@Override public ByteBuffer getColumn(Cell element) { return org.apache.cassandra.utils.ByteBufferUtil.clone(element.name().toByteBuffer()); }
public ByteBuffer getClusteringColumn(int i) { return cell.get(i); }
public boolean isSameCQL3RowAs(CellNameType type, CellName other) { if (clusteringSize() != other.clusteringSize() || other.isStatic() != isStatic()) return false; for (int i = 0; i < clusteringSize(); i++) { if (type.subtype(i).compare(elements[i], other.get(i)) != 0) return false; } return true; }
/** * Returns a ColumnDefinition given a cell name. */ public ColumnDefinition getColumnDefinition(CellName cellName) { ColumnIdentifier id = cellName.cql3ColumnName(this); ColumnDefinition def = id == null ? getColumnDefinition(cellName.toByteBuffer()) // Means a dense layout, try the full column name : getColumnDefinition(id); // It's possible that the def is a PRIMARY KEY or COMPACT_VALUE one in case a concrete cell // name conflicts with a CQL column name, which can happen in 2 cases: // 1) because the user inserted a cell through Thrift that conflicts with a default "alias" used // by CQL for thrift tables (see #6892). // 2) for COMPACT STORAGE tables with a single utf8 clustering column, the cell name can be anything, // including a CQL column name (without this being a problem). // In any case, this is fine, this just mean that columnDefinition is not the ColumnDefinition we are // looking for. return def != null && def.isPartOfCellName() ? def : null; }
protected void construct(Cell from) { setLong(TIMESTAMP_OFFSET, from.timestamp()); CellName name = from.name(); int nameSize = name.size(); int offset = CELL_NAME_SIZE_OFFSET; setShort(offset, (short) nameSize); assert nameSize - name.clusteringSize() <= 2; byte cellNameExtraBits = (byte) ((nameSize - name.clusteringSize()) | NameType.typeOf(name).bits); setByte(offset += 2, cellNameExtraBits); offset += 1; short cellNameDelta = 0; for (int i = 1; i < nameSize; i++) { cellNameDelta += name.get(i - 1).remaining(); setShort(offset, cellNameDelta); offset += 2; } for (int i = 0; i < nameSize; i++) { ByteBuffer bb = name.get(i); setBytes(offset, bb); offset += bb.remaining(); } setInt(VALUE_OFFSET_OFFSET, offset); setBytes(offset, from.value()); }
void add(Cell cell) { CellName cellName = cell.name(); ColumnIdentifier columnName = cellName.cql3ColumnName(cfMetaData); if (cellName.isCollectionCell()) { if (collections == null) collections = new HashMap<>(); List<Cell> values = collections.get(columnName); if (values == null) { values = new ArrayList<Cell>(); collections.put(columnName, values); } values.add(cell); } else { if (columns == null) columns = new HashMap<>(); columns.put(columnName, cell); } }
@Override public boolean indexes(CellName name) { String toCheck = name.cql3ColumnName(cfMetaData).toString().trim(); for (String columnName : this.options.fields.keySet()) { boolean areEqual = toCheck.equalsIgnoreCase(columnName.trim()); if (logger.isDebugEnabled()) logger.debug(String.format("Comparing name for index - This column name [%s] - Passed column name [%s] - Equal [%s]", columnName, toCheck, areEqual)); if (areEqual) return true; } return false; }
public final Composite start(CellName cellName) { CBuilder builder = clusteringCType.builder(); for (int i = 0; i < cellName.clusteringSize(); i++) { ByteBuffer component = cellName.get(i); builder.add(component); } return builder.build(); }
public List<ByteBuffer> serializedValues(List<Cell> cells) { List<ByteBuffer> bbs = new ArrayList<ByteBuffer>(cells.size()); for (Cell c : cells) bbs.add(c.name().collectionElement()); return bbs; } }
keyColumnsAdded = true; String actualColumnName = column.name().cql3ColumnName(table.metadata).toString(); ByteBuffer colValue = column.value(); AbstractType<?> valueValidator = table.metadata.getValueValidator(column.name()); AbstractType keyType = validator.nameComparator(); AbstractType valueType = validator.valueComparator(); ByteBuffer keyBuf = column.name().collectionElement(); if (valueValidator instanceof MapType) { actualColumnName = actualColumnName + "." + keyType.compose(keyBuf);
public static Composite startOf(ByteBuffer scName) { return CellNames.compositeDense(scName).start(); }
Iterator<Cell> iter = data.iterator(new ColumnSlice[]{ data.getComparator().create(prefix, def).slice() }); while (iter.hasNext()) if (type.kind == CollectionType.Kind.SET) if (type.nameComparator().compare(cell.name().collectionElement(), expr.value) == 0) return true;
private static void validateColumnNames(Iterable<CellName> columns) throws InvalidRequestException { for (CellName name : columns) { if (name.dataSize() > org.apache.cassandra.db.Cell.MAX_NAME_LENGTH) throw new InvalidRequestException(String.format("column name is too long (%s > %s)", name.dataSize(), org.apache.cassandra.db.Cell.MAX_NAME_LENGTH)); if (name.isEmpty()) throw new InvalidRequestException("zero-length column name"); } }
protected void addFields(Cell column, String name, ColumnDefinition columnDefinition, List<Field> fields) { boolean isObject = options.isObject(name); if (isObject) { String value = UTF8Type.instance.compose(column.value()); JsonDocument document = new StreamingJsonDocument(value, options.primary, name); fields.addAll(document.getFields()); } else if (column.name().isCollectionCell()) { List<Field> fieldsForField = collectionFields((CollectionType) columnDefinition.type, name, column); fields.addAll(fieldsForField); } else { FieldType fieldType = options.fieldTypes.get(name); Type type = options.types.get(name); addField(type, columnDefinition, name, fieldType, column.value(), fields); if (options.containsDocValues()) { FieldType docValueType = options.fieldDocValueTypes.get(name); if (docValueType != null) { Field docValueField = Fields.docValueField(name, columnDefinition.type, column.value(), docValueType); fields.add(docValueField); } } } }
@Override public DeletedCell localCopy(CFMetaData metadata, AbstractAllocator allocator) { return new BufferDeletedCell(name.copy(metadata, allocator), allocator.clone(value), timestamp); }
public Reclaimer reclaimImmediately(Cell cell) { onHeap().released(cell.name().dataSize() + cell.value().remaining()); return this; }
public boolean isSameCQL3RowAs(CellNameType type, CellName other) { switch (nametype()) { case SIMPLE_DENSE: case COMPOUND_DENSE: return type.compare(this, other) == 0; case COMPOUND_SPARSE_STATIC: case COMPOUND_SPARSE: int clusteringSize = clusteringSize(); if (clusteringSize != other.clusteringSize() || other.isStatic() != isStatic()) return false; for (int i = 0; i < clusteringSize; i++) if (type.subtype(i).compare(get(i), other.get(i)) != 0) return false; return true; case SIMPLE_SPARSE: return true; default: throw new AssertionError(); } }