Github user aweisberg commented on a diff in the pull request:
https://github.com/apache/cassandra/pull/239#discussion_r200707973
--- Diff:
src/java/org/apache/cassandra/db/streaming/CassandraOutgoingFile.java ---
@@ -114,13 +153,59 @@ public void write(StreamSession session,
DataOutputStreamPlus out, int version)
CassandraStreamHeader.serializer.serialize(header, out, version);
out.flush();
- CassandraStreamWriter writer = header.compressionInfo == null ?
- new CassandraStreamWriter(sstable,
header.sections, session) :
- new
CompressedCassandraStreamWriter(sstable, header.sections,
-
header.compressionInfo, session);
+ IStreamWriter writer;
+
+ if (shouldStreamFullSSTable())
+ {
+ writer = new CassandraBlockStreamWriter(sstable, session,
components);
+ }
+ else
+ {
+ writer = (header.compressionInfo == null) ?
+ new CassandraStreamWriter(sstable, header.sections,
session) :
+ new CompressedCassandraStreamWriter(sstable,
header.sections,
+
header.compressionInfo, session);
+ }
+
writer.write(out);
}
+ @VisibleForTesting
+ public boolean shouldStreamFullSSTable()
+ {
+ return isFullSSTableTransfersEnabled && isFullyContained;
+ }
+
+ private boolean fullyContainedIn(List<Range<Token>> requestedRanges,
SSTableReader sstable)
+ {
+ if (requestedRanges == null)
+ return false;
+ try (KeyIterator iter = new KeyIterator(sstable.descriptor,
sstable.metadata()))
+ {
+ while (iter.hasNext())
+ {
+ DecoratedKey key = iter.next();
+ // todo: this can be made more efficient by sorting and
normalizing the ranges (they might already be?)
+ // todo: then we can use the fact that the tokens we get
from the sstable are always increasing, se we don't need
+ // todo: to compare all tokens to all ranges. (see
Verifier.RangeOwnHelper in current trunk for example)
+
+ boolean foundFlag = false;
+ for (Range<Token> r : requestedRanges)
+ {
+ if (r.contains(key.getToken()))
+ {
+ foundFlag = true;
+ break;
+ }
+ }
+
+ if (foundFlag == false)
+ return false;
--- End diff --
missing braces
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]