cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stefa...@apache.org
Subject [4/6] cassandra git commit: Merge branch 'cassandra-3.0' into cassandra-3.7
Date Tue, 31 May 2016 13:01:15 GMT
Merge branch 'cassandra-3.0' into cassandra-3.7


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/a2b73a5a
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/a2b73a5a
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/a2b73a5a

Branch: refs/heads/trunk
Commit: a2b73a5aa623f491eb44cf27bdc15b05155b6ffb
Parents: e23d1d9 57ead56
Author: Stefania Alborghetti <stefania.alborghetti@datastax.com>
Authored: Tue May 31 14:54:40 2016 +0200
Committer: Stefania Alborghetti <stefania.alborghetti@datastax.com>
Committed: Tue May 31 14:58:01 2016 +0200

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../cassandra/config/DatabaseDescriptor.java    |  5 ++++
 .../apache/cassandra/db/ClusteringPrefix.java   |  6 ++--
 .../db/SinglePartitionReadCommand.java          |  2 +-
 .../cassandra/db/marshal/AbstractType.java      | 30 ++++----------------
 src/java/org/apache/cassandra/db/rows/Cell.java |  4 +--
 .../compaction/BlacklistingCompactionsTest.java | 19 +++++++------
 .../sstable/SSTableCorruptionDetectionTest.java |  7 +++--
 .../io/sstable/SSTableWriterTestBase.java       | 11 +++----
 9 files changed, 38 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/a2b73a5a/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index eb826d4,80a07a2..d081587
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,6 -1,5 +1,7 @@@
 -3.0.7
 +3.7
 +Merged from 3.0:
+  * Avoid referencing DatabaseDescriptor in AbstractType (CASSANDRA-11912)
 + * Don't use static dataDirectories field in Directories instances (CASSANDRA-11647)
   * Fix sstables not being protected from removal during index build (CASSANDRA-11905)
   * cqlsh: Suppress stack trace from Read/WriteFailures (CASSANDRA-11032)
   * Remove unneeded code to repair index summaries that have

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a2b73a5a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a2b73a5a/src/java/org/apache/cassandra/db/ClusteringPrefix.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a2b73a5a/src/java/org/apache/cassandra/db/SinglePartitionReadCommand.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a2b73a5a/src/java/org/apache/cassandra/db/marshal/AbstractType.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a2b73a5a/src/java/org/apache/cassandra/db/rows/Cell.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/db/rows/Cell.java
index e6cc435,b10ce06..0b7c46e
--- a/src/java/org/apache/cassandra/db/rows/Cell.java
+++ b/src/java/org/apache/cassandra/db/rows/Cell.java
@@@ -21,7 -21,7 +21,7 @@@ import java.io.IOException
  import java.nio.ByteBuffer;
  import java.util.Comparator;
  
--import org.apache.cassandra.config.ColumnDefinition;
++import org.apache.cassandra.config.*;
  import org.apache.cassandra.db.*;
  import org.apache.cassandra.io.util.DataOutputPlus;
  import org.apache.cassandra.io.util.DataInputPlus;
@@@ -144,165 -143,15 +144,165 @@@ public abstract class Cell extends Colu
      // Overrides super type to provide a more precise return type.
      public abstract Cell purge(DeletionPurger purger, int nowInSec);
  
 -    public interface Serializer
 +    /**
 +     * The serialization format for cell is:
 +     *     [ flags ][ timestamp ][ deletion time ][    ttl    ][ path size ][ path ][ value
size ][ value ]
 +     *     [   1b  ][ 8b (vint) ][   4b (vint)   ][ 4b (vint) ][ 4b (vint) ][  arb ][  4b
(vint) ][  arb  ]
 +     *
 +     * where not all field are always present (in fact, only the [ flags ] are guaranteed
to be present). The fields have the following
 +     * meaning:
 +     *   - [ flags ] is the cell flags. It is a byte for which each bit represents a flag
whose meaning is explained below (*_MASK constants)
 +     *   - [ timestamp ] is the cell timestamp. Present unless the cell has the USE_TIMESTAMP_MASK.
 +     *   - [ deletion time]: the local deletion time for the cell. Present if either the
cell is deleted (IS_DELETED_MASK)
 +     *       or it is expiring (IS_EXPIRING_MASK) but doesn't have the USE_ROW_TTL_MASK.
 +     *   - [ ttl ]: the ttl for the cell. Present if the row is expiring (IS_EXPIRING_MASK)
but doesn't have the
 +     *       USE_ROW_TTL_MASK.
 +     *   - [ value size ] is the size of the [ value ] field. It's present unless either
the cell has the HAS_EMPTY_VALUE_MASK, or the value
 +     *       for columns of this type have a fixed length.
 +     *   - [ path size ] is the size of the [ path ] field. Present iff this is the cell
of a complex column.
 +     *   - [ value ]: the cell value, unless it has the HAS_EMPTY_VALUE_MASK.
 +     *   - [ path ]: the cell path if the column this is a cell of is complex.
 +     */
 +    static class Serializer
      {
 -        public void serialize(Cell cell, DataOutputPlus out, LivenessInfo rowLiveness, SerializationHeader
header) throws IOException;
 +        private final static int IS_DELETED_MASK             = 0x01; // Whether the cell
is a tombstone or not.
 +        private final static int IS_EXPIRING_MASK            = 0x02; // Whether the cell
is expiring.
 +        private final static int HAS_EMPTY_VALUE_MASK        = 0x04; // Wether the cell
has an empty value. This will be the case for tombstone in particular.
 +        private final static int USE_ROW_TIMESTAMP_MASK      = 0x08; // Wether the cell
has the same timestamp than the row this is a cell of.
 +        private final static int USE_ROW_TTL_MASK            = 0x10; // Wether the cell
has the same ttl than the row this is a cell of.
 +
 +        public void serialize(Cell cell, DataOutputPlus out, LivenessInfo rowLiveness, SerializationHeader
header) throws IOException
 +        {
 +            assert cell != null;
 +            boolean hasValue = cell.value().hasRemaining();
 +            boolean isDeleted = cell.isTombstone();
 +            boolean isExpiring = cell.isExpiring();
 +            boolean useRowTimestamp = !rowLiveness.isEmpty() && cell.timestamp()
== rowLiveness.timestamp();
 +            boolean useRowTTL = isExpiring && rowLiveness.isExpiring() &&
cell.ttl() == rowLiveness.ttl() && cell.localDeletionTime() == rowLiveness.localExpirationTime();
 +            int flags = 0;
 +            if (!hasValue)
 +                flags |= HAS_EMPTY_VALUE_MASK;
 +
 +            if (isDeleted)
 +                flags |= IS_DELETED_MASK;
 +            else if (isExpiring)
 +                flags |= IS_EXPIRING_MASK;
 +
 +            if (useRowTimestamp)
 +                flags |= USE_ROW_TIMESTAMP_MASK;
 +            if (useRowTTL)
 +                flags |= USE_ROW_TTL_MASK;
 +
 +            out.writeByte((byte)flags);
 +
 +            if (!useRowTimestamp)
 +                header.writeTimestamp(cell.timestamp(), out);
 +
 +            if ((isDeleted || isExpiring) && !useRowTTL)
 +                header.writeLocalDeletionTime(cell.localDeletionTime(), out);
 +            if (isExpiring && !useRowTTL)
 +                header.writeTTL(cell.ttl(), out);
 +
 +            if (cell.column().isComplex())
 +                cell.column().cellPathSerializer().serialize(cell.path(), out);
 +
 +            if (hasValue)
 +                header.getType(cell.column()).writeValue(cell.value(), out);
 +        }
 +
 +        public Cell deserialize(DataInputPlus in, LivenessInfo rowLiveness, ColumnDefinition
column, SerializationHeader header, SerializationHelper helper) throws IOException
 +        {
 +            int flags = in.readUnsignedByte();
 +            boolean hasValue = (flags & HAS_EMPTY_VALUE_MASK) == 0;
 +            boolean isDeleted = (flags & IS_DELETED_MASK) != 0;
 +            boolean isExpiring = (flags & IS_EXPIRING_MASK) != 0;
 +            boolean useRowTimestamp = (flags & USE_ROW_TIMESTAMP_MASK) != 0;
 +            boolean useRowTTL = (flags & USE_ROW_TTL_MASK) != 0;
 +
 +            long timestamp = useRowTimestamp ? rowLiveness.timestamp() : header.readTimestamp(in);
 +
 +            int localDeletionTime = useRowTTL
 +                                    ? rowLiveness.localExpirationTime()
 +                                    : (isDeleted || isExpiring ? header.readLocalDeletionTime(in)
: NO_DELETION_TIME);
 +
 +            int ttl = useRowTTL ? rowLiveness.ttl() : (isExpiring ? header.readTTL(in) :
NO_TTL);
  
 -        public Cell deserialize(DataInputPlus in, LivenessInfo rowLiveness, ColumnDefinition
column, SerializationHeader header, SerializationHelper helper) throws IOException;
 +            CellPath path = column.isComplex()
 +                            ? column.cellPathSerializer().deserialize(in)
 +                            : null;
  
 -        public long serializedSize(Cell cell, LivenessInfo rowLiveness, SerializationHeader
header);
 +            ByteBuffer value = ByteBufferUtil.EMPTY_BYTE_BUFFER;
 +            if (hasValue)
 +            {
 +                if (helper.canSkipValue(column) || (path != null && helper.canSkipValue(path)))
 +                {
 +                    header.getType(column).skipValue(in);
 +                }
 +                else
 +                {
 +                    boolean isCounter = localDeletionTime == NO_DELETION_TIME &&
column.type.isCounter();
 +
-                     value = header.getType(column).readValue(in);
++                    value = header.getType(column).readValue(in, DatabaseDescriptor.getMaxValueSize());
 +                    if (isCounter)
 +                        value = helper.maybeClearCounterValue(value);
 +                }
 +            }
 +
 +            return new BufferCell(column, timestamp, ttl, localDeletionTime, value, path);
 +        }
 +
 +        public long serializedSize(Cell cell, LivenessInfo rowLiveness, SerializationHeader
header)
 +        {
 +            long size = 1; // flags
 +            boolean hasValue = cell.value().hasRemaining();
 +            boolean isDeleted = cell.isTombstone();
 +            boolean isExpiring = cell.isExpiring();
 +            boolean useRowTimestamp = !rowLiveness.isEmpty() && cell.timestamp()
== rowLiveness.timestamp();
 +            boolean useRowTTL = isExpiring && rowLiveness.isExpiring() &&
cell.ttl() == rowLiveness.ttl() && cell.localDeletionTime() == rowLiveness.localExpirationTime();
 +
 +            if (!useRowTimestamp)
 +                size += header.timestampSerializedSize(cell.timestamp());
 +
 +            if ((isDeleted || isExpiring) && !useRowTTL)
 +                size += header.localDeletionTimeSerializedSize(cell.localDeletionTime());
 +            if (isExpiring && !useRowTTL)
 +                size += header.ttlSerializedSize(cell.ttl());
 +
 +            if (cell.column().isComplex())
 +                size += cell.column().cellPathSerializer().serializedSize(cell.path());
 +
 +            if (hasValue)
 +                size += header.getType(cell.column()).writtenLength(cell.value());
 +
 +            return size;
 +        }
  
          // Returns if the skipped cell was an actual cell (i.e. it had its presence flag).
 -        public boolean skip(DataInputPlus in, ColumnDefinition column, SerializationHeader
header) throws IOException;
 +        public boolean skip(DataInputPlus in, ColumnDefinition column, SerializationHeader
header) throws IOException
 +        {
 +            int flags = in.readUnsignedByte();
 +            boolean hasValue = (flags & HAS_EMPTY_VALUE_MASK) == 0;
 +            boolean isDeleted = (flags & IS_DELETED_MASK) != 0;
 +            boolean isExpiring = (flags & IS_EXPIRING_MASK) != 0;
 +            boolean useRowTimestamp = (flags & USE_ROW_TIMESTAMP_MASK) != 0;
 +            boolean useRowTTL = (flags & USE_ROW_TTL_MASK) != 0;
 +
 +            if (!useRowTimestamp)
 +                header.skipTimestamp(in);
 +
 +            if (!useRowTTL && (isDeleted || isExpiring))
 +                header.skipLocalDeletionTime(in);
 +
 +            if (!useRowTTL && isExpiring)
 +                header.skipTTL(in);
 +
 +            if (column.isComplex())
 +                column.cellPathSerializer().skip(in);
 +
 +            if (hasValue)
 +                header.getType(column).skipValue(in);
 +
 +            return true;
 +        }
      }
  }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a2b73a5a/test/unit/org/apache/cassandra/db/compaction/BlacklistingCompactionsTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a2b73a5a/test/unit/org/apache/cassandra/io/sstable/SSTableCorruptionDetectionTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a2b73a5a/test/unit/org/apache/cassandra/io/sstable/SSTableWriterTestBase.java
----------------------------------------------------------------------


Mime
View raw message