cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject [1/2] git commit: Merge branch 'cassandra-1.1' into trunk
Date Tue, 02 Oct 2012 16:52:05 GMT
Updated Branches:
  refs/heads/trunk ab13579a3 -> f3e24bd51


Merge branch 'cassandra-1.1' into trunk

Conflicts:
	src/java/org/apache/cassandra/cql3/statements/SelectStatement.java


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

Branch: refs/heads/trunk
Commit: f3e24bd5162eede8ad13abc9c85c90dd971fc110
Parents: ab13579 6ddcf03
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Tue Oct 2 18:51:58 2012 +0200
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Tue Oct 2 18:51:58 2012 +0200

----------------------------------------------------------------------
 CHANGES.txt                                        |    1 +
 .../cassandra/cql3/statements/SelectStatement.java |   31 ++++++++++-----
 2 files changed, 22 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/f3e24bd5/CHANGES.txt
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/f3e24bd5/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
index 4af9afd,fac0deb..08b8211
--- a/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java
@@@ -280,26 -319,19 +286,26 @@@ public class SelectStatement implement
          return bounds;
      }
  
 -    private SlicePredicate makeSlicePredicate(List<ByteBuffer> variables)
 +    private IFilter makeFilter(List<ByteBuffer> variables)
      throws InvalidRequestException
      {
 -        SlicePredicate thriftSlicePredicate = new SlicePredicate();
 -
          if (isColumnRange())
          {
 -            SliceRange sliceRange = new SliceRange();
 -            sliceRange.start = getRequestedBound(isReversed ? Bound.END : Bound.START, variables);
 -            sliceRange.finish = getRequestedBound(isReversed ? Bound.START : Bound.END,
variables);
 -            sliceRange.reversed = isReversed;
 -            sliceRange.count = -1; // We use this for range slices, where the count is ignored
in favor of the global column count
 -            thriftSlicePredicate.slice_range = sliceRange;
 +            // For sparse, we used to ask for 'defined columns' * 'asked limit' (where defined
columns includes the row marker)
 +            // to account for the grouping of columns.
 +            // Since that doesn't work for maps/sets/lists, we now use the compositesToGroup
option of SliceQueryFilter.
 +            // But we must preserve backward compatibility too (for mixed version cluster
that is).
 +            int multiplier = cfDef.isCompact ? 1 : (cfDef.metadata.size() + 1);
 +            int toGroup = cfDef.isCompact ? -1 : cfDef.columns.size();
-             ColumnSlice slice = new ColumnSlice(getRequestedBound(isReversed ? Bound.END
: Bound.START, variables),
-                                                 getRequestedBound(isReversed ? Bound.START
: Bound.END, variables));
++            ColumnSlice slice = new ColumnSlice(getRequestedBound(Bound.START, variables),
++                                                getRequestedBound(Bound.END, variables));
 +            SliceQueryFilter filter = new SliceQueryFilter(new ColumnSlice[]{slice},
 +                                                           isReversed,
 +                                                           getLimit(),
 +                                                           toGroup,
 +                                                           multiplier);
 +            QueryProcessor.validateSliceFilter(cfDef.cfm, filter);
 +            return filter;
          }
          else
          {
@@@ -493,10 -484,18 +499,15 @@@
          }
      }
  
-     private ByteBuffer buildBound(Bound b, Restriction[] restrictions, ColumnNameBuilder
builder, List<ByteBuffer> variables) throws InvalidRequestException
 -    private ByteBuffer getRequestedBound(Bound bound, List<ByteBuffer> variables)
throws InvalidRequestException
++    private ByteBuffer buildBound(Bound bound, Restriction[] restrictions, ColumnNameBuilder
builder, List<ByteBuffer> variables) throws InvalidRequestException
      {
-         for (Restriction r : restrictions)
 -        assert isColumnRange();
 -
 -        ColumnNameBuilder builder = cfDef.getColumnNameBuilder();
+         for (CFDefinition.Name name : cfDef.columns.values())
          {
+             // In a restriction, we always have Bound.START < Bound.END for the "base"
comparator.
+             // So if we're doing a reverse slice, we must inverse the bounds when giving
them as start and end of the slice filter.
+             // But if the actual comparator itself is reversed, we must inversed the bounds
too.
+             Bound b = isReversed == isReversedType(name) ? bound : Bound.reverse(bound);
+             Restriction r = columnRestrictions[name.position];
              if (r == null || (!r.isEquality() && r.bound(b) == null))
              {
                  // There wasn't any non EQ relation on that key, we select all records having
the preceding component as prefix.
@@@ -521,13 -520,7 +532,13 @@@
              }
          }
          // Means no relation at all or everything was an equal
-         return (b == Bound.END) ? builder.buildAsEndOfRange() : builder.build();
 -        return builder.build();
++        return (bound == Bound.END) ? builder.buildAsEndOfRange() : builder.build();
 +    }
 +
 +    private ByteBuffer getRequestedBound(Bound b, List<ByteBuffer> variables) throws
InvalidRequestException
 +    {
 +        assert isColumnRange();
 +        return buildBound(b, columnRestrictions, cfDef.getColumnNameBuilder(), variables);
      }
  
      private List<IndexExpression> getIndexExpressions(List<ByteBuffer> variables)
throws InvalidRequestException
@@@ -925,9 -932,16 +936,14 @@@
                  default:
                      throw new AssertionError();
              }
 -            thriftColumns.add(col);
          }
 -        return new CqlRow(key, thriftColumns);
      }
  
+     private static boolean isReversedType(CFDefinition.Name name)
+     {
+         return name.type instanceof ReversedType;
+     }
+ 
      public static class RawStatement extends CFStatement
      {
          private final Parameters parameters;
@@@ -1218,15 -1168,13 +1234,10 @@@
                  stmt.isReversed = isReversed;
              }
  
 -            // If this is a query on tokens, it's necessary a range query (there can be
more than one key per token), so reject IN queries (as we don't know how to do them)
 -            if (stmt.keyRestriction != null && stmt.keyRestriction.onToken &&
stmt.keyRestriction.isEquality() && stmt.keyRestriction.eqValues.size() > 1)
 -                throw new InvalidRequestException("Select using the token() function don't
support IN clause");
  
 -            return new ParsedStatement.Prepared(stmt, Arrays.<CFDefinition.Name>asList(names));
 +            return new ParsedStatement.Prepared(stmt, Arrays.<ColumnSpecification>asList(names));
          }
  
-         private static boolean isReversedType(CFDefinition.Name name)
-         {
-             return name.type instanceof ReversedType;
-         }
- 
          Restriction updateRestriction(CFDefinition.Name name, Restriction restriction, Relation
newRel) throws InvalidRequestException
          {
              if (newRel.onToken && name.kind != CFDefinition.Name.Kind.KEY_ALIAS)


Mime
View raw message