• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Composite类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: add

import org.apache.cassandra.db.composites.Composite; //导入依赖的package包/类
/**
 * Adds a new range tombstone.
 *
 * This method will be faster if the new tombstone sort after all the currently existing ones (this is a common use case), 
 * but it doesn't assume it.
 */
public void add(Composite start, Composite end, long markedAt, int delTime)
{
    if (isEmpty())
    {
        addInternal(0, start, end, markedAt, delTime);
        return;
    }

    int c = comparator.compare(ends[size-1], start);

    // Fast path if we add in sorted order
    if (c <= 0)
    {
        addInternal(size, start, end, markedAt, delTime);
    }
    else
    {
        // Note: insertFrom expect i to be the insertion point in term of interval ends
        int pos = Arrays.binarySearch(ends, 0, size, start, comparator);
        insertFrom((pos >= 0 ? pos : -pos-1), start, end, markedAt, delTime);
    }
    boundaryHeapSize += start.unsharedHeapSize() + end.unsharedHeapSize();
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:30,代码来源:RangeTombstoneList.java


示例17: searchInternal

import org.apache.cassandra.db.composites.Composite; //导入依赖的package包/类
private int searchInternal(Composite name, int startIdx)
{
    if (isEmpty())
        return -1;

    int pos = Arrays.binarySearch(starts, startIdx, size, name, comparator);
    if (pos >= 0)
    {
        // We're exactly on an interval start. The one subtility is that we need to check if
        // the previous is not equal to us and doesn't have a higher marked at
        if (pos > 0 && comparator.compare(name, ends[pos-1]) == 0 && markedAts[pos-1] > markedAts[pos])
            return pos-1;
        else
            return pos;
    }
    else
    {
        // We potentially intersect the range before our "insertion point"
        int idx = -pos-2;
        if (idx < 0)
            return -1;

        return comparator.compare(name, ends[idx]) <= 0 ? idx : -idx-2;
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:26,代码来源:RangeTombstoneList.java


示例18: toSchema

import org.apache.cassandra.db.composites.Composite; //导入依赖的package包/类
public static Mutation toSchema(Mutation mutation, UserType newType, long timestamp)
{
    ColumnFamily cf = mutation.addOrGet(SystemKeyspace.SCHEMA_USER_TYPES_CF);

    Composite prefix = CFMetaData.SchemaUserTypesCf.comparator.make(newType.name);
    CFRowAdder adder = new CFRowAdder(cf, prefix, timestamp);

    adder.resetCollection("field_names");
    adder.resetCollection("field_types");

    for (int i = 0; i < newType.size(); i++)
    {
        adder.addListEntry("field_names", newType.fieldName(i));
        adder.addListEntry("field_types", newType.fieldType(i).toString());
    }
    return mutation;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:18,代码来源:UTMetaData.java


示例19: validateComposite

import org.apache.cassandra.db.composites.Composite; //导入依赖的package包/类
public static void validateComposite(Composite name, CType type) throws InvalidRequestException
{
    long serializedSize = type.serializer().serializedSize(name, TypeSizes.NATIVE);
    if (serializedSize > Cell.MAX_NAME_LENGTH)
        throw new InvalidRequestException(String.format("The sum of all clustering columns is too long (%s > %s)",
                                                        serializedSize,
                                                        Cell.MAX_NAME_LENGTH));
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:9,代码来源:QueryProcessor.java


示例20: deleteFromSchema

import org.apache.cassandra.db.composites.Composite; //导入依赖的package包/类
/**
 * Drop specified trigger from the schema using given mutation.
 *
 * @param mutation  The schema mutation
 * @param cfName    The name of the parent ColumnFamily
 * @param timestamp The timestamp to use for the tombstone
 */
public void deleteFromSchema(Mutation mutation, String cfName, long timestamp)
{
    ColumnFamily cf = mutation.addOrGet(SystemKeyspace.SCHEMA_TRIGGERS_CF);
    int ldt = (int) (System.currentTimeMillis() / 1000);

    Composite prefix = CFMetaData.SchemaTriggersCf.comparator.make(cfName, name);
    cf.addAtom(new RangeTombstone(prefix, prefix.end(), timestamp, ldt));
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:16,代码来源:TriggerDefinition.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MarkdownProcessor类代码示例发布时间:2022-05-23
下一篇:
Java WordTokenizer类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap