cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject [2/3] git commit: Merge branch 'cassandra-2.0' into cassandra-2.1
Date Wed, 02 Apr 2014 12:29:22 GMT
Merge branch 'cassandra-2.0' into cassandra-2.1

Conflicts:
	src/java/org/apache/cassandra/db/SuperColumns.java


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

Branch: refs/heads/trunk
Commit: ef08e62589f9a27c76f610058373780ce36a7d89
Parents: 8afe109 e1a9093
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Wed Apr 2 14:28:54 2014 +0200
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Wed Apr 2 14:28:54 2014 +0200

----------------------------------------------------------------------
 CHANGES.txt                                        | 1 +
 src/java/org/apache/cassandra/db/SuperColumns.java | 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


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

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ef08e625/src/java/org/apache/cassandra/db/SuperColumns.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/db/SuperColumns.java
index 46c5577,0f74587..bab46eb
--- a/src/java/org/apache/cassandra/db/SuperColumns.java
+++ b/src/java/org/apache/cassandra/db/SuperColumns.java
@@@ -124,52 -205,155 +124,51 @@@ public class SuperColumn
          }
      }
  
 -    public static AbstractType<?> getComparatorFor(CFMetaData metadata, ByteBuffer
superColumn)
 -    {
 -        return getComparatorFor(metadata, superColumn != null);
 -    }
 -
 -    public static AbstractType<?> getComparatorFor(CFMetaData metadata, boolean subColumn)
 +    private static CellNameType subType(CellNameType type)
      {
 -        return metadata.isSuper()
 -             ? ((CompositeType)metadata.comparator).types.get(subColumn ? 1 : 0)
 -             : metadata.comparator;
 +        return new SimpleDenseCellNameType(type.subtype(1));
      }
  
 -    // Extract the first component of a columnName, i.e. the super column name
 -    public static ByteBuffer scName(ByteBuffer columnName)
 +    public static CellNameType scNameType(CellNameType type)
      {
 -        return CompositeType.extractComponent(columnName, 0);
 +        return new SimpleDenseCellNameType(type.subtype(0));
      }
  
 -    // Extract the 2nd component of a columnName, i.e. the sub-column name
 -    public static ByteBuffer subName(ByteBuffer columnName)
 +    public static AbstractType<?> getComparatorFor(CFMetaData metadata, ByteBuffer
superColumn)
      {
 -        return CompositeType.extractComponent(columnName, 1);
 +        return getComparatorFor(metadata, superColumn != null);
      }
  
 -    // We don't use CompositeType.Builder mostly because we want to avoid having to provide
