@Override public ByteBuffer getColumn(Cell element) { return org.apache.cassandra.utils.ByteBufferUtil.clone(element.name().toByteBuffer()); }
public boolean validate(ByteBuffer rowKey, Cell cell) { return getIndexedValue(rowKey, cell).remaining() < FBUtilities.MAX_UNSIGNED_SHORT && makeIndexColumnName(rowKey, cell).toByteBuffer().remaining() < FBUtilities.MAX_UNSIGNED_SHORT; } }
private CounterCacheKey(Pair<String, String> ksAndCFName, ByteBuffer partitionKey, CellName cellName) { super(ksAndCFName); this.partitionKey = ByteBufferUtil.getArray(partitionKey); this.cellName = ByteBufferUtil.getArray(cellName.toByteBuffer()); }
public boolean indexes(CellName name) { // This consider the full cellName directly AbstractType<?> comparator = baseCfs.metadata.getColumnDefinitionComparator(columnDef); return comparator.compare(columnDef.name.bytes, name.toByteBuffer()) == 0; }
public PagingState state() { return lastReturned == null ? null : new PagingState(null, lastReturned.toByteBuffer(), maxRemaining()); }
public List<ColumnOrSuperColumn> thriftifyColumns(Collection<Cell> cells, boolean reverseOrder, long now) { ArrayList<ColumnOrSuperColumn> thriftColumns = new ArrayList<ColumnOrSuperColumn>(cells.size()); for (Cell cell : cells) { if (!cell.isLive(now)) continue; thriftColumns.add(thriftifyColumnWithName(cell, cell.name().toByteBuffer())); } // we have to do the reversing here, since internally we pass results around in ColumnFamily // objects, which always sort their cells in the "natural" order // TODO this is inconvenient for direct users of StorageProxy if (reverseOrder) Collections.reverse(thriftColumns); return thriftColumns; }
@Override public ByteBuffer getColumn(Cell element) { return org.apache.cassandra.utils.ByteBufferUtil.clone(element.name().toByteBuffer()); }
private List<Cell> unthriftifySuper(SuperColumn super_column) { List<Cell> cells = new ArrayList<Cell>(super_column.columns.size()); for (org.apache.cassandra.thrift.Column column : super_column.columns) { Cell c = unthriftifySimple(column); cells.add(c.withUpdatedName(CellNames.simpleDense(CompositeType.build(super_column.name, c.name().toByteBuffer())))); } return cells; }
private List<Cell> unthriftifySuperCounter(CounterSuperColumn super_column) { List<Cell> cells = new ArrayList<Cell>(super_column.columns.size()); for (CounterColumn column : super_column.columns) { Cell c = unthriftifyCounter(column); cells.add(c.withUpdatedName(CellNames.simpleDense(CompositeType.build(super_column.name, c.name().toByteBuffer())))); } return cells; } }
public void updateDigest(MessageDigest digest) { digest.update(name().toByteBuffer().duplicate()); digest.update(value().duplicate()); FBUtilities.updateWithLong(digest, timestamp()); FBUtilities.updateWithByte(digest, serializationFlags()); }
@Override public void updateDigest(MessageDigest digest) { digest.update(name().toByteBuffer().duplicate()); FBUtilities.updateWithLong(digest, timestamp()); FBUtilities.updateWithByte(digest, serializationFlags()); } }
public PagingState state() { return lastReturnedKey == null ? null : new PagingState(lastReturnedKey.getKey(), lastReturnedName.toByteBuffer(), maxRemaining()); }
/** convert a cql column to an object */ private Object cqlColumnToObj(Cell col, CfDef cfDef) throws IOException { // standard Map<ByteBuffer,AbstractType> validators = getValidatorMap(cfDef); ByteBuffer cellName = col.name().toByteBuffer(); if (validators.get(cellName) == null) return cassandraToObj(getDefaultMarshallers(cfDef).get(MarshallerType.DEFAULT_VALIDATOR), col.value()); else return cassandraToObj(validators.get(cellName), col.value()); }
@Override public void updateDigest(MessageDigest digest) { digest.update(name().toByteBuffer().duplicate()); // We don't take the deltas into account in a digest contextManager.updateDigest(digest, value()); FBUtilities.updateWithLong(digest, timestamp); FBUtilities.updateWithByte(digest, serializationFlags()); FBUtilities.updateWithLong(digest, timestampOfLastDelete); }
public ByteBuffer primaryKey(ByteBuffer rowKey, CellName clusteringKey) { return primaryKeyType.builder().add(rowKey).add(clusteringKey.toByteBuffer()).build(); }
protected void addColumn(Cell cell) throws IOException { if (columnFamily.metadata().isSuper()) { if (currentSuperColumn == null) throw new IllegalStateException("Trying to add a cell to a super column family, but no super cell has been started."); cell = cell.withUpdatedName(columnFamily.getComparator().makeCellName(currentSuperColumn, cell.name().toByteBuffer())); } columnFamily.addColumn(cell); }
private CounterColumn thriftifySubCounter(Cell cell) { assert cell instanceof CounterCell; return new CounterColumn(cell.name().toByteBuffer(), CounterContext.instance().total(cell.value())); }
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())); } }
private Column thriftifySubColumn(Cell cell) { assert !(cell instanceof CounterCell); Column thrift_column = new Column(cell.name().toByteBuffer()).setValue(cell.value()).setTimestamp(cell.timestamp()); if (cell instanceof ExpiringCell) { thrift_column.setTtl(((ExpiringCell) cell).getTimeToLive()); } return thrift_column; }
private static Column thriftify(org.apache.cassandra.db.Cell c) { ByteBuffer value = (c instanceof CounterCell) ? ByteBufferUtil.bytes(CounterContext.instance().total(c.value())) : c.value(); return new Column(c.name().toByteBuffer()).setValue(value).setTimestamp(c.timestamp()); }