public Composite deserialize(DataInput in) throws IOException { return type.fromByteBuffer(ByteBufferUtil.readWithShortLength(in)); }
private String rangesAsString() { assert !ranges.isEmpty(); StringBuilder sb = new StringBuilder(); CType type = (CType)ranges.comparator(); assert type != null; Iterator<RangeTombstone> iter = rangeIterator(); while (iter.hasNext()) { RangeTombstone i = iter.next(); sb.append("["); sb.append(type.getString(i.min)).append("-"); sb.append(type.getString(i.max)).append(", "); sb.append(i.data); sb.append("]"); } return sb.toString(); }
public static Comparator<IndexInfo> getComparator(final CType nameComparator, boolean reversed) { return reversed ? nameComparator.indexReverseComparator() : nameComparator.indexComparator(); }
public boolean isCompatibleWith(CType previous) { if (this == previous) return true; // Extending with new components is fine, shrinking is not if (size() < previous.size()) return false; for (int i = 0; i < previous.size(); i++) { AbstractType<?> tprev = previous.subtype(i); AbstractType<?> tnew = subtype(i); if (!tnew.isCompatibleWith(tprev)) return false; } return true; }
public IndexInfo deserialize(DataInput in) throws IOException { return new IndexInfo(type.serializer().deserialize(in), type.serializer().deserialize(in), in.readLong(), in.readLong()); }
public RowIndexEntry deserialize(DataInput in, Descriptor.Version version) throws IOException { long position = in.readLong(); int size = in.readInt(); if (size > 0) { DeletionTime deletionTime = DeletionTime.serializer.deserialize(in); int entries = in.readInt(); ISerializer<IndexHelper.IndexInfo> idxSerializer = type.indexSerializer(); List<IndexHelper.IndexInfo> columnsIndex = new ArrayList<IndexHelper.IndexInfo>(entries); for (int i = 0; i < entries; i++) columnsIndex.add(idxSerializer.deserialize(in)); return new IndexedEntry(position, deletionTime, columnsIndex); } else { return new RowIndexEntry(position); } }
QueryOptions options) throws InvalidRequestException CBuilder builder = type.builder(); TreeSet<Composite> inValues = new TreeSet<>(isReversed ? type.reverseComparator() : type);
public ByteBuffer execute(List<ByteBuffer> parameters) throws InvalidRequestException { CBuilder builder = cfm.getKeyValidatorAsCType().builder(); for (int i = 0; i < parameters.size(); i++) { ByteBuffer bb = parameters.get(i); if (bb == null) return null; builder.add(bb); } return partitioner.getTokenFactory().toByteArray(partitioner.getToken(builder.build().toByteBuffer())); } }
public SliceQueryFilter deserialize(DataInput in, int version) throws IOException { ColumnSlice[] slices; slices = new ColumnSlice[in.readInt()]; for (int i = 0; i < slices.length; i++) slices[i] = type.sliceSerializer().deserialize(in, version); boolean reversed = in.readBoolean(); int count = in.readInt(); int compositesToGroup = in.readInt(); return new SliceQueryFilter(slices, reversed, count, compositesToGroup); }
public CompoundCBuilder(CType type) { this.type = type; this.values = new ByteBuffer[type.size()]; }
public long serializedSizeForSSTable(RangeTombstone t) { TypeSizes typeSizes = TypeSizes.NATIVE; return type.serializer().serializedSize(t.min, typeSizes) + 1 // serialization flag + type.serializer().serializedSize(t.max, typeSizes) + DeletionTime.serializer.serializedSize(t.data, typeSizes); } }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null) return false; if (!getClass().equals(o.getClass())) return false; CType c = (CType)o; if (size() != c.size()) return false; for (int i = 0; i < size(); i++) { if (!subtype(i).equals(c.subtype(i))) return false; } return true; }
@Override public int promotedSize(CType type) { TypeSizes typeSizes = TypeSizes.NATIVE; long size = DeletionTime.serializer.serializedSize(deletionTime, typeSizes); size += typeSizes.sizeof(columnsIndex.size()); // number of entries ISerializer<IndexHelper.IndexInfo> idxSerializer = type.indexSerializer(); for (IndexHelper.IndexInfo info : columnsIndex) size += idxSerializer.serializedSize(info, typeSizes); return Ints.checkedCast(size); }
public List<ByteBuffer> buildPartitionKeyNames(QueryOptions options) throws InvalidRequestException CBuilder keyBuilder = cfm.getKeyValidatorAsCType().builder(); List<ByteBuffer> keys = new ArrayList<ByteBuffer>(); for (ColumnDefinition def : cfm.partitionKeyColumns())
public void serialize(SliceQueryFilter f, DataOutputPlus out, int version) throws IOException { out.writeInt(f.slices.length); for (ColumnSlice slice : f.slices) type.sliceSerializer().serialize(slice, out, version); out.writeBoolean(f.reversed); int count = f.count; out.writeInt(count); out.writeInt(f.compositesToGroup); }
public RangeTombstone deserializeFromSSTable(DataInput in, Descriptor.Version version) throws IOException { Composite min = type.serializer().deserialize(in); int b = in.readUnsignedByte(); assert (b & ColumnSerializer.RANGE_TOMBSTONE_MASK) != 0; return deserializeBody(in, min, version); }
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); } }
/** * Deserialize the index into a structure and return it * * @param in input source * @param type the comparator type for the column family * * @return ArrayList<IndexInfo> - list of de-serialized indexes * @throws IOException if an I/O error occurs. */ public static List<IndexInfo> deserializeIndex(FileDataInput in, CType type) throws IOException { int columnIndexSize = in.readInt(); if (columnIndexSize == 0) return Collections.<IndexInfo>emptyList(); ArrayList<IndexInfo> indexList = new ArrayList<IndexInfo>(); FileMark mark = in.mark(); ISerializer<IndexInfo> serializer = type.indexSerializer(); while (in.bytesPastMark(mark) < columnIndexSize) { indexList.add(serializer.deserialize(in)); } assert in.bytesPastMark(mark) == columnIndexSize; return indexList; }
private NavigableSet<ByteBuffer> getKeys(final QueryOptions options) throws InvalidRequestException CBuilder builder = cfm.getKeyValidatorAsCType().builder(); for (ColumnDefinition def : cfm.partitionKeyColumns())
public long serializedSize(SliceQueryFilter f, int version) { TypeSizes sizes = TypeSizes.NATIVE; int size = 0; size += sizes.sizeof(f.slices.length); for (ColumnSlice slice : f.slices) size += type.sliceSerializer().serializedSize(slice, version); size += sizes.sizeof(f.reversed); size += sizes.sizeof(f.count); size += sizes.sizeof(f.compositesToGroup); return size; } }