cassandra-pr mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iamaleksey <...@git.apache.org>
Subject [GitHub] cassandra pull request #239: [CASSANDRA-14556] Optimize Streaming
Date Fri, 27 Jul 2018 11:55:41 GMT
Github user iamaleksey commented on a diff in the pull request:

    https://github.com/apache/cassandra/pull/239#discussion_r205747034
  
    --- Diff: src/java/org/apache/cassandra/db/streaming/CassandraOutgoingFile.java ---
    @@ -114,11 +165,77 @@ 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);
    -        writer.write(out);
    +        if (shouldStreamEntireSSTable() && out instanceof ByteBufDataOutputStreamPlus)
    +        {
    +            CassandraBlockStreamWriter writer = new CassandraBlockStreamWriter(sstable,
session, manifest);
    +            writer.write((ByteBufDataOutputStreamPlus) out);
    +        }
    +        else
    +        {
    +            CassandraStreamWriter writer = (header.compressionInfo == null) ?
    +                     new CassandraStreamWriter(sstable, header.sections, session) :
    +                     new CompressedCassandraStreamWriter(sstable, header.sections,
    +                                                         header.compressionInfo, session);
    +            writer.write(out);
    +        }
    +    }
    +
    +    @VisibleForTesting
    +    public boolean shouldStreamEntireSSTable()
    +    {
    +        // don't stream if full sstable transfers are disabled or legacy counter shards
are present
    +        if (!isZeroCopySSTableTransfersEnabled || ref.get().getSSTableMetadata().hasLegacyCounterShards)
    +            return false;
    +
    +        ColumnFamilyStore cfs = ColumnFamilyStore.getIfExists(getTableId());
    +
    +        if (cfs == null)
    +            return false;
    +
    +        AbstractCompactionStrategy compactionStrategy = cfs.getCompactionStrategyManager()
    +                                                           .getCompactionStrategyFor(ref.get());
    +
    +        if (compactionStrategy instanceof LeveledCompactionStrategy)
    +            return contained(ranges, ref.get());
    +
    +        if (compactionStrategy instanceof SizeTieredCompactionStrategy)
    +        {
    +            return (ranges != null
    +                        && ranges.size() == 1
    +                        && ranges.get(0)
    +                                 .contains(new Range<>(ref.get().first.getToken(),
    --- End diff --
    
    Should be Bounds for the sstable, since range is (first, last] and sstable contains [first,
last] (thanks @krummas). But on a higher level note, maybe just stick to LCS only for now,
and enable STCS after we commit CASSANDRA-14568? We are going to do that in 4.0, so this temporary
special case won't make it to a release anyway ¯\_(ツ)_/¯ 


---

---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


Mime
View raw message