Example usage for org.apache.cassandra.config DatabaseDescriptor getPartitioner

List of usage examples for org.apache.cassandra.config DatabaseDescriptor getPartitioner

Introduction

In this page you can find the example usage for org.apache.cassandra.config DatabaseDescriptor getPartitioner.

Prototype

public static IPartitioner getPartitioner() 

Source Link

Usage

From source file:com.stratio.cassandra.index.PartitionKeyMapper.java

License:Apache License

/**
 * Returns a new {@code PartitionKeyMapper} according to the specified column family meta data.
 *
 * @param metadata The column family metadata.
 *//*  ww  w .  j a va  2s . c om*/
private PartitionKeyMapper(CFMetaData metadata) {
    partitioner = DatabaseDescriptor.getPartitioner();
    this.metadata = metadata;
    this.type = metadata.getKeyValidator();
}

From source file:com.stratio.cassandra.index.TokenMapper.java

License:Apache License

/**
 * Returns a new {@link TokenMapper} instance for the current partitioner using the specified column family
 * metadata./*from w  ww.j  a  va2s .  c o  m*/
 *
 * @param metadata The column family metadata.
 * @return A new {@link TokenMapper} instance for the current partitioner.
 */
public static TokenMapper instance(CFMetaData metadata) {
    IPartitioner partitioner = DatabaseDescriptor.getPartitioner();
    if (partitioner instanceof Murmur3Partitioner) {
        return new TokenMapperMurmur(metadata);
    } else {
        return new TokenMapperGeneric(metadata);
    }
}

From source file:com.stratio.cassandra.index.TokenMapper.java

License:Apache License

/**
 * Returns {@code true} if the specified {@link Token} is the minimum accepted by the {@link IPartitioner}, {@code
 * false} otherwise.//from  w ww  . jav  a2  s .co  m
 *
 * @param token A {@link Token}.
 * @return {@code true} if the specified {@link Token} is the minimum accepted by the {@link IPartitioner}, {@code
 * false} otherwise.
 */
public boolean isMinimum(Token token) {
    Token minimum = DatabaseDescriptor.getPartitioner().getMinimumToken();
    return token.compareTo(minimum) == 0;
}

From source file:com.stratio.cassandra.index.TokenMapperGeneric.java

License:Apache License

/** Returns a new {@link TokenMapperGeneric}. */
public TokenMapperGeneric(CFMetaData metadata) {
    super(metadata);
    factory = DatabaseDescriptor.getPartitioner().getTokenFactory();
}

From source file:com.stratio.cassandra.lucene.IndexPagingState.java

License:Apache License

/**
 * Returns the paging state represented by the specified byte buffer, which should have been generated with {@link
 * #toByteBuffer()}.//from w  w  w  . ja  v a 2s.  co m
 *
 * @param bb a byte buffer generated by {@link #toByteBuffer()}
 * @return the paging state reperesented by {@code bb}
 */
public static IndexPagingState build(ByteBuffer bb) {
    int remaining = readShortLength(bb);
    IndexPagingState state = new IndexPagingState(remaining);
    Arrays.asList(decompose(bb)).stream().forEach(bbe -> {
        ByteBuffer[] values = decompose(bbe);
        DecoratedKey key = DatabaseDescriptor.getPartitioner().decorateKey(values[0]);
        Clustering clustering = new Clustering(Arrays.copyOfRange(values, 1, values.length));
        state.entries.put(key, clustering);
    });
    return state;
}

From source file:com.stratio.cassandra.lucene.key.KeyEntry.java

License:Apache License

/**
 * Returns the decorated partition key.
 *
 * @return the partition key
 */
public DecoratedKey getDecoratedKey() {
    return DatabaseDescriptor.getPartitioner().decorateKey(getKey());
}

From source file:com.stratio.cassandra.lucene.key.PartitionMapper.java

License:Apache License

/**
 * Constructor specifying the indexed table {@link CFMetaData}.
 *
 * @param metadata the indexed table metadata
 *///  ww  w. j a  va2  s.  c  o  m
public PartitionMapper(CFMetaData metadata) {
    this.metadata = metadata;
    partitioner = DatabaseDescriptor.getPartitioner();
    type = metadata.getKeyValidator();
}

From source file:com.stratio.cassandra.lucene.key.TokenMapper.java

License:Apache License

/**
 * Constructor taking the cache size./*from w w w.j  av a 2 s. co  m*/
 *
 * @param cacheSize the max token cache size
 */
public TokenMapper(int cacheSize) {
    if (!(DatabaseDescriptor.getPartitioner() instanceof Murmur3Partitioner)) {
        throw new IndexException("Only Murmur3 partitioner is supported");
    }
    cache = CacheBuilder.newBuilder().maximumSize(cacheSize).build();
}

From source file:com.stratio.cassandra.lucene.service.TokenMapper.java

License:Apache License

/**
 * Returns a new {@link TokenMapper} instance for the current partitioner using the specified column family
 * metadata.//from w w  w .j ava2 s. c  o  m
 *
 * @return A new {@link TokenMapper} instance for the current partitioner.
 */
public static TokenMapper instance() {
    IPartitioner partitioner = DatabaseDescriptor.getPartitioner();
    if (partitioner instanceof Murmur3Partitioner) {
        return new TokenMapperMurmur();
    } else {
        return new TokenMapperGeneric();
    }
}

From source file:com.stratio.cassandra.lucene.service.TokenMapperGeneric.java

License:Apache License

/** Returns a new {@link TokenMapperGeneric}. */
public TokenMapperGeneric() {
    super();
    factory = DatabaseDescriptor.getPartitioner().getTokenFactory();
}