List of usage examples for org.apache.cassandra.dht IPartitioner getToken
public Token getToken(ByteBuffer key);
From source file:org.elassandra.cluster.InternalCassandraClusterService.java
License:Apache License
@Override public Token getToken(ByteBuffer rowKey, ColumnFamily cf) { IPartitioner partitioner = StorageService.getPartitioner(); CType ctype = cf.metadata().getKeyValidatorAsCType(); if (ctype.isCompound()) { Composite composite = ctype.fromByteBuffer(rowKey); ByteBuffer[] bb = new ByteBuffer[cf.metadata().partitionKeyColumns().size()]; for (int i = 0; i < cf.metadata().partitionKeyColumns().size(); i++) { bb[i] = composite.get(i);/*from w w w .j ava 2 s .c o m*/ } return partitioner.getToken(CompositeType.build(bb)); } return partitioner.getToken(rowKey); }
From source file:org.elassandra.cluster.InternalCassandraClusterService.java
License:Apache License
public Token getToken(String index, String type, String routing) throws JsonParseException, JsonMappingException, IOException { DocPrimaryKey pk = parseElasticRouting(index, type, routing); IPartitioner partitioner = StorageService.getPartitioner(); IndexService indexService = indexServiceSafe(index); String ksName = indexService.settingsService().getSettings().get(IndexMetaData.SETTING_KEYSPACE, index); String cfName = typeToCfName(type); CFMetaData metadata = getCFMetaData(ksName, cfName); CBuilder builder = metadata.getKeyValidatorAsCType().builder(); for (int i = 0; i < pk.values.length; i++) { builder.add(pk.values[i]);/* w ww . j ava 2s . c o m*/ } return partitioner.getToken(builder.build().toByteBuffer()); }
From source file:org.elasticsearch.cassandra.cluster.InternalCassandraClusterService.java
License:Apache License
@Override public Token getToken(ByteBuffer rowKey, ColumnFamily cf) { IPartitioner partitioner = StorageService.instance.getPartitioner(); CType ctype = cf.metadata().getKeyValidatorAsCType(); if (ctype.isCompound()) { Composite composite = ctype.fromByteBuffer(rowKey); ByteBuffer[] bb = new ByteBuffer[cf.metadata().partitionKeyColumns().size()]; for (int i = 0; i < cf.metadata().partitionKeyColumns().size(); i++) { bb[i] = composite.get(i);/* www.ja va 2s . c o m*/ } return partitioner.getToken(CompositeType.build(bb)); } return partitioner.getToken(rowKey); }