cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tylerho...@apache.org
Subject [2/2] cassandra git commit: Merge branch 'cassandra-2.0' into cassandra-2.1
Date Fri, 08 May 2015 18:36:48 GMT
Merge branch 'cassandra-2.0' into cassandra-2.1


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

Branch: refs/heads/cassandra-2.1
Commit: d8b79d5aff93b75198bb60e5140ff3fea912d387
Parents: a431d84 15235ee
Author: Tyler Hobbs <tylerhobbs@apache.org>
Authored: Fri May 8 13:36:10 2015 -0500
Committer: Tyler Hobbs <tylerhobbs@apache.org>
Committed: Fri May 8 13:36:10 2015 -0500

----------------------------------------------------------------------
 CHANGES.txt                                            |  2 ++
 .../cassandra/cql3/statements/SelectStatement.java     |  2 +-
 .../apache/cassandra/db/marshal/CollectionType.java    | 13 ++++++++-----
 3 files changed, 11 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/d8b79d5a/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index 2b7a355,d3715c4..162b34f
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,21 -1,6 +1,23 @@@
 -2.0.15:
 +2.1.6
 + * Delete processed sstables in sstablesplit/sstableupgrade (CASSANDRA-8606)
 + * Improve sstable exclusion from partition tombstones (CASSANDRA-9298)
 + * Validate the indexed column rather than the cell's contents for 2i (CASSANDRA-9057)
 + * Add support for top-k custom 2i queries (CASSANDRA-8717)
 + * Fix error when dropping table during compaction (CASSANDRA-9251)
 + * cassandra-stress supports validation operations over user profiles (CASSANDRA-8773)
 + * Add support for rate limiting log messages (CASSANDRA-9029)
 + * Log the partition key with tombstone warnings (CASSANDRA-8561)
 + * Reduce runWithCompactionsDisabled poll interval to 1ms (CASSANDRA-9271)
 + * Fix PITR commitlog replay (CASSANDRA-9195)
 + * GCInspector logs very different times (CASSANDRA-9124)
 + * Fix deleting from an empty list (CASSANDRA-9198)
 + * Update tuple and collection types that use a user-defined type when that UDT
 +   is modified (CASSANDRA-9148, CASSANDRA-9192)
 + * Use higher timeout for prepair and snapshot in repair (CASSANDRA-9261)
 + * Fix anticompaction blocking ANTI_ENTROPY stage (CASSANDRA-9151)
 +Merged from 2.0:
+  * Include keyspace and table name in error log for collections over the size
+    limit (CASSANDRA-9286)
   * Avoid potential overlap in LCS with single-partition sstables (CASSANDRA-9322)
   * Log warning message when a table is queried before the schema has fully
     propagated (CASSANDRA-9136)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/d8b79d5a/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
index 07e60d4,8a4deb6..51f4941
--- a/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
@@@ -1288,25 -1300,12 +1288,25 @@@ public class SelectStatement implement
          }
      }
  
 -    private boolean hasValueForQuery(ColumnGroupMap staticGroup)
 +    private static void addValue(Selection.ResultSetBuilder result, ColumnDefinition def,
CQL3Row row, QueryOptions options)
      {
 -        for (CFDefinition.Name name : Iterables.filter(selection.getColumns(), isStaticFilter))
 -            if (staticGroup.hasValueFor(name.name.key))
 -                return true;
 -        return false;
 +        if (row == null)
 +        {
 +            result.add((ByteBuffer)null);
 +            return;
 +        }
 +
 +        if (def.type.isMultiCell())
 +        {
 +            List<Cell> cells = row.getMultiCellColumn(def.name);
 +            ByteBuffer buffer = cells == null
 +                             ? null
-                              : ((CollectionType)def.type).serializeForNativeProtocol(cells,
options.getProtocolVersion());
++                             : ((CollectionType)def.type).serializeForNativeProtocol(def,
cells, options.getProtocolVersion());
 +            result.add(buffer);
 +            return;
 +        }
 +
 +        result.add(row.getColumn(def.name));
      }
  
      private boolean hasNoClusteringColumnsRestriction()

http://git-wip-us.apache.org/repos/asf/cassandra/blob/d8b79d5a/src/java/org/apache/cassandra/db/marshal/CollectionType.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/db/marshal/CollectionType.java
index 24ad533,d1ae130..8662c1e
--- a/src/java/org/apache/cassandra/db/marshal/CollectionType.java
+++ b/src/java/org/apache/cassandra/db/marshal/CollectionType.java
@@@ -20,8 -20,6 +20,9 @@@ package org.apache.cassandra.db.marshal
  import java.nio.ByteBuffer;
  import java.util.List;
  
