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


Java StorageService.getPartitioner方法代码示例

本文整理汇总了Java中org.apache.cassandra.service.StorageService.getPartitioner方法的典型用法代码示例。如果您正苦于以下问题:Java StorageService.getPartitioner方法的具体用法?Java StorageService.getPartitioner怎么用?Java StorageService.getPartitioner使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.cassandra.service.StorageService的用法示例。


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

示例1: getIndexed

import org.apache.cassandra.service.StorageService; //导入方法依赖的package包/类
private static List<Row> getIndexed(ColumnFamilyStore store, IDiskAtomFilter columnFilter, DecoratedKey startKey, int maxResults, IndexExpression... expressions)
{
    IPartitioner p = StorageService.getPartitioner();
    AbstractBounds<RowPosition> bounds;

    if (startKey == null)
    {
        bounds = new Range<>(p.getMinimumToken(), p.getMinimumToken()).toRowBounds();
    }
    else
    {
        bounds = new Bounds<>(startKey, p.getMinimumToken().maxKeyBound(p));
    }

    return store.indexManager.search(ExtendedFilter.create(store,
                                     new DataRange(bounds, columnFilter),
                                     Arrays.asList(expressions),
                                     maxResults,
                                     false,
                                     System.currentTimeMillis()));
}
 
开发者ID:xedin,项目名称:sasi,代码行数:22,代码来源:SSTableAttachedSecondaryIndexTest.java

示例2: testSatisfiedByWithMultipleTerms

import org.apache.cassandra.service.StorageService; //导入方法依赖的package包/类
@Test
public void testSatisfiedByWithMultipleTerms()
{
    final ByteBuffer comment = UTF8Type.instance.decompose("comment");
    final ColumnFamilyStore store = Keyspace.open("sasecondaryindex").getColumnFamilyStore("saindexed1");
    final IPartitioner<?> partitioner = StorageService.getPartitioner();

    ColumnFamily cf = ArrayBackedSortedColumns.factory.create(store.metadata);
    cf.addColumn(new Column(comment, UTF8Type.instance.decompose("software engineer is working on a project"), System.currentTimeMillis()));

    Operation.Builder builder = new Operation.Builder(OperationType.AND, UTF8Type.instance, controller,
                                        new IndexExpression(comment, IndexOperator.EQ, UTF8Type.instance.decompose("eng is a work")));
    Operation op = builder.complete();

    Assert.assertTrue(op.satisfiedBy(new Row(partitioner.decorateKey(UTF8Type.instance.decompose("key1")), cf), null, false));

    builder = new Operation.Builder(OperationType.AND, UTF8Type.instance, controller,
                                        new IndexExpression(comment, IndexOperator.EQ, UTF8Type.instance.decompose("soft works fine")));
    op = builder.complete();

    Assert.assertTrue(op.satisfiedBy(new Row(partitioner.decorateKey(UTF8Type.instance.decompose("key1")), cf), null, false));
}
 
开发者ID:xedin,项目名称:sasi,代码行数:23,代码来源:OperationTest.java

示例3: testRangeSliceCommandWrite

