public static ByteBuffer subName(Composite columnName) { return columnName.get(1); }
public ByteBuffer get(int i) { return wrapped.get(i); }
public static ByteBuffer scName(Composite columnName) { return columnName.get(0); }
private static List<ByteBuffer> getComponents(Composite prefix, int size) { List<ByteBuffer> l = new ArrayList<>(size); for (int i = 0; i < size; i++) l.add(prefix.get(i)); return l; }
/** * Calculates digest for triggering read repair on mismatch */ public void updateDigest(MessageDigest digest) { ByteBuffer longBuffer = ByteBuffer.allocate(8); for (int i = 0; i < size; i++) { for (int j = 0; j < starts[i].size(); j++) digest.update(starts[i].get(j).duplicate()); for (int j = 0; j < ends[i].size(); j++) digest.update(ends[i].get(j).duplicate()); longBuffer.putLong(0, markedAts[i]); digest.update(longBuffer.array(), 0, 8); } }
public int compare(Composite c1, Composite c2) { if (isByteOrderComparable) return AbstractSimpleCellNameType.compareUnsigned(c1, c2); assert !(c1.isEmpty() | c2.isEmpty()); // This method assumes that simple composites never have an EOC != NONE. This assumption // stands in particular on the fact that a Composites.EMPTY never has a non-NONE EOC. If // this ever change, we'll need to update this. return type.compare(c1.get(0), c2.get(0)); }
public CellName create(Composite prefix, ColumnDefinition column) { assert prefix.size() == 1; // We ignore the column because it's just the COMPACT_VALUE name which is not store in the cell name return new SimpleDenseCellName(prefix.get(0)); }
private void addPartitionKeyFields(ByteBuffer rowKey, long timestamp, IndexEntryBuilder builder) { CType keyCType = tableMapper.cfMetaData.getKeyValidatorAsCType(); Composite compoundRowKey = keyCType.fromByteBuffer(rowKey); for (Map.Entry<String, ColumnDefinition> entry : options.partitionKeysIndexed.entrySet()) { ByteBuffer value = compoundRowKey.get(entry.getValue().position()); addKeyField(timestamp, entry, value, builder); } }
public void validate(Composite name) { ByteBuffer previous = null; for (int i = 0; i < name.size(); i++) { AbstractType<?> comparator = subtype(i); ByteBuffer value = name.get(i); comparator.validateCollectionMember(value, previous); previous = value; } }
public int compareNextTo(Composite composite) throws IOException { maybeReadNext(); if (composite.isEmpty()) return next.hasRemaining() ? 1 : 0; return type.subtype(0).compare(next, composite.get(0)); }
protected Composite makeIndexColumnPrefix(ByteBuffer rowKey, Composite columnName) { int count = Math.min(baseCfs.metadata.clusteringColumns().size(), columnName.size()); CBuilder builder = getIndexComparator().prefixBuilder(); builder.add(rowKey); for (int i = 0; i < Math.min(columnDef.position(), count); i++) builder.add(columnName.get(i)); for (int i = columnDef.position() + 1; i < count; i++) builder.add(columnName.get(i)); return builder.build(); }
private void addKeyColumns(Map<String, Integer> positions, Tuple tuple, ByteBuffer rowKey) { CType keyCType = table.metadata.getKeyValidatorAsCType(); Composite compoundRowKey = keyCType.fromByteBuffer(rowKey); List<ColumnDefinition> partitionKeys = table.metadata.partitionKeyColumns(); for (ColumnDefinition entry : partitionKeys) { ByteBuffer value = compoundRowKey.get(entry.position()); String actualColumnName = entry.name.toString(); for (String field : positions.keySet()) { if (actualColumnName.equalsIgnoreCase(field)) { tuple.getTuple()[positions.get(field)] = entry.type.compose(value); } } } }
protected Composite makeIndexColumnPrefix(ByteBuffer rowKey, Composite cellName) { int count = 1 + baseCfs.metadata.clusteringColumns().size(); CBuilder builder = getIndexComparator().builder(); builder.add(rowKey); for (int i = 0; i < Math.min(cellName.size(), count - 1); i++) builder.add(cellName.get(i)); return builder.build(); }
protected Composite makeIndexColumnPrefix(ByteBuffer rowKey, Composite columnName) { int count = Math.min(baseCfs.metadata.clusteringColumns().size(), columnName.size()); CBuilder builder = getIndexComparator().prefixBuilder(); builder.add(rowKey); for (int i = 0; i < count; i++) builder.add(columnName.get(i)); return builder.build(); }
protected Composite makeIndexColumnPrefix(ByteBuffer rowKey, Composite cellName) { CBuilder builder = getIndexComparator().prefixBuilder(); builder.add(rowKey); for (int i = 0; i < Math.min(columnDef.position(), cellName.size()); i++) builder.add(cellName.get(i)); return builder.build(); }
protected Composite makeIndexColumnPrefix(ByteBuffer rowKey, Composite cellName) { CBuilder builder = getIndexComparator().prefixBuilder(); builder.add(rowKey); for (int i = 0; i < Math.min(columnDef.position(), cellName.size()); i++) builder.add(cellName.get(i)); // When indexing, cellName is a full name including the collection // key. When searching, restricted clustering columns are included // but the collection key is not. In this case, don't try to add an // element to the builder for it, as it will just end up null and // error out when retrieving cells from the index cf (CASSANDRA-7525) if (cellName.size() >= columnDef.position() + 1) builder.add(cellName.get(columnDef.position() + 1)); return builder.build(); }
public final int compareToSimple(final Composite that) { assert size() == 1 && that.size() == 1; int length = valueStartOffset() - nameDeltaOffset(1); long offset = peer + nameDeltaOffset(1); return FastByteOperations.UnsafeOperations.compareTo(null, offset, length, that.get(0)); } }
public boolean isPrefixOf(CType type, Composite c) { if (size() > c.size() || isStatic() != c.isStatic()) return false; for (int i = 0; i < size(); i++) { if (type.subtype(i).compare(get(i), c.get(i)) != 0) return false; } return true; }
public boolean isPrefixOf(CType type, Composite c) { if (size() > c.size() || isStatic() != c.isStatic()) return false; for (int i = 0; i < size(); i++) { if (type.subtype(i).compare(get(i), c.get(i)) != 0) return false; } return true; }