本文整理汇总了Java中org.apache.cassandra.db.marshal.CompositeType.build方法的典型用法代码示例。如果您正苦于以下问题:Java CompositeType.build方法的具体用法?Java CompositeType.build怎么用?Java CompositeType.build使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cassandra.db.marshal.CompositeType
的用法示例。
在下文中一共展示了CompositeType.build方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPartitionKey
import org.apache.cassandra.db.marshal.CompositeType; //导入方法依赖的package包/类
private ByteBuffer getPartitionKey(Map<String, ByteBuffer> keyColumns)
{
ByteBuffer partitionKey;
if (keyValidator instanceof CompositeType)
{
ByteBuffer[] keys = new ByteBuffer[partitionKeyColumns.length];
for (int i = 0; i< keys.length; i++)
keys[i] = keyColumns.get(partitionKeyColumns[i]);
partitionKey = CompositeType.build(keys);
}
else
{
partitionKey = keyColumns.get(partitionKeyColumns[0]);
}
return partitionKey;
}
示例2: reachEndRange
import org.apache.cassandra.db.marshal.CompositeType; //导入方法依赖的package包/类
/** check whether current row is at the end of range */
private boolean reachEndRange()
{
// current row key
ByteBuffer rowKey;
if (keyValidator instanceof CompositeType)
{
ByteBuffer[] keys = new ByteBuffer[partitionBoundColumns.size()];
for (int i = 0; i < partitionBoundColumns.size(); i++)
keys[i] = partitionBoundColumns.get(i).value.duplicate();
rowKey = CompositeType.build(keys);
}
else
{
rowKey = partitionBoundColumns.get(0).value;
}
String endToken = split.getEndToken();
String currentToken = partitioner.getToken(rowKey).toString();
logger.debug("End token: {}, current token: {}", endToken, currentToken);
return endToken.equals(currentToken);
}
示例3: getPartitionKey
import org.apache.cassandra.db.marshal.CompositeType; //导入方法依赖的package包/类
private ByteBuffer getPartitionKey(Map<String, ByteBuffer> keyColumns)
{
ByteBuffer partitionKey;
if (partitionKeyColumns.size() > 1)
{
ByteBuffer[] keys = new ByteBuffer[partitionKeyColumns.size()];
for (int i = 0; i< keys.length; i++)
keys[i] = keyColumns.get(partitionKeyColumns.get(i).getName());
partitionKey = CompositeType.build(keys);
}
else
{
partitionKey = keyColumns.get(partitionKeyColumns.get(0).getName());
}
return partitionKey;
}
示例4: reachEndRange
import org.apache.cassandra.db.marshal.CompositeType; //导入方法依赖的package包/类
/**
* check whether current row is at the end of range
*
* @return the boolean
*/
private boolean reachEndRange() {
// current row key
ByteBuffer rowKey;
if (keyValidator instanceof CompositeType) {
ByteBuffer[] keys = new ByteBuffer[partitionBoundColumns.size()];
for (int i = 0; i < partitionBoundColumns.size(); i++) {
keys[i] = partitionBoundColumns.get(i).value.duplicate();
}
rowKey = CompositeType.build(keys);
} else {
rowKey = partitionBoundColumns.get(0).value;
}
String endToken = String.valueOf(split.getEndToken());
String currentToken = partitioner.getToken(rowKey).toString();
return endToken.equals(currentToken);
}
示例5: getPartitionKey
import org.apache.cassandra.db.marshal.CompositeType; //导入方法依赖的package包/类
/**
* Returns the partition key related to a given {@link Cells}.
*
* @param cells {@link Cells} from Cassandra to extract the partition key.
* @param keyValidator Cassandra key type.
* @param numberOfKeys Number of keys.
* @return Partition key.
*/
public static ByteBuffer getPartitionKey(Cells cells, AbstractType<?> keyValidator, int numberOfKeys) {
ByteBuffer partitionKey;
if (keyValidator instanceof CompositeType) {
ByteBuffer[] keys = new ByteBuffer[numberOfKeys];
for (int i = 0; i < cells.size(); i++) {
Cell c = cells.getCellByIdx(i);
if (c.isKey()) {
keys[i] = DataType.serializeValue(c.getValue(), CassandraDeepJobConfig.PROTOCOL_VERSION);
}
}
partitionKey = CompositeType.build(keys);
} else {
Cell cell = cells.getCellByIdx(0);
partitionKey = DataType.serializeValue(cell.getValue(), CassandraDeepJobConfig.PROTOCOL_VERSION);
}
return partitionKey;
}
示例6: reachEndRange
import org.apache.cassandra.db.marshal.CompositeType; //导入方法依赖的package包/类
/**
* check whether current row is at the end of range
*/
private boolean reachEndRange() {
// current row key
ByteBuffer rowKey;
if (keyValidator instanceof CompositeType) {
ByteBuffer[] keys = new ByteBuffer[partitionBoundColumns.size()];
for (int i = 0; i < partitionBoundColumns.size(); i++) {
keys[i] = partitionBoundColumns.get(i).value.duplicate();
}
rowKey = CompositeType.build(keys);
} else {
rowKey = partitionBoundColumns.get(0).value;
}
String endToken = split.getEndToken();
String currentToken = partitioner.getToken(rowKey).toString();
logger.debug("End token: {}, current token: {}", endToken, currentToken);
return endToken.equals(currentToken);
}
示例7: serializePartitionKey
import org.apache.cassandra.db.marshal.CompositeType; //导入方法依赖的package包/类
public static ByteBuffer serializePartitionKey(ClusteringPrefix keyAsClustering)
{
// TODO: we should stop using Clustering for partition keys. Maybe we can add
// a few methods to DecoratedKey so we don't have to (note that while using a Clustering
// allows to use buildBound(), it's actually used for partition keys only when every restriction
// is an equal, so we could easily create a specific method for keys for that.
if (keyAsClustering.size() == 1)
return keyAsClustering.get(0);
ByteBuffer[] values = new ByteBuffer[keyAsClustering.size()];
for (int i = 0; i < keyAsClustering.size(); i++)
values[i] = keyAsClustering.get(i);
return CompositeType.build(values);
}
示例8: addMutation
import org.apache.cassandra.db.marshal.CompositeType; //导入方法依赖的package包/类
public static void addMutation(RowMutation rm, String columnFamilyName, String superColumnName, long columnName, String value, long timestamp)
{
ByteBuffer cname = superColumnName == null
? getBytes(columnName)
: CompositeType.build(ByteBufferUtil.bytes(superColumnName), getBytes(columnName));
rm.add(columnFamilyName, cname, ByteBufferUtil.bytes(value), timestamp);
}
示例9: makeCurrentPartitionKey
import org.apache.cassandra.db.marshal.CompositeType; //导入方法依赖的package包/类
private DecoratedKey makeCurrentPartitionKey()
{
ByteBuffer rawKey = viewMetadata.partitionKeyColumns().size() == 1
? currentViewEntryPartitionKey[0]
: CompositeType.build(currentViewEntryPartitionKey);
return viewMetadata.decorateKey(rawKey);
}
示例10: makeCellName
import org.apache.cassandra.db.marshal.CompositeType; //导入方法依赖的package包/类
private static ByteBuffer makeCellName(Clustering clustering, ColumnDefinition c, CellPath path)
{
int cs = clustering.size();
ByteBuffer[] values = new ByteBuffer[cs + 1 + (path == null ? 0 : path.size())];
for (int i = 0; i < cs; i++)
values[i] = clustering.get(i);
values[cs] = c.name.bytes;
if (path != null)
for (int i = 0; i < path.size(); i++)
values[cs + 1 + i] = path.get(i);
return CompositeType.build(values);
}
示例11: getPartitionKey
import org.apache.cassandra.db.marshal.CompositeType; //导入方法依赖的package包/类
private ByteBuffer getPartitionKey(Map<String, ByteBuffer> keyColumns) {
ByteBuffer partitionKey;
if (keyValidator instanceof CompositeType) {
ByteBuffer[] keys = new ByteBuffer[partitionKeyColumns.length];
for (int i = 0; i < keys.length; i++) {
keys[i] = keyColumns.get(partitionKeyColumns[i]);
}
partitionKey = CompositeType.build(keys);
} else {
partitionKey = keyColumns.get(partitionKeyColumns[0]);
}
return partitionKey;
}
示例12: toByteBuffer
import org.apache.cassandra.db.marshal.CompositeType; //导入方法依赖的package包/类
public static ByteBuffer toByteBuffer(final Object value) {
if (value == null) {
return ByteBufferUtil.EMPTY_BYTE_BUFFER;
} else if (value instanceof CharSequence) {
return ByteBufferUtil.bytes(value.toString());
} else if (value instanceof Double) {
return ByteBufferUtil.bytes((Double) value);
} else if (value instanceof Float) {
return ByteBufferUtil.bytes((Float) value);
} else if (value instanceof Integer) {
return ByteBufferUtil.bytes((Integer) value);
} else if (value instanceof Long) {
return ByteBufferUtil.bytes((Long) value);
} else if (value instanceof ByteBuffer) {
return ByteBufferUtil.clone((ByteBuffer) value);
} else if (value instanceof GenericData.Array) {
return serializeList((GenericData.Array)value);
} else if (value instanceof SpecificRecord) {
List<ByteBuffer> buffers = Lists.newArrayList();
SpecificRecord record = (SpecificRecord) value;
for (Schema.Field field : record.getSchema().getFields()) {
buffers.add(toByteBuffer(record.get(field.pos())));
}
return CompositeType.build(buffers.toArray(new ByteBuffer[0]));
} else if (value instanceof Map) {
return serializeMap((Map<?, ?>) value);
} else if (value instanceof Set) {
return serializeSet((Set<?>) value);
} else if (value instanceof List) {
return serializeList((List<?>) value);
} else if (value instanceof UUID) {
return ByteBufferUtil.bytes((UUID) value);
}
throw new CrunchRuntimeException("Can not transform field (class: " + value.getClass() + ") to ByteBuffer");
}
示例13: getIndexedValue
import org.apache.cassandra.db.marshal.CompositeType; //导入方法依赖的package包/类
public ByteBuffer getIndexedValue(ByteBuffer partitionKey,
Clustering clustering,
CellPath path, ByteBuffer cellValue)
{
return CompositeType.build(path.get(0), cellValue);
}
示例14: bindAndGet
import org.apache.cassandra.db.marshal.CompositeType; //导入方法依赖的package包/类
@Override
public ByteBuffer bindAndGet(List<ByteBuffer> variables) throws InvalidRequestException
{
return CompositeType.build(bindInternal(variables));
}