当前位置: 首页>>代码示例>>Java>>正文


Java PartitionPosition类代码示例

本文整理汇总了Java中org.apache.cassandra.db.PartitionPosition的典型用法代码示例。如果您正苦于以下问题:Java PartitionPosition类的具体用法?Java PartitionPosition怎么用?Java PartitionPosition使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PartitionPosition类属于org.apache.cassandra.db包,在下文中一共展示了PartitionPosition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: binarySearch

import org.apache.cassandra.db.PartitionPosition; //导入依赖的package包/类
public int binarySearch(PartitionPosition key)
{
    // We will be comparing non-native Keys, so use a buffer with appropriate byte order
    ByteBuffer hollow = MemoryUtil.getHollowDirectByteBuffer().order(ByteOrder.BIG_ENDIAN);
    int low = 0, mid = offsetCount, high = mid - 1, result = -1;
    while (low <= high)
    {
        mid = (low + high) >> 1;
        fillTemporaryKey(mid, hollow);
        result = -DecoratedKey.compareTo(partitioner, hollow, key);
        if (result > 0)
        {
            low = mid + 1;
        }
        else if (result == 0)
        {
            return mid;
        }
        else
        {
            high = mid - 1;
        }
    }

    return -mid - (result < 0 ? 1 : 2);
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:27,代码来源:IndexSummary.java

示例2: testNormalizeComplex

import org.apache.cassandra.db.PartitionPosition; //导入依赖的package包/类
@Test
public void testNormalizeComplex()
{
    List<Range<PartitionPosition>> input, expected;

    input = asList(range("8", "2"), range("7", "9"), range("4", "5"));
    expected = asList(range("", "2"), range("4", "5"), range("7", ""));
    assertNormalize(input, expected);

    input = asList(range("5", "9"), range("2", "5"));
    expected = asList(range("2", "9"));
    assertNormalize(input, expected);

    input = asList(range ("", "1"), range("9", "2"), range("4", "5"), range("", ""));
    expected = asList(range("", ""));
    assertNormalize(input, expected);

    input = asList(range ("", "1"), range("1", "4"), range("4", "5"), range("5", ""));
    expected = asList(range("", ""));
    assertNormalize(input, expected);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:22,代码来源:RangeTest.java

示例3: testSSTablesInBounds

import org.apache.cassandra.db.PartitionPosition; //导入依赖的package包/类
@Test
public void testSSTablesInBounds()
{
    ColumnFamilyStore cfs = MockSchema.newCFS();
    View initialView = fakeView(0, 5, cfs);
    for (int i = 0 ; i < 5 ; i++)
    {
        for (int j = i ; j < 5 ; j++)
        {
            PartitionPosition min = MockSchema.readerBounds(i);
            PartitionPosition max = MockSchema.readerBounds(j);
            for (boolean minInc : new boolean[] { true })//, false} )
            {
                for (boolean maxInc : new boolean[] { true })//, false} )
                {
                    if (i == j && !(minInc && maxInc))
                        continue;

                    AbstractBounds<PartitionPosition> bounds = AbstractBounds.bounds(min, minInc, max, maxInc);
                    List<SSTableReader> r = ImmutableList.copyOf(initialView.liveSSTablesInBounds(bounds.left, bounds.right));
                    Assert.assertEquals(String.format("%d(%s) %d(%s)", i, minInc, j, maxInc), j - i + (minInc ? 0 : -1) + (maxInc ? 1 : 0), r.size());
                }
            }
        }
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:27,代码来源:ViewTest.java

示例4: compareTo

import org.apache.cassandra.db.PartitionPosition; //导入依赖的package包/类
public int compareTo(PartitionPosition pos)
{
    if (this == pos)
        return 0;

    int cmp = getToken().compareTo(pos.getToken());
    if (cmp != 0)
        return cmp;

    if (isMinimumBound)
        return ((pos instanceof KeyBound) && ((KeyBound)pos).isMinimumBound) ? 0 : -1;
    else
        return ((pos instanceof KeyBound) && !((KeyBound)pos).isMinimumBound) ? 0 : 1;
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:15,代码来源:Token.java

示例5: buildIntervals

import org.apache.cassandra.db.PartitionPosition; //导入依赖的package包/类
public static List<Interval<PartitionPosition, SSTableReader>> buildIntervals(Iterable<SSTableReader> sstables)
{
    List<Interval<PartitionPosition, SSTableReader>> intervals = new ArrayList<>(Iterables.size(sstables));
    for (SSTableReader sstable : sstables)
        intervals.add(Interval.<PartitionPosition, SSTableReader>create(sstable.first, sstable.last, sstable));
    return intervals;
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:8,代码来源:SSTableIntervalTree.java

示例6: getIndexScanPosition

import org.apache.cassandra.db.PartitionPosition; //导入依赖的package包/类
/**
 * Gets the position in the index file to start scanning to find the given key (at most indexInterval keys away,
 * modulo downsampling of the index summary). Always returns a {@code value >= 0}
 */
public long getIndexScanPosition(PartitionPosition key)
{
    if (openReason == OpenReason.MOVED_START && key.compareTo(first) < 0)
        key = first;

    return getIndexScanPositionFromBinarySearchResult(indexSummary.binarySearch(key), indexSummary);
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:12,代码来源:SSTableReader.java

示例7: firstKeyBeyond

import org.apache.cassandra.db.PartitionPosition; //导入依赖的package包/类
/**
 * Finds and returns the first key beyond a given token in this SSTable or null if no such key exists.
 */
public DecoratedKey firstKeyBeyond(PartitionPosition token)
{
    if (token.compareTo(first) < 0)
        return first;

    long sampledPosition = getIndexScanPosition(token);

    if (ifile == null)
        return null;

    String path = null;
    try (FileDataInput in = ifile.createReader(sampledPosition))
    {
        path = in.getPath();
        while (!in.isEOF())
        {
            ByteBuffer indexKey = ByteBufferUtil.readWithShortLength(in);
            DecoratedKey indexDecoratedKey = decorateKey(indexKey);
            if (indexDecoratedKey.compareTo(token) > 0)
                return indexDecoratedKey;

            RowIndexEntry.Serializer.skip(in, descriptor.version);
        }
    }
    catch (IOException e)
    {
        markSuspect();
        throw new CorruptSSTableException(e, path);
    }

    return null;
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:36,代码来源:SSTableReader.java

示例8: validKey

import org.apache.cassandra.db.PartitionPosition; //导入依赖的package包/类
private boolean validKey(DataRange dataRange) {
	PartitionPosition start = dataRange.startKey();
	if (currentPosition.compareTo(start) == 0 && startPosition.compareTo(start) <= 0) {
		PartitionPosition stop = dataRange.stopKey();
		return stopPosition.compareTo(stop) == 0;
	}
	return false;
}
 
开发者ID:jmiddleton,项目名称:cassandra-fhir-index,代码行数:9,代码来源:SearchCacheEntry.java

示例9: liveSSTablesInBounds

import org.apache.cassandra.db.PartitionPosition; //导入依赖的package包/类
/**
 * Returns the sstables that have any partition between {@code left} and {@code right}, when both bounds are taken inclusively.
 * The interval formed by {@code left} and {@code right} shouldn't wrap.
 */
public Iterable<SSTableReader> liveSSTablesInBounds(PartitionPosition left, PartitionPosition right)
{
    assert !AbstractBounds.strictlyWrapsAround(left, right);

    if (intervalTree.isEmpty())
        return Collections.emptyList();

    PartitionPosition stopInTree = right.isMinimum() ? intervalTree.max() : right;
    return intervalTree.search(Interval.create(left, stopInTree));
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:15,代码来源:View.java

示例10: sstablesInBounds

import org.apache.cassandra.db.PartitionPosition; //导入依赖的package包/类
public static List<SSTableReader> sstablesInBounds(PartitionPosition left, PartitionPosition right, SSTableIntervalTree intervalTree)
{
    assert !AbstractBounds.strictlyWrapsAround(left, right);

    if (intervalTree.isEmpty())
        return Collections.emptyList();

    PartitionPosition stopInTree = right.isMinimum() ? intervalTree.max() : right;
    return intervalTree.search(Interval.create(left, stopInTree));
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:11,代码来源:View.java

示例11: selectLive

import org.apache.cassandra.db.PartitionPosition; //导入依赖的package包/类
/**
 * @return a ViewFragment containing the sstables and memtables that may need to be merged
 * for rows within @param rowBounds, inclusive, according to the interval tree.
 */
public static Function<View, Iterable<SSTableReader>> selectLive(AbstractBounds<PartitionPosition> rowBounds)
{
    // Note that View.sstablesInBounds always includes it's bound while rowBounds may not. This is ok however
    // because the fact we restrict the sstables returned by this function is an optimization in the first
    // place and the returned sstables will (almost) never cover *exactly* rowBounds anyway. It's also
    // *very* unlikely that a sstable is included *just* because we consider one of the bound inclusively
    // instead of exclusively, so the performance impact is negligible in practice.
    return (view) -> view.liveSSTablesInBounds(rowBounds.left, rowBounds.right);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:14,代码来源:View.java

示例12: LeveledManifest

import org.apache.cassandra.db.PartitionPosition; //导入依赖的package包/类
LeveledManifest(ColumnFamilyStore cfs, int maxSSTableSizeInMB, SizeTieredCompactionStrategyOptions options)
{
    this.cfs = cfs;
    this.maxSSTableSizeInBytes = maxSSTableSizeInMB * 1024L * 1024L;
    this.options = options;

    generations = new List[MAX_LEVEL_COUNT];
    lastCompactedKeys = new PartitionPosition[MAX_LEVEL_COUNT];
    for (int i = 0; i < generations.length; i++)
    {
        generations[i] = new ArrayList<>();
        lastCompactedKeys[i] = cfs.getPartitioner().getMinimumToken().minKeyBound();
    }
    compactionCounter = new int[MAX_LEVEL_COUNT];
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:16,代码来源:LeveledManifest.java

示例13: testNormalizeNoop

import org.apache.cassandra.db.PartitionPosition; //导入依赖的package包/类
@Test
public void testNormalizeNoop()
{
    List<Range<PartitionPosition>> l;

    l = asList(range("1", "3"), range("4", "5"));
    assertNormalize(l, l);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:9,代码来源:RangeTest.java

示例14: testNormalizeSimpleOverlap

import org.apache.cassandra.db.PartitionPosition; //导入依赖的package包/类
@Test
public void testNormalizeSimpleOverlap()
{
    List<Range<PartitionPosition>> input, expected;

    input = asList(range("1", "4"), range("3", "5"));
    expected = asList(range("1", "5"));
    assertNormalize(input, expected);

    input = asList(range("1", "4"), range("1", "4"));
    expected = asList(range("1", "4"));
    assertNormalize(input, expected);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:14,代码来源:RangeTest.java

示例15: testNormalizeSort

import org.apache.cassandra.db.PartitionPosition; //导入依赖的package包/类
@Test
public void testNormalizeSort()
{
    List<Range<PartitionPosition>> input, expected;

    input = asList(range("4", "5"), range("1", "3"));
    expected = asList(range("1", "3"), range("4", "5"));
    assertNormalize(input, expected);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:10,代码来源:RangeTest.java


注:本文中的org.apache.cassandra.db.PartitionPosition类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。