@Override public boolean apply(@Nullable Row row) { return row != null && !row.key.getKey().equals(exceptKey); } });
@Override public StaticBuffer next() { ensureOpen(); if (!hasNext()) throw new NoSuchElementException(); currentRow = keys.next(); ByteBuffer currentKey = currentRow.key.getKey().duplicate(); try { return StaticArrayBuffer.of(currentKey); } finally { lastSeenKey = currentKey; } }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null || !(obj instanceof DecoratedKey)) return false; DecoratedKey other = (DecoratedKey)obj; return ByteBufferUtil.compareUnsigned(getKey(), other.getKey()) == 0; // we compare faster than BB.equals for array backed BB }
/** * If the given @param key occupies only part of a larger buffer, allocate a new buffer that is only * as large as necessary. */ public static DecoratedKey getMinimalKey(DecoratedKey key) { return key.getKey().position() > 0 || key.getKey().hasRemaining() || !key.getKey().hasArray() ? new BufferDecoratedKey(key.getToken(), HeapAllocator.instance.clone(key.getKey())) : key; }
public TombstoneOverwhelmingException(int numTombstones, String query, CFMetaData metadata, DecoratedKey lastPartitionKey, ClusteringPrefix lastClustering) { super(String.format("Scanned over %d tombstones during query '%s' (last scanned row partion key was (%s)); query aborted", numTombstones, query, makePKString(metadata, lastPartitionKey.getKey(), lastClustering))); }
public void filterHash(long[] dest) { ByteBuffer key = getKey(); MurmurHash.hash3_x64_128(key, key.position(), key.remaining(), 0, dest); } }
private static void printMinMaxToken(Descriptor descriptor, IPartitioner partitioner, AbstractType<?> keyType, PrintStream out) throws IOException { File summariesFile = new File(descriptor.filenameFor(Component.SUMMARY)); if (!summariesFile.exists()) return; try (DataInputStream iStream = new DataInputStream(new FileInputStream(summariesFile))) { Pair<DecoratedKey, DecoratedKey> firstLast = new IndexSummary.IndexSummarySerializer().deserializeFirstLastKey(iStream, partitioner, descriptor.version.hasSamplingLevel()); out.printf("First token: %s (key=%s)%n", firstLast.left.getToken(), keyType.getString(firstLast.left.getKey())); out.printf("Last token: %s (key=%s)%n", firstLast.right.getToken(), keyType.getString(firstLast.right.getKey())); } }
public int compareTo(PartitionPosition pos) { if (this == pos) return 0; // delegate to Token.KeyBound if needed if (!(pos instanceof DecoratedKey)) return -pos.compareTo(this); DecoratedKey otherKey = (DecoratedKey) pos; int cmp = getToken().compareTo(otherKey.getToken()); return cmp == 0 ? ByteBufferUtil.compareUnsigned(getKey(), otherKey.getKey()) : cmp; }
public int compareTo(PartitionPosition pos) { if (this == pos) return 0; // delegate to Token.KeyBound if needed if (!(pos instanceof DecoratedKey)) return -pos.compareTo(this); DecoratedKey otherKey = (DecoratedKey) pos; int cmp = getToken().compareTo(otherKey.getToken()); return cmp == 0 ? ByteBufferUtil.compareUnsigned(getKey(), otherKey.getKey()) : cmp; }
public void cacheKey(DecoratedKey key, RowIndexEntry info) { CachingParams caching = metadata.params.caching; if (!caching.cacheKeys() || keyCache == null || keyCache.getCapacity() == 0) return; KeyCacheKey cacheKey = new KeyCacheKey(metadata.ksAndCFName, descriptor, key.getKey()); logger.trace("Adding cache entry for {} -> {}", cacheKey, info); keyCache.put(cacheKey, info); }
protected void appendCQLWhereClause(StringBuilder sb) { sb.append(" WHERE "); sb.append(ColumnDefinition.toCQLString(metadata().partitionKeyColumns())).append(" = "); DataRange.appendKeyString(sb, metadata().getKeyValidator(), partitionKey().getKey()); // We put the row filter first because the clustering index filter can end by "ORDER BY" if (!rowFilter().isEmpty()) sb.append(" AND ").append(rowFilter()); String filterString = clusteringIndexFilter().toCQLString(metadata()); if (!filterString.isEmpty()) sb.append(" AND ").append(filterString); }
protected void appendCQLWhereClause(StringBuilder sb) { sb.append(" WHERE "); sb.append(ColumnDefinition.toCQLString(metadata().partitionKeyColumns())).append(" = "); DataRange.appendKeyString(sb, metadata().getKeyValidator(), partitionKey().getKey()); // We put the row filter first because the clustering index filter can end by "ORDER BY" if (!rowFilter().isEmpty()) sb.append(" AND ").append(rowFilter()); String filterString = clusteringIndexFilter().toCQLString(metadata()); if (!filterString.isEmpty()) sb.append(" AND ").append(filterString); }
public void serialize(Commit commit, DataOutputPlus out, int version) throws IOException { if (version < MessagingService.VERSION_30) ByteBufferUtil.writeWithShortLength(commit.update.partitionKey().getKey(), out); UUIDSerializer.serializer.serialize(commit.ballot, out, version); PartitionUpdate.serializer.serialize(commit.update, out, version); }
private void writePartitionHeader(UnfilteredRowIterator iterator) throws IOException { ByteBufferUtil.writeWithShortLength(iterator.partitionKey().getKey(), writer); DeletionTime.serializer.serialize(iterator.partitionLevelDeletion(), writer); if (header.hasStatic()) { Row staticRow = iterator.staticRow(); UnfilteredSerializer.serializer.serializeStaticRow(staticRow, header, writer, version); if (!observers.isEmpty()) observers.forEach((o) -> o.nextUnfilteredCluster(staticRow)); } }
public void serialize(PartitionPosition pos, DataOutputPlus out, int version) throws IOException { Kind kind = pos.kind(); out.writeByte(kind.ordinal()); if (kind == Kind.ROW_KEY) ByteBufferUtil.writeWithShortLength(((DecoratedKey)pos).getKey(), out); else Token.serializer.serialize(pos.getToken(), out, version); }
public static int compareTo(IPartitioner partitioner, ByteBuffer key, PartitionPosition position) { // delegate to Token.KeyBound if needed if (!(position instanceof DecoratedKey)) return -position.compareTo(partitioner.decorateKey(key)); DecoratedKey otherKey = (DecoratedKey) position; int cmp = partitioner.getToken(key).compareTo(otherKey.getToken()); return cmp == 0 ? ByteBufferUtil.compareUnsigned(key, otherKey.getKey()) : cmp; }
protected void serializeSelection(DataOutputPlus out, int version) throws IOException { metadata().getKeyValidator().writeValue(partitionKey().getKey(), out); ClusteringIndexFilter.serializer.serialize(clusteringIndexFilter(), out, version); }
protected long selectionSerializedSize(int version) { return metadata().getKeyValidator().writtenLength(partitionKey().getKey()) + ClusteringIndexFilter.serializer.serializedSize(clusteringIndexFilter(), version); }
private void updateWithCurrentValue(PartitionUpdate.CounterMark mark, ClockAndCount currentValue, ColumnFamilyStore cfs) { long clock = Math.max(FBUtilities.timestampMicros(), currentValue.clock + 1L); long count = currentValue.count + CounterContext.instance().total(mark.value()); mark.setValue(CounterContext.instance().createGlobal(CounterId.getLocalId(), clock, count)); // Cache the newly updated value cfs.putCachedCounter(key().getKey(), mark.clustering(), mark.column(), mark.path(), ClockAndCount.create(clock, count)); }