the comparator.
 -    public static ByteBuffer startOf(ByteBuffer scName)
 +    public static AbstractType<?> getComparatorFor(CFMetaData metadata, boolean subColumn)
      {
 -        int length = scName.remaining();
 -        ByteBuffer bb = ByteBuffer.allocate(2 + length + 1);
 -
 -        bb.put((byte) ((length >> 8) & 0xFF));
 -        bb.put((byte) (length & 0xFF));
 -        bb.put(scName.duplicate());
 -        bb.put((byte) 0);
 -        bb.flip();
 -        return bb;
 +        return metadata.isSuper()
 +             ? metadata.comparator.subtype(subColumn ? 1 : 0)
 +             : metadata.comparator.asAbstractType();
      }
  
 -    public static ByteBuffer endOf(ByteBuffer scName)
 +    // Extract the first component of a columnName, i.e. the super column name
 +    public static ByteBuffer scName(Composite columnName)
      {
 -        ByteBuffer bb = startOf(scName);
 -        bb.put(bb.remaining() - 1, (byte)1);
 -        return bb;
 +        return columnName.get(0);
      }
  
 -    public static SCFilter filterToSC(CompositeType type, IDiskAtomFilter filter)
 +    // Extract the 2nd component of a columnName, i.e. the sub-column name
 +    public static ByteBuffer subName(Composite columnName)
      {
 -        if (filter instanceof NamesQueryFilter)
 -            return namesFilterToSC(type, (NamesQueryFilter)filter);
 -        else
 -            return sliceFilterToSC(type, (SliceQueryFilter)filter);
 +        return columnName.get(1);
      }
  
 -    public static SCFilter namesFilterToSC(CompositeType type, NamesQueryFilter filter)
 +    public static Composite startOf(ByteBuffer scName)
      {
 -        SortedSet<ByteBuffer> newColumns = new TreeSet<>(type.types.get(1));
 -        ByteBuffer scName = scName(filter.columns.first());
 -        for (ByteBuffer name : filter.columns)
 -        {
 -            // If we're selecting column across multiple SC, it's not something we can translate
for an old node
 -            if (type.types.get(0).compare(scName, scName(name)) != 0)
 -                throw new RuntimeException("Cannot convert filter to old super column format.
Update all nodes to Cassandra 2.0 first.");
 -
 -            newColumns.add(subName(name));
 -        }
 -        return new SCFilter(scName, new NamesQueryFilter(newColumns));
 +        return CellNames.compositeDense(scName).start();
      }
  
 -    public static SCFilter sliceFilterToSC(CompositeType type, SliceQueryFilter filter)
 +    public static Composite endOf(ByteBuffer scName)
      {
 -        /*
 -         * There is 3 main cases that we can translate back into super column
 -         * queries:
 -         *   1) We have only one slice where the first component of start and
 -         *   finish is the same, we translate as a slice query on one SC.
 -         *   2) We have only one slice, neither the start and finish have a 2nd
 -         *   component, and end has the 'end of component' set, we translate
 -         *   as a slice of SCs.
 -         *   3) Each slice has the same first component for start and finish, no
 -         *   2nd component and each finish has the 'end of component' set, we
 -         *   translate as a names query of SCs (the filter must then not be reversed).
 -         * Otherwise, we can't do much.
 -         */
 -
 -        boolean reversed = filter.reversed;
 -        if (filter.slices.length == 1)
 -        {
 -            ByteBuffer start = filter.slices[0].start;
 -            ByteBuffer finish = filter.slices[0].start;
 -
 -            if (filter.compositesToGroup == 1)
 -            {
 -                // Note: all the resulting filter must have compositeToGroup == 0 because
this
 -                // make no sense for super column on the destination node otherwise
 -                if (start.remaining() == 0)
 -                {
 -                    if (finish.remaining() == 0)
 -                        // An 'IdentityFilter', keep as is (except for the compositeToGroup)
 -                        return new SCFilter(null, new SliceQueryFilter(filter.start(), filter.finish(),
reversed, filter.count));
 -
 -                    if (subName(finish) == null
 -                            && ((!reversed && !firstEndOfComponent(finish))
|| (reversed && firstEndOfComponent(finish))))
 -                        return new SCFilter(null, new SliceQueryFilter(ByteBufferUtil.EMPTY_BYTE_BUFFER,
scName(finish), reversed, filter.count));
 -                }
 -                else if (finish.remaining() == 0)
 -                {
 -                    if (subName(start) == null
 -                            && ((!reversed && firstEndOfComponent(start))
|| (reversed && !firstEndOfComponent(start))))
 -                        return new SCFilter(null, new SliceQueryFilter(scName(start), ByteBufferUtil.EMPTY_BYTE_BUFFER,
reversed, filter.count));
 -                }
 -                else if (subName(start) == null && subName(finish) == null
 -                        && ((   reversed && !firstEndOfComponent(start)
&&  firstEndOfComponent(finish))
 -                            || (!reversed &&  firstEndOfComponent(start) &&
!firstEndOfComponent(finish))))
 -                {
 -                    // A slice of supercolumns
 -                    return new SCFilter(null, new SliceQueryFilter(scName(start), scName(finish),
reversed, filter.count));
 -                }
 -            }
 -            else if (filter.compositesToGroup == -1 && type.types.get(0).compare(scName(start),
scName(finish)) == 0)
 -            {
 -                // A slice of subcolumns
 -                ByteBuffer newStart = subName(start);
 -                ByteBuffer newFinish = subName(finish);
 -                return new SCFilter(scName(start),
 -                                    filter.withUpdatedSlice(newStart  == null ? ByteBufferUtil.EMPTY_BYTE_BUFFER
: newStart,
 -                                                            newFinish == null ? ByteBufferUtil.EMPTY_BYTE_BUFFER
: newFinish));
 -            }
 -        }
 -        else if (!reversed)
 -        {
 -            SortedSet<ByteBuffer> columns = new TreeSet<ByteBuffer>(type.types.get(0));
 -            for (int i = 0; i < filter.slices.length; ++i)
 -            {
 -                ByteBuffer start = filter.slices[i].start;
 -                ByteBuffer finish = filter.slices[i].finish;
 -
 -                if (subName(start) != null || subName(finish) != null
 -                  || type.types.get(0).compare(scName(start), scName(finish)) != 0
 -                  || firstEndOfComponent(start) || !firstEndOfComponent(finish))
 -                    throw new RuntimeException("Cannot convert filter to old super column
format. Update all nodes to Cassandra 2.0 first.");
 -
 -                columns.add(scName(start));
 -            }
 -            return new SCFilter(null, new NamesQueryFilter(columns));
 -        }
 -        throw new RuntimeException("Cannot convert filter to old super column format. Update
all nodes to Cassandra 2.0 first.");
 +        return CellNames.compositeDense(scName).end();
      }
  
- 
 -    public static IDiskAtomFilter fromSCFilter(CompositeType type, ByteBuffer scName, IDiskAtomFilter
filter)
 +    public static IDiskAtomFilter fromSCFilter(CellNameType type, ByteBuffer scName, IDiskAtomFilter
filter)
      {
          if (filter instanceof NamesQueryFilter)
              return fromSCNamesFilter(type, scName, (NamesQueryFilter)filter);


Mime
View raw message