++import org.apache.cassandra.config.ColumnDefinition;
 +import org.apache.cassandra.db.Cell;
 +import org.apache.cassandra.transport.Server;
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  
@@@ -76,102 -86,49 +77,104 @@@ public abstract class CollectionType<T
          }
      }
  
 -    public void validate(ByteBuffer bytes)
 +    public boolean isCollection()
      {
 -        valueComparator().validate(bytes);
 +        return true;
      }
  
 -    public boolean isCollection()
 +    @Override
 +    public void validateCellValue(ByteBuffer cellValue) throws MarshalException
      {
 -        return true;
 +        if (isMultiCell())
 +            valueComparator().validate(cellValue);
 +        else
 +            super.validateCellValue(cellValue);
      }
  
 -    // Utilitary method
 -    protected static ByteBuffer pack(List<ByteBuffer> buffers, int elements, int size)
 +    /**
 +     * Checks if this collection is Map.
 +     * @return <code>true</code> if this collection is a Map, <code>false</code>
otherwise.
 +     */
 +    public boolean isMap()
      {
 -        ByteBuffer result = ByteBuffer.allocate(2 + size);
 -        result.putShort((short)elements);
 -        for (ByteBuffer bb : buffers)
 -        {
 -            result.putShort((short)bb.remaining());
 -            result.put(bb.duplicate());
 -        }
 -        return (ByteBuffer)result.flip();
 +        return kind == Kind.MAP;
 +    }
 +
-     public List<Cell> enforceLimit(List<Cell> cells, int version)
++    public List<Cell> enforceLimit(ColumnDefinition def, List<Cell> cells, int
version)
 +    {
 +        assert isMultiCell();
 +
 +        if (version >= Server.VERSION_3 || cells.size() <= MAX_ELEMENTS)
 +            return cells;
 +
-         logger.error("Detected collection with {} elements, more than the {} limit. Only
the first {} elements will be returned to the client. "
-                    + "Please see http://cassandra.apache.org/doc/cql3/CQL.html#collections
for more details.", cells.size(), MAX_ELEMENTS, MAX_ELEMENTS);
++        logger.error("Detected collection for table {}.{} with {} elements, more than the
{} limit. Only the first {}" +
++                     " elements will be returned to the client. Please see " +
++                     "http://cassandra.apache.org/doc/cql3/CQL.html#collections for more
details.",
++                     def.ksName, def.cfName, cells.size(), MAX_ELEMENTS, MAX_ELEMENTS);
 +        return cells.subList(0, MAX_ELEMENTS);
 +    }
 +
 +    public abstract List<ByteBuffer> serializedValues(List<Cell> cells);
 +
-     public ByteBuffer serializeForNativeProtocol(List<Cell> cells, int version)
++    public ByteBuffer serializeForNativeProtocol(ColumnDefinition def, List<Cell>
cells, int version)
 +    {
 +        assert isMultiCell();
-         cells = enforceLimit(cells, version);
++        cells = enforceLimit(def, cells, version);
 +        List<ByteBuffer> values = serializedValues(cells);
 +        return CollectionSerializer.pack(values, cells.size(), version);
      }
  
 -    protected List<Pair<ByteBuffer, Column>> enforceLimit(CFDefinition.Name
name, List<Pair<ByteBuffer, Column>> columns)
 +    @Override
 +    public boolean isCompatibleWith(AbstractType<?> previous)
      {
 -        if (columns.size() <= MAX_ELEMENTS)
 -            return columns;
 -
 -        logger.error("Detected collection for table {}.{} with {} elements, more than the
{} limit. Only the first {}"
 -                     + "elements will be returned to the client. Please see "
 -                     + "http://cassandra.apache.org/doc/cql3/CQL.html#collections for more
details.",
 -                     name.ksName, name.cfName, columns.size(), MAX_ELEMENTS, MAX_ELEMENTS);
 -        return columns.subList(0, MAX_ELEMENTS);
 +        if (this == previous)
 +            return true;
 +
 +        if (!getClass().equals(previous.getClass()))
 +            return false;
 +
 +        CollectionType tprev = (CollectionType) previous;
 +        if (this.isMultiCell() != tprev.isMultiCell())
 +            return false;
 +
 +        // subclasses should handle compatibility checks for frozen collections
 +        if (!this.isMultiCell())
 +            return isCompatibleWithFrozen(tprev);
 +
 +        if (!this.nameComparator().isCompatibleWith(tprev.nameComparator()))
 +            return false;
 +
 +        // the value comparator is only used for Cell values, so sorting doesn't matter
 +        return this.valueComparator().isValueCompatibleWith(tprev.valueComparator());
      }
  
 -    public static ByteBuffer pack(List<ByteBuffer> buffers, int elements)
 +    @Override
 +    public boolean isValueCompatibleWithInternal(AbstractType<?> previous)
      {
 -        int size = 0;
 -        for (ByteBuffer bb : buffers)
 -            size += 2 + bb.remaining();
 -        return pack(buffers, elements, size);
 +        // for multi-cell collections, compatibility and value-compatibility are the same
 +        if (this.isMultiCell())
 +            return isCompatibleWith(previous);
 +
 +        if (this == previous)
 +            return true;
 +
 +        if (!getClass().equals(previous.getClass()))
 +            return false;
 +
 +        CollectionType tprev = (CollectionType) previous;
 +        if (this.isMultiCell() != tprev.isMultiCell())
 +            return false;
 +
 +        // subclasses should handle compatibility checks for frozen collections
 +        return isValueCompatibleWithFrozen(tprev);
      }
  
 +    /** A version of isCompatibleWith() to deal with non-multicell (frozen) collections
*/
 +    protected abstract boolean isCompatibleWithFrozen(CollectionType<?> previous);
 +
 +    /** A version of isValueCompatibleWith() to deal with non-multicell (frozen) collections
*/
 +    protected abstract boolean isValueCompatibleWithFrozen(CollectionType<?> previous);
 +
      public CQL3Type asCQL3Type()
      {
          return new CQL3Type.Collection(this);


Mime
View raw message