cassandra-pr mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aweisberg <...@git.apache.org>
Subject [GitHub] cassandra pull request #239: Optimize Streaming
Date Fri, 06 Jul 2018 16:39:20 GMT
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: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


Mime
View raw message