public boolean hasNext() { return compacted.hasNext(); }
public boolean hasNext() { return compacted.hasNext(); }
public boolean hasNext() { return compacted.hasNext(); }
/** * Digests the the provided iterator. * * @param command the command that has yield {@code iterator}. This can be null if {@code version >= MessagingService.VERSION_30} * as this is only used when producing digest to be sent to legacy nodes. * @param iterator the iterator to digest. * @param digest the {@code MessageDigest} to use for the digest. * @param version the messaging protocol to use when producing the digest. */ public static void digest(ReadCommand command, UnfilteredPartitionIterator iterator, MessageDigest digest, int version) { try (UnfilteredPartitionIterator iter = iterator) { while (iter.hasNext()) { try (UnfilteredRowIterator partition = iter.next()) { UnfilteredRowIterators.digest(command, partition, digest, version); } } } }
/** * Digests the the provided iterator. * * @param command the command that has yield {@code iterator}. This can be null if {@code version >= MessagingService.VERSION_30} * as this is only used when producing digest to be sent to legacy nodes. * @param iterator the iterator to digest. * @param digest the {@code MessageDigest} to use for the digest. * @param version the messaging protocol to use when producing the digest. */ public static void digest(ReadCommand command, UnfilteredPartitionIterator iterator, MessageDigest digest, int version) { try (UnfilteredPartitionIterator iter = iterator) { while (iter.hasNext()) { try (UnfilteredRowIterator partition = iter.next()) { UnfilteredRowIterators.digest(command, partition, digest, version); } } } }
/** * Digests the the provided iterator. * * @param command the command that has yield {@code iterator}. This can be null if {@code version >= MessagingService.VERSION_30} * as this is only used when producing digest to be sent to legacy nodes. * @param iterator the iterator to digest. * @param digest the {@code MessageDigest} to use for the digest. * @param version the messaging protocol to use when producing the digest. */ public static void digest(ReadCommand command, UnfilteredPartitionIterator iterator, MessageDigest digest, int version) { try (UnfilteredPartitionIterator iter = iterator) { while (iter.hasNext()) { try (UnfilteredRowIterator partition = iter.next()) { UnfilteredRowIterators.digest(command, partition, digest, version); } } } }
public void serialize(UnfilteredPartitionIterator iter, ColumnFilter selection, DataOutputPlus out, int version) throws IOException { assert version >= MessagingService.VERSION_30; // We handle backward compatibility directy in ReadResponse.LegacyRangeSliceReplySerializer out.writeBoolean(iter.isForThrift()); while (iter.hasNext()) { out.writeBoolean(true); try (UnfilteredRowIterator partition = iter.next()) { UnfilteredRowIteratorSerializer.serializer.serialize(partition, selection, out, version); } } out.writeBoolean(false); }
public void serialize(UnfilteredPartitionIterator iter, ColumnFilter selection, DataOutputPlus out, int version) throws IOException { assert version >= MessagingService.VERSION_30; // We handle backward compatibility directy in ReadResponse.LegacyRangeSliceReplySerializer out.writeBoolean(iter.isForThrift()); while (iter.hasNext()) { out.writeBoolean(true); try (UnfilteredRowIterator partition = iter.next()) { UnfilteredRowIteratorSerializer.serializer.serialize(partition, selection, out, version); } } out.writeBoolean(false); }
public void serialize(UnfilteredPartitionIterator iter, ColumnFilter selection, DataOutputPlus out, int version) throws IOException { assert version >= MessagingService.VERSION_30; // We handle backward compatibility directy in ReadResponse.LegacyRangeSliceReplySerializer out.writeBoolean(iter.isForThrift()); while (iter.hasNext()) { out.writeBoolean(true); try (UnfilteredRowIterator partition = iter.next()) { UnfilteredRowIteratorSerializer.serializer.serialize(partition, selection, out, version); } } out.writeBoolean(false); }
public void serialize(UnfilteredPartitionIterator iter, ColumnFilter selection, DataOutputPlus out, int version) throws IOException { assert version >= MessagingService.VERSION_30; // We handle backward compatibility directy in ReadResponse.LegacyRangeSliceReplySerializer out.writeBoolean(iter.isForThrift()); while (iter.hasNext()) { out.writeBoolean(true); try (UnfilteredRowIterator partition = iter.next()) { UnfilteredRowIteratorSerializer.serializer.serialize(partition, selection, out, version); } } out.writeBoolean(false); }
public long serializedSize(ReadResponse response, int version) { assert version < MessagingService.VERSION_30; long size = TypeSizes.sizeof(0); // number of partitions assert response.command != null; // we only serialize LocalDataResponse, which always has the command set try (UnfilteredPartitionIterator iterator = response.makeIterator(response.command)) { while (iterator.hasNext()) { try (UnfilteredRowIterator partition = iterator.next()) { size += ByteBufferUtil.serializedSizeWithShortLength(partition.partitionKey().getKey()); size += LegacyLayout.serializedSizeAsLegacyPartition(response.command, partition, version); } } } return size; } }
private static void convertSchemaToMutations(Map<DecoratedKey, Mutation> mutationMap, String schemaTableName) { ReadCommand cmd = getReadCommandForTableSchema(schemaTableName); try (ReadExecutionController executionController = cmd.executionController(); UnfilteredPartitionIterator iter = cmd.executeLocally(executionController)) { while (iter.hasNext()) { try (UnfilteredRowIterator partition = iter.next()) { if (isSystemKeyspaceSchemaPartition(partition.partitionKey())) continue; DecoratedKey key = partition.partitionKey(); Mutation mutation = mutationMap.get(key); if (mutation == null) { mutation = new Mutation(SchemaConstants.SCHEMA_KEYSPACE_NAME, key); mutationMap.put(key, mutation); } mutation.add(makeUpdateForSchema(partition, cmd.columnFilter())); } } } }
public long serializedSize(ReadResponse response, int version) { assert version < MessagingService.VERSION_30; long size = TypeSizes.sizeof(0); // number of partitions assert response.command != null; // we only serialize LocalDataResponse, which always has the command set try (UnfilteredPartitionIterator iterator = response.makeIterator(response.command)) { while (iterator.hasNext()) { try (UnfilteredRowIterator partition = iterator.next()) { size += ByteBufferUtil.serializedSizeWithShortLength(partition.partitionKey().getKey()); size += LegacyLayout.serializedSizeAsLegacyPartition(response.command, partition, version); } } } return size; } }
public long serializedSize(ReadResponse response, int version) { assert version < MessagingService.VERSION_30; long size = TypeSizes.sizeof(0); // number of partitions assert response.command != null; // we only serialize LocalDataResponse, which always has the command set try (UnfilteredPartitionIterator iterator = response.makeIterator(response.command)) { while (iterator.hasNext()) { try (UnfilteredRowIterator partition = iterator.next()) { size += ByteBufferUtil.serializedSizeWithShortLength(partition.partitionKey().getKey()); size += LegacyLayout.serializedSizeAsLegacyPartition(response.command, partition, version); } } } return size; } }
@SuppressWarnings("resource") // The created resources are returned right away public static UnfilteredRowIterator getOnlyElement(final UnfilteredPartitionIterator iter, SinglePartitionReadCommand command) { // If the query has no results, we'll get an empty iterator, but we still // want a RowIterator out of this method, so we return an empty one. UnfilteredRowIterator toReturn = iter.hasNext() ? iter.next() : EmptyIterators.unfilteredRow(command.metadata(), command.partitionKey(), command.clusteringIndexFilter().isReversed()); // Note that in general, we should wrap the result so that it's close method actually // close the whole UnfilteredPartitionIterator. class Close extends Transformation { public void onPartitionClose() { // asserting this only now because it bothers Serializer if hasNext() is called before // the previously returned iterator hasn't been fully consumed. boolean hadNext = iter.hasNext(); iter.close(); assert !hadNext; } } return Transformation.apply(toReturn, new Close()); }
@SuppressWarnings("resource") // The created resources are returned right away public static UnfilteredRowIterator getOnlyElement(final UnfilteredPartitionIterator iter, SinglePartitionReadCommand command) { // If the query has no results, we'll get an empty iterator, but we still // want a RowIterator out of this method, so we return an empty one. UnfilteredRowIterator toReturn = iter.hasNext() ? iter.next() : EmptyIterators.unfilteredRow(command.metadata(), command.partitionKey(), command.clusteringIndexFilter().isReversed()); // Note that in general, we should wrap the result so that it's close method actually // close the whole UnfilteredPartitionIterator. class Close extends Transformation { public void onPartitionClose() { // asserting this only now because it bothers Serializer if hasNext() is called before // the previously returned iterator hasn't been fully consumed. boolean hadNext = iter.hasNext(); iter.close(); assert !hadNext; } } return Transformation.apply(toReturn, new Close()); }
@SuppressWarnings("resource") // The created resources are returned right away public static UnfilteredRowIterator getOnlyElement(final UnfilteredPartitionIterator iter, SinglePartitionReadCommand command) { // If the query has no results, we'll get an empty iterator, but we still // want a RowIterator out of this method, so we return an empty one. UnfilteredRowIterator toReturn = iter.hasNext() ? iter.next() : EmptyIterators.unfilteredRow(command.metadata(), command.partitionKey(), command.clusteringIndexFilter().isReversed()); // Note that in general, we should wrap the result so that it's close method actually // close the whole UnfilteredPartitionIterator. class Close extends Transformation { public void onPartitionClose() { // asserting this only now because it bothers Serializer if hasNext() is called before // the previously returned iterator hasn't been fully consumed. boolean hadNext = iter.hasNext(); iter.close(); assert !hadNext; } } return Transformation.apply(toReturn, new Close()); }
/** * Creates a string of the requested partition in this read response suitable for debugging. */ public String toDebugString(ReadCommand command, DecoratedKey key) { if (isDigestResponse()) return "Digest:0x" + ByteBufferUtil.bytesToHex(digest(command)); try (UnfilteredPartitionIterator iter = makeIterator(command)) { while (iter.hasNext()) { try (UnfilteredRowIterator partition = iter.next()) { if (partition.partitionKey().equals(key)) return ImmutableBTreePartition.create(partition).toString(); } } } return "<key " + key + " not found>"; }
/** * Creates a string of the requested partition in this read response suitable for debugging. */ public String toDebugString(ReadCommand command, DecoratedKey key) { if (isDigestResponse()) return "Digest:0x" + ByteBufferUtil.bytesToHex(digest(command)); try (UnfilteredPartitionIterator iter = makeIterator(command)) { while (iter.hasNext()) { try (UnfilteredRowIterator partition = iter.next()) { if (partition.partitionKey().equals(key)) return toDebugString(partition, command.metadata()); } } } return "<key " + key + " not found>"; }
/** * Creates a string of the requested partition in this read response suitable for debugging. */ public String toDebugString(ReadCommand command, DecoratedKey key) { if (isDigestResponse()) return "Digest:0x" + ByteBufferUtil.bytesToHex(digest(command)); try (UnfilteredPartitionIterator iter = makeIterator(command)) { while (iter.hasNext()) { try (UnfilteredRowIterator partition = iter.next()) { if (partition.partitionKey().equals(key)) return toDebugString(partition, command.metadata()); } } } return "<key " + key + " not found>"; }