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


Java ColumnFamily类代码示例

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


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

示例1: execute

import org.apache.cassandra.db.ColumnFamily; //导入依赖的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

示例2: execute

import org.apache.cassandra.db.ColumnFamily; //导入依赖的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

示例3: deserialize

import org.apache.cassandra.db.ColumnFamily; //导入依赖的package包/类
public PrepareResponse deserialize(DataInput in, int version) throws IOException
{
    boolean success = in.readBoolean();
    ByteBuffer key = ByteBufferUtil.readWithShortLength(in);
    return new PrepareResponse(success,
                               new Commit(key,
                                          UUIDSerializer.serializer.deserialize(in, version),
                                          ColumnFamily.serializer.deserialize(in,
                                                                              ArrayBackedSortedColumns.factory,
                                                                              ColumnSerializer.Flag.LOCAL, version)),
                               new Commit(key,
                                          UUIDSerializer.serializer.deserialize(in, version),
                                          ColumnFamily.serializer.deserialize(in,
                                                                              ArrayBackedSortedColumns.factory,
                                                                              ColumnSerializer.Flag.LOCAL, version)));
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:17,代码来源:PrepareResponse.java

示例4: getColumnFamily

import org.apache.cassandra.db.ColumnFamily; //导入依赖的package包/类
protected ColumnFamily getColumnFamily()
{
    ColumnFamily previous = buffer.get(currentKey);
    // If the CF already exist in memory, we'll just continue adding to it
    if (previous == null)
    {
        previous = TreeMapBackedSortedColumns.factory.create(metadata);
        buffer.put(currentKey, previous);
    }
    else
    {
        // We will reuse a CF that we have counted already. But because it will be easier to add the full size
        // of the CF in the next writeRow call than to find out the delta, we just remove the size until that next call
        currentSize -= currentKey.key.remaining() + ColumnFamily.serializer.serializedSize(previous, MessagingService.current_version) * 1.2;
    }
    return previous;
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:18,代码来源:SSTableSimpleUnsortedWriter.java

示例5: build

import org.apache.cassandra.db.ColumnFamily; //导入依赖的package包/类
public LogEntry build(ColumnFamily update, ByteBuffer key) {
    LogEntry logEntry = new LogEntry();

    logEntry.setTimeUuid(generateTimeUuid());
    logEntry.setLoggedKeyspace(ColumnFamilyUtil.getKeyspaceName(update));
    logEntry.setLoggedTable(ColumnFamilyUtil.getTableName(update));
    logEntry.setLoggedKey(ColumnFamilyUtil.getKeyText(update, key));

    if (ColumnFamilyUtil.isDeleted(update)) {
        logEntry.setOperation(Operation.delete);
    } else {
        logEntry.setOperation(Operation.save);
    }

    Set<String> cellNames = ColumnFamilyUtil.getCellNames(update);
    if (this.ignoreColumns != null) {
        cellNames.removeAll(this.ignoreColumns);
    }
    
    logEntry.setUpdatedColumns(cellNames);
    return logEntry;
}
 
开发者ID:felipead,项目名称:cassandra-logger,代码行数:23,代码来源:LogEntryBuilder.java

示例6: extractDataValue

import org.apache.cassandra.db.ColumnFamily; //导入依赖的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

示例7: trace

import org.apache.cassandra.db.ColumnFamily; //导入依赖的package包/类
public static void trace(final ByteBuffer sessionIdBytes, final String message, final int elapsed)
{
    final String threadName = Thread.currentThread().getName();

    StageManager.getStage(Stage.TRACING).execute(new WrappedRunnable()
    {
        public void runMayThrow()
        {
            Mutation mutation = new Mutation(Tracing.TRACE_KS, sessionIdBytes);
            ColumnFamily cells = mutation.addOrGet(CFMetaData.TraceEventsCf);

            CFRowAdder adder = new CFRowAdder(cells, cells.metadata().comparator.make(UUIDGen.getTimeUUID()), FBUtilities.timestampMicros());
            adder.add("activity", message);
            adder.add("source", FBUtilities.getBroadcastAddress());
            if (elapsed >= 0)
                adder.add("source_elapsed", elapsed);
            adder.add("thread", threadName);

            Tracing.mutateWithCatch(mutation);
        }
    });
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:23,代码来源:TraceState.java

示例8: getColumnFamily

import org.apache.cassandra.db.ColumnFamily; //导入依赖的package包/类
protected ColumnFamily getColumnFamily() throws IOException
{
    ColumnFamily previous = buffer.get(currentKey);
    // If the CF already exist in memory, we'll just continue adding to it
    if (previous == null)
    {
        previous = createColumnFamily();
        buffer.put(currentKey, previous);

        // Since this new CF will be written by the next sync(), count its header. And a CF header
        // on disk is:
        //   - the row key: 2 bytes size + key size bytes
        //   - the row level deletion infos: 4 + 8 bytes
        currentSize += 14 + currentKey.getKey().remaining();
    }
    return previous;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:18,代码来源:SSTableSimpleUnsortedWriter.java

示例9: getReduced

import org.apache.cassandra.db.ColumnFamily; //导入依赖的package包/类
protected Row getReduced()
{
    ColumnFamily resolved = versions.size() > 1
                          ? RowDataResolver.resolveSuperset(versions, timestamp)
                          : versions.get(0);
    if (versions.size() < sources.size())
    {
        // add placeholder rows for sources that didn't have any data, so maybeScheduleRepairs sees them
        for (InetAddress source : sources)
        {
            if (!versionSources.contains(source))
            {
                versions.add(null);
                versionSources.add(source);
            }
        }
    }
    // resolved can be null even if versions doesn't have all nulls because of the call to removeDeleted in resolveSuperSet
    if (resolved != null)
        repairResults.addAll(RowDataResolver.scheduleRepairs(resolved, keyspaceName, key, versions, versionSources));
    versions.clear();
    versionSources.clear();
    return new Row(key, resolved);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:25,代码来源:RangeSliceResponseResolver.java

示例10: doAppend

import org.apache.cassandra.db.ColumnFamily; //导入依赖的package包/类
static void doAppend(Term t, ColumnFamily cf, ColumnNameBuilder columnName, UpdateParameters params) throws InvalidRequestException
{
    Term.Terminal value = t.bind(params.variables);
    // If we append null, do nothing. Note that for Setter, we've
    // already removed the previous value so we're good here too
    if (value == null)
        return;

    assert value instanceof Lists.Value;
    List<ByteBuffer> toAdd = ((Lists.Value)value).elements;
    for (int i = 0; i < toAdd.size(); i++)
    {
        ColumnNameBuilder b = i == toAdd.size() - 1 ? columnName : columnName.copy();
        ByteBuffer uuid = ByteBuffer.wrap(UUIDGen.getTimeUUIDBytes());
        ByteBuffer cellName = b.add(uuid).build();
        cf.addColumn(params.makeColumn(cellName, toAdd.get(i)));
    }
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:19,代码来源:Lists.java

示例11: execute

import org.apache.cassandra.db.ColumnFamily; //导入依赖的package包/类
public void execute(ByteBuffer rowKey, ColumnFamily cf, ColumnNameBuilder prefix, UpdateParameters params) throws InvalidRequestException
{
    Term.Terminal value = t.bind(params.variables);
    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;
    ColumnNameBuilder column = prefix.add(columnName.key);
    for (int i = 0; i < toAdd.size(); i++)
    {
        ColumnNameBuilder b = i == toAdd.size() - 1 ? column : column.copy();
        PrecisionTime pt = PrecisionTime.getNext(time);
        ByteBuffer uuid = ByteBuffer.wrap(UUIDGen.getTimeUUIDBytes(pt.millis, pt.nanos));
        ByteBuffer cellName = b.add(uuid).build();
        cf.addColumn(params.makeColumn(cellName, toAdd.get(i)));
    }
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:21,代码来源:Lists.java

示例12: deserialize

import org.apache.cassandra.db.ColumnFamily; //导入依赖的package包/类
public IRowCacheEntry deserialize(DataInput in) throws IOException
{
    boolean isSentinel = in.readBoolean();
    if (isSentinel)
        return new RowCacheSentinel(in.readLong());
    return ColumnFamily.serializer.deserialize(in, MessagingService.current_version);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:8,代码来源:SerializingCacheProvider.java

示例13: validate

import org.apache.cassandra.db.ColumnFamily; //导入依赖的package包/类
private void validate(Collection<RowMutation> tmutations) throws InvalidRequestException
{
    for (RowMutation mutation : tmutations)
    {
        QueryProcessor.validateKey(mutation.key());
        for (ColumnFamily tcf : mutation.getColumnFamilies())
            for (ByteBuffer tName : tcf.getColumnNames())
                QueryProcessor.validateColumn(tcf.metadata(), tName, tcf.getColumn(tName).value());
    }
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:11,代码来源:TriggerExecutor.java

示例14: doAppend

import org.apache.cassandra.db.ColumnFamily; //导入依赖的package包/类
static void doAppend(Term t, ColumnFamily cf, Composite prefix, ColumnDefinition column, UpdateParameters params) throws InvalidRequestException
{
    Term.Terminal value = t.bind(params.options);
    Lists.Value listValue = (Lists.Value)value;
    if (column.type.isMultiCell())
    {
        // If we append null, do nothing. Note that for Setter, we've
        // already removed the previous value so we're good here too
        if (value == null)
            return;

        List<ByteBuffer> toAdd = listValue.elements;
        for (int i = 0; i < toAdd.size(); i++)
        {
            ByteBuffer uuid = ByteBuffer.wrap(UUIDGen.getTimeUUIDBytes());
            cf.addColumn(params.makeColumn(cf.getComparator().create(prefix, column, uuid), toAdd.get(i)));
        }
    }
    else
    {
        // for frozen lists, we're overwriting the whole cell value
        CellName name = cf.getComparator().create(prefix, column);
        if (value == null)
            cf.addAtom(params.makeTombstone(name));
        else
            cf.addColumn(params.makeColumn(name, listValue.getWithProtocolVersion(Server.CURRENT_VERSION)));
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:29,代码来源:Lists.java

示例15: execute

import org.apache.cassandra.db.ColumnFamily; //导入依赖的package包/类
public void execute(ByteBuffer rowKey, ColumnFamily cf, Composite prefix, UpdateParameters params) throws InvalidRequestException
{
    if (column.type.isMultiCell())
    {
        // delete + put
        CellName name = cf.getComparator().create(prefix, column);
        cf.addAtom(params.makeTombstoneForOverwrite(name.slice()));
    }
    Putter.doPut(t, cf, prefix, column, params);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:11,代码来源:Maps.java


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