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


Java Composite类代码示例

本文整理汇总了Java中org.apache.cassandra.db.composites.Composite的典型用法代码示例。如果您正苦于以下问题:Java Composite类的具体用法?Java Composite怎么用?Java Composite使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: minComponents

import org.apache.cassandra.db.composites.Composite; //导入依赖的package包/类
/**
 * finds the min cell name component(s)
 *
 * Note that this method *can modify maxSeen*.
 *
 * @param minSeen the max columns seen so far
 * @param candidate the candidate column(s)
 * @param comparator the comparator to use
 * @return a list with the min column(s)
 */
public static List<ByteBuffer> minComponents(List<ByteBuffer> minSeen, Composite candidate, CellNameType comparator)
{
    // For a cell name, no reason to look more than the clustering prefix
    // (and comparing the collection element would actually crash)
    int size = Math.min(candidate.size(), comparator.clusteringPrefixSize());

    if (minSeen.isEmpty())
        return getComponents(candidate, size);

    // In most case maxSeen is big enough to hold the result so update it in place in those cases
    minSeen = maybeGrow(minSeen, size);

    for (int i = 0; i < size; i++)
        minSeen.set(i, min(minSeen.get(i), candidate.get(i), comparator.subtype(i)));

    return minSeen;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:28,代码来源:ColumnNameHelper.java

示例2: execute

import org.apache.cassandra.db.composites.Composite; //导入依赖的package包/类
public void execute(ByteBuffer rowKey, ColumnFamily cf, Composite prefix, UpdateParameters params) throws InvalidRequestException
{
    assert column.type.isMultiCell() : "Attempted to remove items from a frozen set";

    Term.Terminal value = t.bind(params.options);
    if (value == null)
        return;

    // This can be either a set or a single element
    Set<ByteBuffer> toDiscard = value instanceof Sets.Value
                              ? ((Sets.Value)value).elements
                              : Collections.singleton(value.get(params.options));

    for (ByteBuffer bb : toDiscard)
    {
        cf.addColumn(params.makeTombstone(cf.getComparator().create(prefix, column, bb)));
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:19,代码来源:Sets.java

示例3: execute

import org.apache.cassandra.db.composites.Composite; //导入依赖的package包/类
public void execute(ByteBuffer rowKey, ColumnFamily cf, Composite prefix, UpdateParameters params) throws InvalidRequestException
{
    assert column.type.isMultiCell() : "Attempted to prepend to a frozen list";
    Term.Terminal value = t.bind(params.options);
    if (value == null)
        return;

    assert value instanceof Lists.Value;
    long time = PrecisionTime.REFERENCE_TIME - (System.currentTimeMillis() - PrecisionTime.REFERENCE_TIME);

    List<ByteBuffer> toAdd = ((Lists.Value)value).elements;
    for (int i = toAdd.size() - 1; i >= 0; i--)
    {
        PrecisionTime pt = PrecisionTime.getNext(time);
        ByteBuffer uuid = ByteBuffer.wrap(UUIDGen.getTimeUUIDBytes(pt.millis, pt.nanos));
        cf.addColumn(params.makeColumn(cf.getComparator().create(prefix, column, uuid), toAdd.get(i)));
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:19,代码来源:Lists.java

示例4: testBuildBoundWithOneEqRestrictionsAndTwoClusteringColumns

import org.apache.cassandra.db.composites.Composite; //导入依赖的package包/类
/**
 * Test 'clustering_1 = 1' with 2 clustering columns
 */
@Test
public void testBuildBoundWithOneEqRestrictionsAndTwoClusteringColumns() throws InvalidRequestException
{
    ByteBuffer clustering_2 = ByteBufferUtil.bytes(1);
    SingleColumnRestriction.EQ eq = new SingleColumnRestriction.EQ(toTerm(clustering_2), false);
    Restriction[] restrictions = new Restriction[] { eq, null };

    List<Composite> bounds = executeBuildBound(restrictions, Bound.START);
    assertEquals(1, bounds.size());
    assertComposite(bounds.get(0), clustering_2, EOC.START);

    bounds = executeBuildBound(restrictions, Bound.END);
    assertEquals(1, bounds.size());
    assertComposite(bounds.get(0), clustering_2, EOC.END);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:19,代码来源:SelectStatementTest.java

示例5: executeWithCondition

import org.apache.cassandra.db.composites.Composite; //导入依赖的package包/类
public ResultMessage executeWithCondition(QueryState queryState, QueryOptions options)
throws RequestExecutionException, RequestValidationException
{
    List<ByteBuffer> keys = buildPartitionKeyNames(options);
    // We don't support IN for CAS operation so far
    if (keys.size() > 1)
        throw new InvalidRequestException("IN on the partition key is not supported with conditional updates");

    ByteBuffer key = keys.get(0);
    long now = options.getTimestamp(queryState);
    Composite prefix = createClusteringPrefix(options);

    CQL3CasRequest request = new CQL3CasRequest(cfm, key, false);
    addConditions(prefix, request, options);
    request.addRowUpdate(prefix, this, options, now);

    ColumnFamily result = StorageProxy.cas(keyspace(),
                                           columnFamily(),
                                           key,
                                           request,
                                           options.getSerialConsistency(),
                                           options.getConsistency(),
                                           queryState.getClientState());
    return new ResultMessage.Rows(buildCasResultSet(key, result, options));
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:26,代码来源:ModificationStatement.java

示例6: addConditions

import org.apache.cassandra.db.composites.Composite; //导入依赖的package包/类
public void addConditions(Composite clusteringPrefix, CQL3CasRequest request, QueryOptions options) throws InvalidRequestException
{
    if (ifNotExists)
    {
        // If we use ifNotExists, if the statement applies to any non static columns, then the condition is on the row of the non-static
        // columns and the prefix should be the clusteringPrefix. But if only static columns are set, then the ifNotExists apply to the existence
        // of any static columns and we should use the prefix for the "static part" of the partition.
        request.addNotExist(clusteringPrefix);
    }
    else if (ifExists)
    {
        request.addExist(clusteringPrefix);
    }
    else
    {
        if (columnConditions != null)
            request.addConditions(clusteringPrefix, columnConditions, options);
        if (staticConditions != null)
            request.addConditions(cfm.comparator.staticPrefix(), staticConditions, options);
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:22,代码来源:ModificationStatement.java

示例7: extractDataValue

import org.apache.cassandra.db.composites.Composite; //导入依赖的package包/类
private ByteBuffer extractDataValue(ColumnDefinition def, ByteBuffer rowKey, ColumnFamily data, Composite prefix)
{
    switch (def.kind)
    {
        case PARTITION_KEY:
            return def.isOnAllComponents()
                 ? rowKey
                 : ((CompositeType)data.metadata().getKeyValidator()).split(rowKey)[def.position()];
        case CLUSTERING_COLUMN:
            return prefix.get(def.position());
        case REGULAR:
            CellName cname = prefix == null
                           ? data.getComparator().cellFromByteBuffer(def.name.bytes)
                           : data.getComparator().create(prefix, def);

            Cell cell = data.getColumn(cname);
            return cell == null ? null : cell.value();
        case COMPACT_VALUE:
            assert data.getColumnCount() == 1;
            return data.getSortedColumns().iterator().next().value();
    }
    throw new AssertionError();
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:24,代码来源:ExtendedFilter.java

示例8: testBuildBoundWithOneInRestrictionsAndOneClusteringColumn

import org.apache.cassandra.db.composites.Composite; //导入依赖的package包/类
/**
 * Test 'clustering_0 IN (1, 2, 3)' with only one clustering column
 */
@Test
public void testBuildBoundWithOneInRestrictionsAndOneClusteringColumn() throws InvalidRequestException
{
    ByteBuffer value1 = ByteBufferUtil.bytes(1);
    ByteBuffer value2 = ByteBufferUtil.bytes(2);
    ByteBuffer value3 = ByteBufferUtil.bytes(3);
    SingleColumnRestriction.IN in = new SingleColumnRestriction.InWithValues(toTerms(value1, value2, value3));
    Restriction[] restrictions = new Restriction[] { in };

    List<Composite> bounds = executeBuildBound(restrictions, Bound.START);
    assertEquals(3, bounds.size());
    assertComposite(bounds.get(0), value1, EOC.START);
    assertComposite(bounds.get(1), value2, EOC.START);
    assertComposite(bounds.get(2), value3, EOC.START);

    bounds = executeBuildBound(restrictions, Bound.END);
    assertEquals(3, bounds.size());
    assertComposite(bounds.get(0), value1, EOC.END);
    assertComposite(bounds.get(1), value2, EOC.END);
    assertComposite(bounds.get(2), value3, EOC.END);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:25,代码来源:SelectStatementTest.java

示例9: testBuildBoundWithMultiEqRestrictions

import org.apache.cassandra.db.composites.Composite; //导入依赖的package包/类
/**
 * Test '(clustering_0, clustering_1) = (1, 2)' with two clustering column
 */
@Test
public void testBuildBoundWithMultiEqRestrictions() throws InvalidRequestException
{
    ByteBuffer value1 = ByteBufferUtil.bytes(1);
    ByteBuffer value2 = ByteBufferUtil.bytes(2);
    MultiColumnRestriction.EQ eq = new MultiColumnRestriction.EQ(toMultiItemTerminal(value1, value2), false);
    Restriction[] restrictions = new Restriction[] { eq, eq };

    List<Composite> bounds = executeBuildBound(restrictions, Bound.START);
    assertEquals(1, bounds.size());
    assertComposite(bounds.get(0), value1, value2, EOC.START);

    bounds = executeBuildBound(restrictions, Bound.END);
    assertEquals(1, bounds.size());
    assertComposite(bounds.get(0), value1, value2, EOC.END);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:20,代码来源:SelectStatementTest.java

示例10: withUpdatedStart

import org.apache.cassandra.db.composites.Composite; //导入依赖的package包/类
public SliceQueryFilter withUpdatedStart(Composite newStart, CellNameType comparator)
{
    Comparator<Composite> cmp = reversed ? comparator.reverseComparator() : comparator;

    List<ColumnSlice> newSlices = new ArrayList<>(slices.length);
    boolean pastNewStart = false;
    for (ColumnSlice slice : slices)
    {
        if (pastNewStart)
        {
            newSlices.add(slice);
            continue;
        }

        if (slice.isBefore(cmp, newStart))
            continue;

        if (slice.includes(cmp, newStart))
            newSlices.add(new ColumnSlice(newStart, slice.finish));
        else
            newSlices.add(slice);

        pastNewStart = true;
    }
    return withUpdatedSlices(newSlices.toArray(new ColumnSlice[newSlices.size()]));
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:27,代码来源:SliceQueryFilter.java

示例11: execute

import org.apache.cassandra.db.composites.Composite; //导入依赖的package包/类
public void execute(ByteBuffer rowKey, ColumnFamily cf, Composite prefix, UpdateParameters params) throws InvalidRequestException
{
    assert column.type.isMultiCell() : "Attempted to set a value for a single key on a frozen map";
    ByteBuffer key = k.bindAndGet(params.options);
    ByteBuffer value = t.bindAndGet(params.options);
    if (key == null)
        throw new InvalidRequestException("Invalid null map key");

    CellName cellName = cf.getComparator().create(prefix, column, key);

    if (value == null)
    {
        cf.addColumn(params.makeTombstone(cellName));
    }
    else
    {
        // We don't support value > 64K because the serialization format encode the length as an unsigned short.
        if (value.remaining() > FBUtilities.MAX_UNSIGNED_SHORT)
            throw new InvalidRequestException(String.format("Map value is too long. Map values are limited to %d bytes but %d bytes value provided",
                                                            FBUtilities.MAX_UNSIGNED_SHORT,
                                                            value.remaining()));

        cf.addColumn(params.makeColumn(cellName, value));
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:26,代码来源:Maps.java

示例12: queryNextPage

import org.apache.cassandra.db.composites.Composite; //导入依赖的package包/类
protected List<Row> queryNextPage(int pageSize, ConsistencyLevel consistencyLevel, boolean localQuery)
throws RequestExecutionException
{
    SliceQueryFilter sf = (SliceQueryFilter)columnFilter;
    AbstractBounds<RowPosition> keyRange = lastReturnedKey == null ? command.keyRange : makeIncludingKeyBounds(lastReturnedKey);
    Composite start = lastReturnedName == null ? sf.start() : lastReturnedName;
    PagedRangeCommand pageCmd = new PagedRangeCommand(command.keyspace,
                                                      command.columnFamily,
                                                      command.timestamp,
                                                      keyRange,
                                                      sf,
                                                      start,
                                                      sf.finish(),
                                                      command.rowFilter,
                                                      pageSize,
                                                      command.countCQL3Rows);

    return localQuery
         ? pageCmd.executeLocally()
         : StorageProxy.getRangeSlice(pageCmd, consistencyLevel);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:22,代码来源:RangeSliceQueryPager.java

示例13: testBuildBoundWithOneEqRestrictionsAndOneClusteringColumn

import org.apache.cassandra.db.composites.Composite; //导入依赖的package包/类
/**
 * Test 'clustering_0 = 1' with only one clustering column
 */
@Test
public void testBuildBoundWithOneEqRestrictionsAndOneClusteringColumn() throws InvalidRequestException
{
    ByteBuffer clustering_0 = ByteBufferUtil.bytes(1);
    SingleColumnRestriction.EQ eq = new SingleColumnRestriction.EQ(toTerm(clustering_0), false);
    Restriction[] restrictions = new Restriction[] { eq };

    List<Composite> bounds = executeBuildBound(restrictions, Bound.START);
    assertEquals(1, bounds.size());
    assertComposite(bounds.get(0), clustering_0, EOC.START);

    bounds = executeBuildBound(restrictions, Bound.END);
    assertEquals(1, bounds.size());
    assertComposite(bounds.get(0), clustering_0, EOC.END);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:19,代码来源:SelectStatementTest.java

示例14: PagedRangeCommand

import org.apache.cassandra.db.composites.Composite; //导入依赖的package包/类
public PagedRangeCommand(String keyspace,
                         String columnFamily,
                         long timestamp,
                         AbstractBounds<RowPosition> keyRange,
                         SliceQueryFilter predicate,
                         Composite start,
                         Composite stop,
                         List<IndexExpression> rowFilter,
                         int limit,
                         boolean countCQL3Rows)
{
    super(keyspace, columnFamily, timestamp, keyRange, predicate, rowFilter);
    this.start = start;
    this.stop = stop;
    this.limit = limit;
    this.countCQL3Rows = countCQL3Rows;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:18,代码来源:PagedRangeCommand.java

示例15: makePrefix

import org.apache.cassandra.db.composites.Composite; //导入依赖的package包/类
private Composite makePrefix(CompositesIndex index, ByteBuffer key, ExtendedFilter filter, boolean isStart)
{
    if (key.remaining() == 0)
        return Composites.EMPTY;

    Composite prefix;
    IDiskAtomFilter columnFilter = filter.columnFilter(key);
    if (columnFilter instanceof SliceQueryFilter)
    {
        SliceQueryFilter sqf = (SliceQueryFilter)columnFilter;
        Composite columnName = isStart ? sqf.start() : sqf.finish();
        prefix = columnName.isEmpty() ? index.getIndexComparator().make(key) : index.makeIndexColumnPrefix(key, columnName);
    }
    else
    {
        prefix = index.getIndexComparator().make(key);
    }
    return isStart ? prefix.start() : prefix.end();
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:20,代码来源:CompositesSearcher.java


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