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


Java CompositeType.build方法代码示例

本文整理汇总了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;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:18,代码来源:CqlRecordWriter.java

示例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);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:25,代码来源:CqlPagingRecordReader.java

示例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;
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:18,代码来源:CqlRecordWriter.java

示例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);
}
 
开发者ID:Stratio,项目名称:deep-spark,代码行数:26,代码来源:DeepRecordReader.java

示例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;
}
 
开发者ID:Stratio,项目名称:deep-spark,代码行数:29,代码来源:CassandraUtils.java

示例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);
}
 
开发者ID:2013Commons,项目名称:hive-cassandra,代码行数:24,代码来源:CqlPagingRecordReader.java

示例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);
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:15,代码来源:CFMetaData.java

示例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);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:8,代码来源:Util.java

示例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);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:9,代码来源:ViewUpdateGenerator.java

示例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);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:13,代码来源:CounterCacheKey.java

示例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;
}
 
开发者ID:2013Commons,项目名称:hive-cassandra,代码行数:15,代码来源:CqlRecordWriter.java

示例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");
}
 
开发者ID:spotify,项目名称:hdfs2cass,代码行数:38,代码来源:CassandraRecordUtils.java

示例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);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:7,代码来源:CollectionEntryIndex.java

示例14: bindAndGet

import org.apache.cassandra.db.marshal.CompositeType; //导入方法依赖的package包/类
@Override
public ByteBuffer bindAndGet(List<ByteBuffer> variables) throws InvalidRequestException
{
    return CompositeType.build(bindInternal(variables));
}
 
开发者ID:mafernandez-stratio,项目名称:cassandra-cqlMod,代码行数:6,代码来源:UserTypes.java


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