本文整理汇总了Java中org.apache.cassandra.db.composites.CellName类的典型用法代码示例。如果您正苦于以下问题:Java CellName类的具体用法?Java CellName怎么用?Java CellName使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CellName类属于org.apache.cassandra.db.composites包,在下文中一共展示了CellName类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateColumn
import org.apache.cassandra.db.composites.CellName; //导入依赖的package包/类
public static void validateColumn(CFMetaData metadata, CellName name, ByteBuffer value)
throws InvalidRequestException
{
validateColumnName(name);
AbstractType<?> validator = metadata.getValueValidator(name);
try
{
if (validator != null)
validator.validate(value);
}
catch (MarshalException me)
{
throw new InvalidRequestException(String.format("Invalid column value for column (name=%s); %s",
ByteBufferUtil.bytesToHex(name.toByteBuffer()),
me.getMessage()));
}
}
示例2: mutationForKey
import org.apache.cassandra.db.composites.CellName; //导入依赖的package包/类
public Mutation mutationForKey(ByteBuffer key, String keyspace, Long timestamp, ThriftClientState clientState, List<ByteBuffer> variables, CFMetaData metadata)
throws InvalidRequestException
{
Mutation mutation = new Mutation(keyspace, key);
QueryProcessor.validateKeyAlias(metadata, keyName);
if (columns.size() < 1)
{
// No columns, delete the partition
mutation.delete(columnFamily, (timestamp == null) ? getTimestamp(clientState) : timestamp);
}
else
{
// Delete specific columns
AbstractType<?> at = metadata.comparator.asAbstractType();
for (Term column : columns)
{
CellName columnName = metadata.comparator.cellFromByteBuffer(column.getByteBuffer(at, variables));
validateColumnName(columnName);
mutation.delete(columnFamily, columnName, (timestamp == null) ? getTimestamp(clientState) : timestamp);
}
}
return mutation;
}
示例3: deserialize
import org.apache.cassandra.db.composites.CellName; //导入依赖的package包/类
public Future<Pair<CounterCacheKey, ClockAndCount>> deserialize(DataInputStream in, final ColumnFamilyStore cfs) throws IOException
{
final ByteBuffer partitionKey = ByteBufferUtil.readWithLength(in);
final CellName cellName = cfs.metadata.comparator.cellFromByteBuffer(ByteBufferUtil.readWithLength(in));
return StageManager.getStage(Stage.READ).submit(new Callable<Pair<CounterCacheKey, ClockAndCount>>()
{
public Pair<CounterCacheKey, ClockAndCount> call() throws Exception
{
DecoratedKey key = cfs.partitioner.decorateKey(partitionKey);
QueryFilter filter = QueryFilter.getNamesFilter(key,
cfs.metadata.cfName,
FBUtilities.singleton(cellName, cfs.metadata.comparator),
Long.MIN_VALUE);
ColumnFamily cf = cfs.getTopLevelColumns(filter, Integer.MIN_VALUE);
if (cf == null)
return null;
Cell cell = cf.getColumn(cellName);
if (cell == null || !cell.isLive(Long.MIN_VALUE))
return null;
ClockAndCount clockAndCount = CounterContext.instance().getLocalClockAndCount(cell.value());
return Pair.create(CounterCacheKey.create(cfs.metadata.cfId, partitionKey, cellName), clockAndCount);
}
});
}
示例4: insert
import org.apache.cassandra.db.composites.CellName; //导入依赖的package包/类
public void insert(ByteBuffer rowKey, Cell cell, OpOrder.Group opGroup)
{
DecoratedKey valueKey = getIndexKeyFor(getIndexedValue(rowKey, cell));
ColumnFamily cfi = ArrayBackedSortedColumns.factory.create(indexCfs.metadata, false, 1);
CellName name = makeIndexColumnName(rowKey, cell);
if (cell instanceof ExpiringCell)
{
ExpiringCell ec = (ExpiringCell) cell;
cfi.addColumn(new BufferExpiringCell(name, ByteBufferUtil.EMPTY_BYTE_BUFFER, ec.timestamp(), ec.getTimeToLive(), ec.getLocalDeletionTime()));
}
else
{
cfi.addColumn(new BufferCell(name, ByteBufferUtil.EMPTY_BYTE_BUFFER, cell.timestamp()));
}
if (logger.isDebugEnabled())
logger.debug("applying index row {} in {}", indexCfs.metadata.getKeyValidator().getString(valueKey.getKey()), cfi);
indexCfs.apply(valueKey, cfi, SecondaryIndexManager.nullUpdater, opGroup, null);
}
示例5: SSTableNamesIterator
import org.apache.cassandra.db.composites.CellName; //导入依赖的package包/类
public SSTableNamesIterator(SSTableReader sstable, DecoratedKey key, SortedSet<CellName> columns)
{
assert columns != null;
this.sstable = sstable;
this.columns = columns;
this.key = key;
RowIndexEntry indexEntry = sstable.getPosition(key, SSTableReader.Operator.EQ);
if (indexEntry == null)
return;
try
{
read(sstable, null, indexEntry);
}
catch (IOException e)
{
sstable.markSuspect();
throw new CorruptSSTableException(e, sstable.getFilename());
}
finally
{
if (fileToClose != null)
FileUtils.closeQuietly(fileToClose);
}
}
示例6: readSimpleColumns
import org.apache.cassandra.db.composites.CellName; //导入依赖的package包/类
private void readSimpleColumns(FileDataInput file, SortedSet<CellName> columnNames, List<OnDiskAtom> result)
{
Iterator<OnDiskAtom> atomIterator = cf.metadata().getOnDiskIterator(file, sstable.descriptor.version);
int n = 0;
while (atomIterator.hasNext())
{
OnDiskAtom column = atomIterator.next();
if (column instanceof Cell)
{
if (columnNames.contains(column.name()))
{
result.add(column);
if (++n >= columns.size())
break;
}
}
else
{
result.add(column);
}
}
}
示例7: retryDummyRead
import org.apache.cassandra.db.composites.CellName; //导入依赖的package包/类
private void retryDummyRead(String ks, String cf) throws PermanentBackendException {
final long limit = System.currentTimeMillis() + (60L * 1000L);
while (System.currentTimeMillis() < limit) {
try {
SortedSet<CellName> names = new TreeSet<>(new Comparator<CellName>() {
// This is a singleton set. We need to define a comparator because SimpleDenseCellName is not
// comparable, but it doesn't have to be a useful comparator
@Override
public int compare(CellName o1, CellName o2)
{
return 0;
}
});
names.add(CellNames.simpleDense(ByteBufferUtil.zeroByteBuffer(1)));
NamesQueryFilter nqf = new NamesQueryFilter(names);
SliceByNamesReadCommand cmd = new SliceByNamesReadCommand(ks, ByteBufferUtil.zeroByteBuffer(1), cf, 1L, nqf);
StorageProxy.read(ImmutableList.<ReadCommand> of(cmd), ConsistencyLevel.QUORUM);
log.info("Read on CF {} in KS {} succeeded", cf, ks);
return;
} catch (Throwable t) {
log.warn("Failed to read CF {} in KS {} following creation", cf, ks, t);
}
try {
Thread.sleep(1000L);
} catch (InterruptedException e) {
throw new PermanentBackendException(e);
}
}
throw new PermanentBackendException("Timed out while attempting to read CF " + cf + " in KS " + ks + " following creation");
}
示例8: execute
import org.apache.cassandra.db.composites.CellName; //导入依赖的package包/类
public void execute(ByteBuffer rowKey, ColumnFamily cf, Composite prefix, UpdateParameters params) throws InvalidRequestException
{
if (column.type.isMultiCell())
{
// delete + add
CellName name = cf.getComparator().create(prefix, column);
cf.addAtom(params.makeTombstoneForOverwrite(name.slice()));
}
Adder.doAdd(t, cf, prefix, column, params);
}
示例9: collectionColumns
import org.apache.cassandra.db.composites.CellName; //导入依赖的package包/类
protected Iterator<Cell> collectionColumns(CellName collection, ColumnFamily cf, final long now)
{
// We are testing for collection equality, so we need to have the expected values *and* only those.
ColumnSlice[] collectionSlice = new ColumnSlice[]{ collection.slice() };
// Filter live columns, this makes things simpler afterwards
return Iterators.filter(cf.iterator(collectionSlice), new Predicate<Cell>()
{
public boolean apply(Cell c)
{
// we only care about live columns
return c.isLive(now);
}
});
}
示例10: appliesTo
import org.apache.cassandra.db.composites.CellName; //导入依赖的package包/类
public boolean appliesTo(Composite rowPrefix, ColumnFamily current, long now) throws InvalidRequestException
{
CellName name = current.metadata().comparator.create(rowPrefix, column);
for (ByteBuffer value : inValues)
{
if (isSatisfiedByValue(value, current.getColumn(name), column.type, Operator.EQ, now))
return true;
}
return false;
}
示例11: execute
import org.apache.cassandra.db.composites.CellName; //导入依赖的package包/类
public void execute(ByteBuffer rowKey, ColumnFamily cf, Composite prefix, UpdateParameters params) throws InvalidRequestException
{
if (column.type.isMultiCell())
{
// delete + append
CellName name = cf.getComparator().create(prefix, column);
cf.addAtom(params.makeTombstoneForOverwrite(name.slice()));
}
Appender.doAppend(t, cf, prefix, column, params);
}
示例12: doAppend
import org.apache.cassandra.db.composites.CellName; //导入依赖的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)));
}
}
示例13: execute
import org.apache.cassandra.db.composites.CellName; //导入依赖的package包/类
public void execute(ByteBuffer rowKey, ColumnFamily cf, Composite prefix, UpdateParameters params) throws InvalidRequestException
{
ByteBuffer bytes = t.bindAndGet(params.options);
if (bytes == null)
throw new InvalidRequestException("Invalid null value for counter increment");
long increment = ByteBufferUtil.toLong(bytes);
CellName cname = cf.getComparator().create(prefix, column);
cf.addColumn(params.makeCounter(cname, increment));
}
示例14: serialize
import org.apache.cassandra.db.composites.CellName; //导入依赖的package包/类
public void serialize(NamesQueryFilter f, DataOutputPlus out, int version) throws IOException
{
out.writeInt(f.columns.size());
ISerializer<CellName> serializer = type.cellSerializer();
for (CellName cName : f.columns)
{
serializer.serialize(cName, out);
}
out.writeBoolean(f.countCQL3Rows);
}
示例15: execute
import org.apache.cassandra.db.composites.CellName; //导入依赖的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);
}