import org.apache.cassandra.service.StorageService; //导入方法依赖的package包/类
private void testRangeSliceCommandWrite() throws IOException
{
    IPartitioner part = StorageService.getPartitioner();
    AbstractBounds<RowPosition> bounds = new Range<Token>(part.getRandomToken(), part.getRandomToken()).toRowBounds();

    RangeSliceCommand namesCmd = new RangeSliceCommand(statics.KS, "Standard1", statics.readTs, namesPred, bounds, 100);
    MessageOut<RangeSliceCommand> namesCmdMsg = namesCmd.createMessage();
    RangeSliceCommand emptyRangeCmd = new RangeSliceCommand(statics.KS, "Standard1", statics.readTs, emptyRangePred, bounds, 100);
    MessageOut<RangeSliceCommand> emptyRangeCmdMsg = emptyRangeCmd.createMessage();
    RangeSliceCommand regRangeCmd = new RangeSliceCommand(statics.KS, "Standard1", statics.readTs, nonEmptyRangePred, bounds, 100);
    MessageOut<RangeSliceCommand> regRangeCmdMsg = regRangeCmd.createMessage();
    RangeSliceCommand namesCmdSup = new RangeSliceCommand(statics.KS, "Super1", statics.readTs, namesSCPred, bounds, 100);
    MessageOut<RangeSliceCommand> namesCmdSupMsg = namesCmdSup.createMessage();
    RangeSliceCommand emptyRangeCmdSup = new RangeSliceCommand(statics.KS, "Super1", statics.readTs, emptyRangePred, bounds, 100);
    MessageOut<RangeSliceCommand> emptyRangeCmdSupMsg = emptyRangeCmdSup.createMessage();
    RangeSliceCommand regRangeCmdSup = new RangeSliceCommand(statics.KS, "Super1", statics.readTs, nonEmptyRangeSCPred, bounds, 100);
    MessageOut<RangeSliceCommand> regRangeCmdSupMsg = regRangeCmdSup.createMessage();

    DataOutputStream out = getOutput("db.RangeSliceCommand.bin");
    namesCmdMsg.serialize(out, getVersion());
    emptyRangeCmdMsg.serialize(out, getVersion());
    regRangeCmdMsg.serialize(out, getVersion());
    namesCmdSupMsg.serialize(out, getVersion());
    emptyRangeCmdSupMsg.serialize(out, getVersion());
    regRangeCmdSupMsg.serialize(out, getVersion());
    out.close();

    // test serializedSize
    testSerializedSize(namesCmd, RangeSliceCommand.serializer);
    testSerializedSize(emptyRangeCmd, RangeSliceCommand.serializer);
    testSerializedSize(regRangeCmd, RangeSliceCommand.serializer);
    testSerializedSize(namesCmdSup, RangeSliceCommand.serializer);
    testSerializedSize(emptyRangeCmdSup, RangeSliceCommand.serializer);
    testSerializedSize(regRangeCmdSup, RangeSliceCommand.serializer);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:36,代码来源:SerializationsTest.java

示例4: getMaximumToken

import org.apache.cassandra.service.StorageService; //导入方法依赖的package包/类
private static Token getMaximumToken() throws PermanentBackendException {
    IPartitioner partitioner = StorageService.getPartitioner();

    if (partitioner instanceof RandomPartitioner) {
        return new BigIntegerToken(RandomPartitioner.MAXIMUM);
    } else if (partitioner instanceof Murmur3Partitioner) {
        return new LongToken(Murmur3Partitioner.MAXIMUM);
    } else if (partitioner instanceof ByteOrderedPartitioner) {
        //TODO: This makes the assumption that its an EdgeStore (i.e. 8 byte keys)
        return new BytesToken(com.thinkaurelius.titan.diskstorage.util.ByteBufferUtil.oneByteBuffer(8));
    } else {
        throw new PermanentBackendException("Unsupported partitioner: " + partitioner);
    }
}
 
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:15,代码来源:CassandraEmbeddedKeyColumnValueStore.java

示例5: getMinimumToken

import org.apache.cassandra.service.StorageService; //导入方法依赖的package包/类
private static Token getMinimumToken() throws PermanentBackendException {
    IPartitioner partitioner = StorageService.getPartitioner();

    if (partitioner instanceof RandomPartitioner) {
        return ((RandomPartitioner) partitioner).getMinimumToken();
    } else if (partitioner instanceof Murmur3Partitioner) {
        return ((Murmur3Partitioner) partitioner).getMinimumToken();
    } else if (partitioner instanceof ByteOrderedPartitioner) {
        //TODO: This makes the assumption that its an EdgeStore (i.e. 8 byte keys)
        return new BytesToken(com.thinkaurelius.titan.diskstorage.util.ByteBufferUtil.zeroByteBuffer(8));
    } else {
        throw new PermanentBackendException("Unsupported partitioner: " + partitioner);
    }
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:15,代码来源:CassandraEmbeddedKeyColumnValueStore.java

示例6: testRandomSSTableTransfer

import org.apache.cassandra.service.StorageService; //导入方法依赖的package包/类
@Test
public void testRandomSSTableTransfer() throws Exception
{
    final Keyspace keyspace = Keyspace.open("Keyspace1");
    final ColumnFamilyStore cfs = keyspace.getColumnFamilyStore("Standard1");
    Mutator mutator = new Mutator()
    {
        public void mutate(String key, String colName, long timestamp) throws Exception
        {
            ColumnFamily cf = ArrayBackedSortedColumns.factory.create(keyspace.getName(), cfs.name);
            cf.addColumn(column(colName, "value", timestamp));
            cf.addColumn(new BufferCell(cellname("birthdate"), ByteBufferUtil.bytes(new Date(timestamp).toString()), timestamp));
            Mutation rm = new Mutation("Keyspace1", ByteBufferUtil.bytes(key), cf);
            logger.debug("Applying row to transfer " + rm);
            rm.apply();
        }
    };
    // write a lot more data so the data is spread in more than 1 chunk.
    for (int i = 1; i <= 6000; i++)
        mutator.mutate("key" + i, "col" + i, System.currentTimeMillis());
    cfs.forceBlockingFlush();
    Util.compactAll(cfs, Integer.MAX_VALUE).get();
    SSTableReader sstable = cfs.getSSTables().iterator().next();
    cfs.clearUnsafe();

    IPartitioner p = StorageService.getPartitioner();
    List<Range<Token>> ranges = new ArrayList<>();
    ranges.add(new Range<>(p.getToken(ByteBufferUtil.bytes("key1")), p.getToken(ByteBufferUtil.bytes("key1000"))));
    ranges.add(new Range<>(p.getToken(ByteBufferUtil.bytes("key5")), p.getToken(ByteBufferUtil.bytes("key500"))));
    ranges.add(new Range<>(p.getToken(ByteBufferUtil.bytes("key9")), p.getToken(ByteBufferUtil.bytes("key900"))));
    transfer(sstable, ranges);
    assertEquals(1, cfs.getSSTables().size());
    assertEquals(7, Util.getRangeSlice(cfs).size());
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:35,代码来源:StreamingTransferTest.java

示例7: getCassandraPartitioner

import org.apache.cassandra.service.StorageService; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public IPartitioner getCassandraPartitioner()
        throws BackendException {
    try {
        return StorageService.getPartitioner();
    } catch (Exception e) {
        log.warn("Could not read local token range: {}", e);
        throw new PermanentBackendException("Could not read partitioner information on cluster", e);
    }
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:12,代码来源:CassandraEmbeddedStoreManager.java

示例8: getKeySlice

import org.apache.cassandra.service.StorageService; //导入方法依赖的package包/类
/**
 * Create a RangeSliceCommand and run it against the StorageProxy.
 * <p>
 * To match the behavior of the standard Cassandra thrift API endpoint, the
 * {@code nowMillis} argument should be the number of milliseconds since the
 * UNIX Epoch (e.g. System.currentTimeMillis() or equivalent obtained
 * through a {@link TimestampProvider}). This is per
 * {@link org.apache.cassandra.thrift.CassandraServer#get_range_slices(ColumnParent, SlicePredicate, KeyRange, ConsistencyLevel)},
 * which passes the server's System.currentTimeMillis() to the
 * {@code RangeSliceCommand} constructor.
 */
private List<Row> getKeySlice(Token start,
                              Token end,
                              @Nullable SliceQuery sliceQuery,
                              int pageSize,
                              long nowMillis) throws BackendException {
    IPartitioner partitioner = StorageService.getPartitioner();

    SliceRange columnSlice = new SliceRange();
    if (sliceQuery == null) {
        columnSlice.setStart(ArrayUtils.EMPTY_BYTE_ARRAY)
                .setFinish(ArrayUtils.EMPTY_BYTE_ARRAY)
                .setCount(5);
    } else {
        columnSlice.setStart(sliceQuery.getSliceStart().asByteBuffer())
                .setFinish(sliceQuery.getSliceEnd().asByteBuffer())
                .setCount(sliceQuery.hasLimit() ? sliceQuery.getLimit() : Integer.MAX_VALUE);
    }
    /* Note: we need to fetch columns for each row as well to remove "range ghosts" */
    SlicePredicate predicate = new SlicePredicate().setSlice_range(columnSlice);

    RowPosition startPosition = start.minKeyBound(partitioner);
    RowPosition endPosition = end.minKeyBound(partitioner);

    List<Row> rows;

    try {
        CFMetaData cfm = Schema.instance.getCFMetaData(keyspace, columnFamily);
        IDiskAtomFilter filter = ThriftValidation.asIFilter(predicate, cfm, null);

        RangeSliceCommand cmd = new RangeSliceCommand(keyspace, columnFamily, nowMillis, filter, new Bounds<RowPosition>(startPosition, endPosition), pageSize);

        rows = StorageProxy.getRangeSlice(cmd, ConsistencyLevel.QUORUM);
    } catch (Exception e) {
        throw new PermanentBackendException(e);
    }

    return rows;
}
 
开发者ID:graben1437,项目名称:titan1.0.1.kafka,代码行数:50,代码来源:CassandraEmbeddedKeyColumnValueStore.java

示例9: open

import org.apache.cassandra.service.StorageService; //导入方法依赖的package包/类
public static SSTableReader open(Descriptor desc, CFMetaData metadata) throws IOException
{
    IPartitioner p = desc.cfname.contains(SECONDARY_INDEX_NAME_SEPARATOR)
                   ? new LocalPartitioner(metadata.getKeyValidator())
                   : StorageService.getPartitioner();
    return open(desc, componentsFor(desc), metadata, p);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:8,代码来源:SSTableReader.java

示例10: getKeySlice

import org.apache.cassandra.service.StorageService; //导入方法依赖的package包/类
/**
 * Create a RangeSliceCommand and run it against the StorageProxy.
 * <p>
 * To match the behavior of the standard Cassandra thrift API endpoint, the
 * {@code nowMillis} argument should be the number of milliseconds since the
 * UNIX Epoch (e.g. System.currentTimeMillis() or equivalent obtained
 * through a {@link TimestampProvider}). This is per
 * {@link org.apache.cassandra.thrift.CassandraServer#get_range_slices(ColumnParent, SlicePredicate, KeyRange, ConsistencyLevel)},
 * which passes the server's System.currentTimeMillis() to the
 * {@code RangeSliceCommand} constructor.
 */
private List<Row> getKeySlice(Token start,
                              Token end,
                              @Nullable SliceQuery sliceQuery,
                              int pageSize,
                              long nowMillis) throws BackendException {
    IPartitioner<?> partitioner = StorageService.getPartitioner();

    SliceRange columnSlice = new SliceRange();
    if (sliceQuery == null) {
        columnSlice.setStart(ArrayUtils.EMPTY_BYTE_ARRAY)
                .setFinish(ArrayUtils.EMPTY_BYTE_ARRAY)
                .setCount(5);
    } else {
        columnSlice.setStart(sliceQuery.getSliceStart().asByteBuffer())
                .setFinish(sliceQuery.getSliceEnd().asByteBuffer())
                .setCount(sliceQuery.hasLimit() ? sliceQuery.getLimit() : Integer.MAX_VALUE);
    }
    /* Note: we need to fetch columns for each row as well to remove "range ghosts" */
    SlicePredicate predicate = new SlicePredicate().setSlice_range(columnSlice);

    RowPosition startPosition = start.minKeyBound(partitioner);
    RowPosition endPosition = end.minKeyBound(partitioner);

    List<Row> rows;

    try {
        CFMetaData cfm = Schema.instance.getCFMetaData(keyspace, columnFamily);
        IDiskAtomFilter filter = ThriftValidation.asIFilter(predicate, cfm, null);

        RangeSliceCommand cmd = new RangeSliceCommand(keyspace, columnFamily, nowMillis, filter, new Bounds<RowPosition>(startPosition, endPosition), pageSize);

        rows = StorageProxy.getRangeSlice(cmd, ConsistencyLevel.QUORUM);
    } catch (Exception e) {
        throw new PermanentBackendException(e);
    }

    return rows;
}
 
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:50,代码来源:CassandraEmbeddedKeyColumnValueStore.java

示例11: getKeys

import org.apache.cassandra.service.StorageService; //导入方法依赖的package包/类
@Override
public KeyIterator getKeys(KeyRangeQuery keyRangeQuery, StoreTransaction txh) throws BackendException {
    IPartitioner partitioner = StorageService.getPartitioner();

    // see rant about this in Astyanax implementation
    if (partitioner instanceof RandomPartitioner || partitioner instanceof Murmur3Partitioner)
        throw new PermanentBackendException("This operation is only supported when byte-ordered partitioner is used.");

    return new RowIterator(keyRangeQuery, storeManager.getPageSize(), txh);
}
 
开发者ID:graben1437,项目名称:titan1.0.1.kafka,代码行数:11,代码来源:CassandraEmbeddedKeyColumnValueStore.java

示例12: SSTableWriter

import org.apache.cassandra.service.StorageService; //导入方法依赖的package包/类
public SSTableWriter(String filename, long keyCount, long repairedAt)
{
    this(filename,
         keyCount,
         repairedAt,
         Schema.instance.getCFMetaData(Descriptor.fromFilename(filename)),
         StorageService.getPartitioner(),
         new MetadataCollector(Schema.instance.getCFMetaData(Descriptor.fromFilename(filename)).comparator));
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:10,代码来源:SSTableWriter.java

示例13: getCassandraPartitioner

import org.apache.cassandra.service.StorageService; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public IPartitioner<? extends Token<?>> getCassandraPartitioner()
        throws BackendException {
    try {
        return StorageService.getPartitioner();
    } catch (Exception e) {
        log.warn("Could not read local token range: {}", e);
        throw new PermanentBackendException("Could not read partitioner information on cluster", e);
    }
}
 
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:12,代码来源:CassandraEmbeddedStoreManager.java

示例14: transferSSTables

import org.apache.cassandra.service.StorageService; //导入方法依赖的package包/类
private void transferSSTables(SSTableReader sstable) throws Exception
{
    IPartitioner p = StorageService.getPartitioner();
    List<Range<Token>> ranges = new ArrayList<>();
    ranges.add(new Range<>(p.getMinimumToken(), p.getToken(ByteBufferUtil.bytes("key1"))));
    ranges.add(new Range<>(p.getToken(ByteBufferUtil.bytes("key2")), p.getMinimumToken()));
    transfer(sstable, ranges);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:9,代码来源:StreamingTransferTest.java

示例15: deserialize

import org.apache.cassandra.service.StorageService; //导入方法依赖的package包/类
public Token deserialize(DataInput in) throws IOException
{
    IPartitioner p = StorageService.getPartitioner();
    int size = in.readInt();
    byte[] bytes = new byte[size];
    in.readFully(bytes);
    return p.getTokenFactory().fromByteArray(ByteBuffer.wrap(bytes));
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:9,代码来源:Token.java


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