http://git-wip-us.apache.org/repos/asf/cassandra/blob/a991b648/test/unit/org/apache/cassandra/cql3/restrictions/PrimaryKeyRestrictionSetTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/cql3/restrictions/PrimaryKeyRestrictionSetTest.java b/test/unit/org/apache/cassandra/cql3/restrictions/PrimaryKeyRestrictionSetTest.java index 05d6e98..d738c46 100644 --- a/test/unit/org/apache/cassandra/cql3/restrictions/PrimaryKeyRestrictionSetTest.java +++ b/test/unit/org/apache/cassandra/cql3/restrictions/PrimaryKeyRestrictionSetTest.java @@ -18,9 +18,9 @@ package org.apache.cassandra.cql3.restrictions; import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.List; +import java.util.*; +import com.google.common.collect.Iterables; import org.junit.Test; import org.apache.cassandra.config.CFMetaData; @@ -28,11 +28,7 @@ import org.apache.cassandra.config.ColumnDefinition; import org.apache.cassandra.cql3.*; import org.apache.cassandra.cql3.Term.MultiItemTerminal; import org.apache.cassandra.cql3.statements.Bound; -import org.apache.cassandra.db.ColumnFamilyType; -import org.apache.cassandra.db.composites.Composite; -import org.apache.cassandra.db.composites.Composite.EOC; -import org.apache.cassandra.db.composites.Composites; -import org.apache.cassandra.db.composites.CompoundSparseCellNameType; +import org.apache.cassandra.db.*; import org.apache.cassandra.db.marshal.AbstractType; import org.apache.cassandra.db.marshal.Int32Type; import org.apache.cassandra.exceptions.InvalidRequestException; @@ -45,72 +41,72 @@ import static org.junit.Assert.assertTrue; public class PrimaryKeyRestrictionSetTest { @Test - public void testBoundsAsCompositesWithNoRestrictions() throws InvalidRequestException + public void testboundsAsClusteringWithNoRestrictions() throws InvalidRequestException { CFMetaData cfMetaData = newCFMetaData(1); - PrimaryKeyRestrictions restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator); + PrimaryKeyRestrictions restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator, false); - List<Composite> bounds = restrictions.boundsAsComposites(Bound.START, QueryOptions.DEFAULT); + SortedSet<Slice.Bound> bounds = restrictions.boundsAsClustering(Bound.START, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertEmptyComposite(bounds.get(0)); + assertEmptyStart(get(bounds, 0)); - bounds = restrictions.boundsAsComposites(Bound.END, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.END, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertEmptyComposite(bounds.get(0)); + assertEmptyEnd(get(bounds, 0)); } /** * Test 'clustering_0 = 1' with only one clustering column */ @Test - public void testBoundsAsCompositesWithOneEqRestrictionsAndOneClusteringColumn() throws InvalidRequestException + public void testboundsAsClusteringWithOneEqRestrictionsAndOneClusteringColumn() throws InvalidRequestException { CFMetaData cfMetaData = newCFMetaData(1); ByteBuffer clustering_0 = ByteBufferUtil.bytes(1); Restriction eq = newSingleEq(cfMetaData, 0, clustering_0); - PrimaryKeyRestrictions restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator); + PrimaryKeyRestrictions restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator, false); restrictions = restrictions.mergeWith(eq); - List<Composite> bounds = restrictions.boundsAsComposites(Bound.START, QueryOptions.DEFAULT); + SortedSet<Slice.Bound> bounds = restrictions.boundsAsClustering(Bound.START, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), clustering_0, EOC.START); + assertStartBound(get(bounds, 0), true, clustering_0); - bounds = restrictions.boundsAsComposites(Bound.END, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.END, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), clustering_0, EOC.END); + assertEndBound(get(bounds, 0), true, clustering_0); } /** * Test 'clustering_1 = 1' with 2 clustering columns */ @Test - public void testBoundsAsCompositesWithOneEqRestrictionsAndTwoClusteringColumns() throws InvalidRequestException + public void testboundsAsClusteringWithOneEqRestrictionsAndTwoClusteringColumns() throws InvalidRequestException { CFMetaData cfMetaData = newCFMetaData(2); ByteBuffer clustering_0 = ByteBufferUtil.bytes(1); Restriction eq = newSingleEq(cfMetaData, 0, clustering_0); - PrimaryKeyRestrictions restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator); + PrimaryKeyRestrictions restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator, false); restrictions = restrictions.mergeWith(eq); - List<Composite> bounds = restrictions.boundsAsComposites(Bound.START, QueryOptions.DEFAULT); + SortedSet<Slice.Bound> bounds = restrictions.boundsAsClustering(Bound.START, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), clustering_0, EOC.START); + assertStartBound(get(bounds, 0), true, clustering_0); - bounds = restrictions.boundsAsComposites(Bound.END, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.END, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), clustering_0, EOC.END); + assertEndBound(get(bounds, 0), true, clustering_0); } /** * Test 'clustering_0 IN (1, 2, 3)' with only one clustering column */ @Test - public void testBoundsAsCompositesWithOneInRestrictionsAndOneClusteringColumn() throws InvalidRequestException + public void testboundsAsClusteringWithOneInRestrictionsAndOneClusteringColumn() throws InvalidRequestException { ByteBuffer value1 = ByteBufferUtil.bytes(1); ByteBuffer value2 = ByteBufferUtil.bytes(2); @@ -120,27 +116,27 @@ public class PrimaryKeyRestrictionSetTest Restriction in = newSingleIN(cfMetaData, 0, value1, value2, value3); - PrimaryKeyRestrictions restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator); + PrimaryKeyRestrictions restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator, false); restrictions = restrictions.mergeWith(in); - List<Composite> bounds = restrictions.boundsAsComposites(Bound.START, QueryOptions.DEFAULT); + SortedSet<Slice.Bound> bounds = restrictions.boundsAsClustering(Bound.START, QueryOptions.DEFAULT); assertEquals(3, bounds.size()); - assertComposite(bounds.get(0), value1, EOC.START); - assertComposite(bounds.get(1), value2, EOC.START); - assertComposite(bounds.get(2), value3, EOC.START); + assertStartBound(get(bounds, 0), true, value1); + assertStartBound(get(bounds, 1), true, value2); + assertStartBound(get(bounds, 2), true, value3); - bounds = restrictions.boundsAsComposites(Bound.END, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.END, QueryOptions.DEFAULT); assertEquals(3, bounds.size()); - assertComposite(bounds.get(0), value1, EOC.END); - assertComposite(bounds.get(1), value2, EOC.END); - assertComposite(bounds.get(2), value3, EOC.END); + assertEndBound(get(bounds, 0), true, value1); + assertEndBound(get(bounds, 1), true, value2); + assertEndBound(get(bounds, 2), true, value3); } /** * Test slice restriction (e.g 'clustering_0 > 1') with only one clustering column */ @Test - public void testBoundsAsCompositesWithSliceRestrictionsAndOneClusteringColumn() throws InvalidRequestException + public void testboundsAsClusteringWithSliceRestrictionsAndOneClusteringColumn() throws InvalidRequestException { CFMetaData cfMetaData = newCFMetaData(1); @@ -148,85 +144,85 @@ public class PrimaryKeyRestrictionSetTest ByteBuffer value2 = ByteBufferUtil.bytes(2); Restriction slice = newSingleSlice(cfMetaData, 0, Bound.START, false, value1); - PrimaryKeyRestrictions restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator); + PrimaryKeyRestrictions restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator, false); restrictions = restrictions.mergeWith(slice); - List<Composite> bounds = restrictions.boundsAsComposites(Bound.START, QueryOptions.DEFAULT); + SortedSet<Slice.Bound> bounds = restrictions.boundsAsClustering(Bound.START, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value1, EOC.END); + assertStartBound(get(bounds, 0), false, value1); - bounds = restrictions.boundsAsComposites(Bound.END, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.END, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertEmptyComposite(bounds.get(0)); + assertEmptyEnd(get(bounds, 0)); slice = newSingleSlice(cfMetaData, 0, Bound.START, true, value1); - restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator); + restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator, false); restrictions = restrictions.mergeWith(slice); - bounds = restrictions.boundsAsComposites(Bound.START, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.START, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value1, EOC.NONE); + assertStartBound(get(bounds, 0), true, value1); - bounds = restrictions.boundsAsComposites(Bound.END, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.END, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertEmptyComposite(bounds.get(0)); + assertEmptyEnd(get(bounds, 0)); slice = newSingleSlice(cfMetaData, 0, Bound.END, true, value1); - restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator); + restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator, false); restrictions = restrictions.mergeWith(slice); - bounds = restrictions.boundsAsComposites(Bound.START, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.START, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertEmptyComposite(bounds.get(0)); + assertEmptyStart(get(bounds, 0)); - bounds = restrictions.boundsAsComposites(Bound.END, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.END, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value1, EOC.END); + assertEndBound(get(bounds, 0), true, value1); slice = newSingleSlice(cfMetaData, 0, Bound.END, false, value1); - restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator); + restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator, false); restrictions = restrictions.mergeWith(slice); - bounds = restrictions.boundsAsComposites(Bound.START, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.START, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertEmptyComposite(bounds.get(0)); + assertEmptyStart(get(bounds, 0)); - bounds = restrictions.boundsAsComposites(Bound.END, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.END, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value1, EOC.START); + assertEndBound(get(bounds, 0), false, value1); slice = newSingleSlice(cfMetaData, 0, Bound.START, false, value1); Restriction slice2 = newSingleSlice(cfMetaData, 0, Bound.END, false, value2); - restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator); + restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator, false); restrictions = restrictions.mergeWith(slice).mergeWith(slice2); - bounds = restrictions.boundsAsComposites(Bound.START, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.START, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value1, EOC.END); + assertStartBound(get(bounds, 0), false, value1); - bounds = restrictions.boundsAsComposites(Bound.END, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.END, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value2, EOC.START); + assertEndBound(get(bounds, 0), false, value2); slice = newSingleSlice(cfMetaData, 0, Bound.START, true, value1); slice2 = newSingleSlice(cfMetaData, 0, Bound.END, true, value2); - restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator); + restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator, false); restrictions = restrictions.mergeWith(slice).mergeWith(slice2); - bounds = restrictions.boundsAsComposites(Bound.START, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.START, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value1, EOC.NONE); + assertStartBound(get(bounds, 0), true, value1); - bounds = restrictions.boundsAsComposites(Bound.END, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.END, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value2, EOC.END); + assertEndBound(get(bounds, 0), true, value2); } /** * Test 'clustering_0 = 1 AND clustering_1 IN (1, 2, 3)' */ @Test - public void testBoundsAsCompositesWithEqAndInRestrictions() throws InvalidRequestException + public void testboundsAsClusteringWithEqAndInRestrictions() throws InvalidRequestException { CFMetaData cfMetaData = newCFMetaData(2); @@ -235,27 +231,27 @@ public class PrimaryKeyRestrictionSetTest ByteBuffer value3 = ByteBufferUtil.bytes(3); Restriction eq = newSingleEq(cfMetaData, 0, value1); Restriction in = newSingleIN(cfMetaData, 1, value1, value2, value3); - PrimaryKeyRestrictions restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator); + PrimaryKeyRestrictions restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator, false); restrictions = restrictions.mergeWith(eq).mergeWith(in); - List<Composite> bounds = restrictions.boundsAsComposites(Bound.START, QueryOptions.DEFAULT); + SortedSet<Slice.Bound> bounds = restrictions.boundsAsClustering(Bound.START, QueryOptions.DEFAULT); assertEquals(3, bounds.size()); - assertComposite(bounds.get(0), value1, value1, EOC.START); - assertComposite(bounds.get(1), value1, value2, EOC.START); - assertComposite(bounds.get(2), value1, value3, EOC.START); + assertStartBound(get(bounds, 0), true, value1, value1); + assertStartBound(get(bounds, 1), true, value1, value2); + assertStartBound(get(bounds, 2), true, value1, value3); - bounds = restrictions.boundsAsComposites(Bound.END, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.END, QueryOptions.DEFAULT); assertEquals(3, bounds.size()); - assertComposite(bounds.get(0), value1, value1, EOC.END); - assertComposite(bounds.get(1), value1, value2, EOC.END); - assertComposite(bounds.get(2), value1, value3, EOC.END); + assertEndBound(get(bounds, 0), true, value1, value1); + assertEndBound(get(bounds, 1), true, value1, value2); + assertEndBound(get(bounds, 2), true, value1, value3); } /** * Test equal and slice restrictions (e.g 'clustering_0 = 0 clustering_1 > 1') */ @Test - public void testBoundsAsCompositesWithEqAndSliceRestrictions() throws InvalidRequestException + public void testboundsAsClusteringWithEqAndSliceRestrictions() throws InvalidRequestException { CFMetaData cfMetaData = newCFMetaData(2); @@ -266,108 +262,108 @@ public class PrimaryKeyRestrictionSetTest Restriction eq = newSingleEq(cfMetaData, 0, value3); Restriction slice = newSingleSlice(cfMetaData, 1, Bound.START, false, value1); - PrimaryKeyRestrictions restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator); + PrimaryKeyRestrictions restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator, false); restrictions = restrictions.mergeWith(eq).mergeWith(slice); - List<Composite> bounds = restrictions.boundsAsComposites(Bound.START, QueryOptions.DEFAULT); + SortedSet<Slice.Bound> bounds = restrictions.boundsAsClustering(Bound.START, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value3, value1, EOC.END); + assertStartBound(get(bounds, 0), false, value3, value1); - bounds = restrictions.boundsAsComposites(Bound.END, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.END, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value3, EOC.END); + assertEndBound(get(bounds, 0), true, value3); slice = newSingleSlice(cfMetaData, 1, Bound.START, true, value1); - restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator); + restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator, false); restrictions = restrictions.mergeWith(eq).mergeWith(slice); - bounds = restrictions.boundsAsComposites(Bound.START, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.START, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value3, value1, EOC.NONE); + assertStartBound(get(bounds, 0), true, value3, value1); - bounds = restrictions.boundsAsComposites(Bound.END, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.END, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value3, EOC.END); + assertEndBound(get(bounds, 0), true, value3); slice = newSingleSlice(cfMetaData, 1, Bound.END, true, value1); - restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator); + restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator, false); restrictions = restrictions.mergeWith(eq).mergeWith(slice); - bounds = restrictions.boundsAsComposites(Bound.START, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.START, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value3, EOC.START); + assertStartBound(get(bounds, 0), true, value3); - bounds = restrictions.boundsAsComposites(Bound.END, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.END, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value3, value1, EOC.END); + assertEndBound(get(bounds, 0), true, value3, value1); slice = newSingleSlice(cfMetaData, 1, Bound.END, false, value1); - restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator); + restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator, false); restrictions = restrictions.mergeWith(eq).mergeWith(slice); - bounds = restrictions.boundsAsComposites(Bound.START, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.START, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value3, EOC.START); + assertStartBound(get(bounds, 0), true, value3); - bounds = restrictions.boundsAsComposites(Bound.END, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.END, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value3, value1, EOC.START); + assertEndBound(get(bounds, 0), false, value3, value1); slice = newSingleSlice(cfMetaData, 1, Bound.START, false, value1); Restriction slice2 = newSingleSlice(cfMetaData, 1, Bound.END, false, value2); - restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator); + restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator, false); restrictions = restrictions.mergeWith(eq).mergeWith(slice).mergeWith(slice2); - bounds = restrictions.boundsAsComposites(Bound.START, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.START, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value3, value1, EOC.END); + assertStartBound(get(bounds, 0), false, value3, value1); - bounds = restrictions.boundsAsComposites(Bound.END, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.END, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value3, value2, EOC.START); + assertEndBound(get(bounds, 0), false, value3, value2); slice = newSingleSlice(cfMetaData, 1, Bound.START, true, value1); slice2 = newSingleSlice(cfMetaData, 1, Bound.END, true, value2); - restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator); + restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator, false); restrictions = restrictions.mergeWith(eq).mergeWith(slice).mergeWith(slice2); - bounds = restrictions.boundsAsComposites(Bound.START, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.START, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value3, value1, EOC.NONE); + assertStartBound(get(bounds, 0), true, value3, value1); - bounds = restrictions.boundsAsComposites(Bound.END, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.END, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value3, value2, EOC.END); + assertEndBound(get(bounds, 0), true, value3, value2); } /** * Test '(clustering_0, clustering_1) = (1, 2)' with two clustering column */ @Test - public void testBoundsAsCompositesWithMultiEqRestrictions() throws InvalidRequestException + public void testboundsAsClusteringWithMultiEqRestrictions() throws InvalidRequestException { CFMetaData cfMetaData = newCFMetaData(2); ByteBuffer value1 = ByteBufferUtil.bytes(1); ByteBuffer value2 = ByteBufferUtil.bytes(2); Restriction eq = newMultiEq(cfMetaData, 0, value1, value2); - PrimaryKeyRestrictions restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator); + PrimaryKeyRestrictions restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator, false); restrictions = restrictions.mergeWith(eq); - List<Composite> bounds = restrictions.boundsAsComposites(Bound.START, QueryOptions.DEFAULT); + SortedSet<Slice.Bound> bounds = restrictions.boundsAsClustering(Bound.START, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value1, value2, EOC.START); + assertStartBound(get(bounds, 0), true, value1, value2); - bounds = restrictions.boundsAsComposites(Bound.END, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.END, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value1, value2, EOC.END); + assertEndBound(get(bounds, 0), true, value1, value2); } /** * Test '(clustering_0, clustering_1) IN ((1, 2), (2, 3))' with two clustering column */ @Test - public void testBoundsAsCompositesWithMultiInRestrictions() throws InvalidRequestException + public void testboundsAsClusteringWithMultiInRestrictions() throws InvalidRequestException { CFMetaData cfMetaData = newCFMetaData(2); @@ -375,25 +371,25 @@ public class PrimaryKeyRestrictionSetTest ByteBuffer value2 = ByteBufferUtil.bytes(2); ByteBuffer value3 = ByteBufferUtil.bytes(3); Restriction in = newMultiIN(cfMetaData, 0, asList(value1, value2), asList(value2, value3)); - PrimaryKeyRestrictions restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator); + PrimaryKeyRestrictions restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator, false); restrictions = restrictions.mergeWith(in); - List<Composite> bounds = restrictions.boundsAsComposites(Bound.START, QueryOptions.DEFAULT); + SortedSet<Slice.Bound> bounds = restrictions.boundsAsClustering(Bound.START, QueryOptions.DEFAULT); assertEquals(2, bounds.size()); - assertComposite(bounds.get(0), value1, value2, EOC.START); - assertComposite(bounds.get(1), value2, value3, EOC.START); + assertStartBound(get(bounds, 0), true, value1, value2); + assertStartBound(get(bounds, 1), true, value2, value3); - bounds = restrictions.boundsAsComposites(Bound.END, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.END, QueryOptions.DEFAULT); assertEquals(2, bounds.size()); - assertComposite(bounds.get(0), value1, value2, EOC.END); - assertComposite(bounds.get(1), value2, value3, EOC.END); + assertEndBound(get(bounds, 0), true, value1, value2); + assertEndBound(get(bounds, 1), true, value2, value3); } /** * Test multi-column slice restrictions (e.g '(clustering_0) > (1)') with only one clustering column */ @Test - public void testBoundsAsCompositesWithMultiSliceRestrictionsWithOneClusteringColumn() throws InvalidRequestException + public void testboundsAsClusteringWithMultiSliceRestrictionsWithOneClusteringColumn() throws InvalidRequestException { CFMetaData cfMetaData = newCFMetaData(1); @@ -401,85 +397,85 @@ public class PrimaryKeyRestrictionSetTest ByteBuffer value2 = ByteBufferUtil.bytes(2); Restriction slice = newMultiSlice(cfMetaData, 0, Bound.START, false, value1); - PrimaryKeyRestrictions restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator); + PrimaryKeyRestrictions restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator, false); restrictions = restrictions.mergeWith(slice); - List<Composite> bounds = restrictions.boundsAsComposites(Bound.START, QueryOptions.DEFAULT); + SortedSet<Slice.Bound> bounds = restrictions.boundsAsClustering(Bound.START, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value1, EOC.END); + assertStartBound(get(bounds, 0), false, value1); - bounds = restrictions.boundsAsComposites(Bound.END, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.END, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertEmptyComposite(bounds.get(0)); + assertEmptyEnd(get(bounds, 0)); slice = newMultiSlice(cfMetaData, 0, Bound.START, true, value1); - restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator); + restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator, false); restrictions = restrictions.mergeWith(slice); - bounds = restrictions.boundsAsComposites(Bound.START, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.START, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value1, EOC.NONE); + assertStartBound(get(bounds, 0), true, value1); - bounds = restrictions.boundsAsComposites(Bound.END, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.END, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertEmptyComposite(bounds.get(0)); + assertEmptyEnd(get(bounds, 0)); slice = newMultiSlice(cfMetaData, 0, Bound.END, true, value1); - restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator); + restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator, false); restrictions = restrictions.mergeWith(slice); - bounds = restrictions.boundsAsComposites(Bound.START, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.START, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertEmptyComposite(bounds.get(0)); + assertEmptyStart(get(bounds, 0)); - bounds = restrictions.boundsAsComposites(Bound.END, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.END, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value1, EOC.END); + assertEndBound(get(bounds, 0), true, value1); slice = newMultiSlice(cfMetaData, 0, Bound.END, false, value1); - restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator); + restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator, false); restrictions = restrictions.mergeWith(slice); - bounds = restrictions.boundsAsComposites(Bound.START, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.START, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertEmptyComposite(bounds.get(0)); + assertEmptyStart(get(bounds, 0)); - bounds = restrictions.boundsAsComposites(Bound.END, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.END, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value1, EOC.START); + assertEndBound(get(bounds, 0), false, value1); slice = newMultiSlice(cfMetaData, 0, Bound.START, false, value1); Restriction slice2 = newMultiSlice(cfMetaData, 0, Bound.END, false, value2); - restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator); + restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator, false); restrictions = restrictions.mergeWith(slice).mergeWith(slice2); - bounds = restrictions.boundsAsComposites(Bound.START, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.START, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value1, EOC.END); + assertStartBound(get(bounds, 0), false, value1); - bounds = restrictions.boundsAsComposites(Bound.END, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.END, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value2, EOC.START); + assertEndBound(get(bounds, 0), false, value2); slice = newMultiSlice(cfMetaData, 0, Bound.START, true, value1); slice2 = newMultiSlice(cfMetaData, 0, Bound.END, true, value2); - restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator); + restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator, false); restrictions = restrictions.mergeWith(slice).mergeWith(slice2); - bounds = restrictions.boundsAsComposites(Bound.START, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.START, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value1, EOC.NONE); + assertStartBound(get(bounds, 0), true, value1); - bounds = restrictions.boundsAsComposites(Bound.END, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.END, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value2, EOC.END); + assertEndBound(get(bounds, 0), true, value2); } /** * Test multi-column slice restrictions (e.g '(clustering_0, clustering_1) > (1, 2)') */ @Test - public void testBoundsAsCompositesWithMultiSliceRestrictionsWithTwoClusteringColumn() throws InvalidRequestException + public void testboundsAsClusteringWithMultiSliceRestrictionsWithTwoClusteringColumn() throws InvalidRequestException { CFMetaData cfMetaData = newCFMetaData(2); @@ -488,90 +484,90 @@ public class PrimaryKeyRestrictionSetTest // (clustering_0, clustering1) > (1, 2) Restriction slice = newMultiSlice(cfMetaData, 0, Bound.START, false, value1, value2); - PrimaryKeyRestrictions restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator); + PrimaryKeyRestrictions restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator, false); restrictions = restrictions.mergeWith(slice); - List<Composite> bounds = restrictions.boundsAsComposites(Bound.START, QueryOptions.DEFAULT); + SortedSet<Slice.Bound> bounds = restrictions.boundsAsClustering(Bound.START, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value1, value2, EOC.END); + assertStartBound(get(bounds, 0), false, value1, value2); - bounds = restrictions.boundsAsComposites(Bound.END, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.END, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertEmptyComposite(bounds.get(0)); + assertEmptyEnd(get(bounds, 0)); // (clustering_0, clustering1) >= (1, 2) slice = newMultiSlice(cfMetaData, 0, Bound.START, true, value1, value2); - restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator); + restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator, false); restrictions = restrictions.mergeWith(slice); - bounds = restrictions.boundsAsComposites(Bound.START, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.START, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value1, value2, EOC.NONE); + assertStartBound(get(bounds, 0), true, value1, value2); - bounds = restrictions.boundsAsComposites(Bound.END, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.END, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertEmptyComposite(bounds.get(0)); + assertEmptyEnd(get(bounds, 0)); // (clustering_0, clustering1) <= (1, 2) slice = newMultiSlice(cfMetaData, 0, Bound.END, true, value1, value2); - restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator); + restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator, false); restrictions = restrictions.mergeWith(slice); - bounds = restrictions.boundsAsComposites(Bound.START, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.START, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertEmptyComposite(bounds.get(0)); + assertEmptyStart(get(bounds, 0)); - bounds = restrictions.boundsAsComposites(Bound.END, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.END, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value1, value2, EOC.END); + assertEndBound(get(bounds, 0), true, value1, value2); // (clustering_0, clustering1) < (1, 2) slice = newMultiSlice(cfMetaData, 0, Bound.END, false, value1, value2); - restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator); + restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator, false); restrictions = restrictions.mergeWith(slice); - bounds = restrictions.boundsAsComposites(Bound.START, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.START, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertEmptyComposite(bounds.get(0)); + assertEmptyStart(get(bounds, 0)); - bounds = restrictions.boundsAsComposites(Bound.END, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.END, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value1, value2, EOC.START); + assertEndBound(get(bounds, 0), false, value1, value2); // (clustering_0, clustering1) > (1, 2) AND (clustering_0) < (2) slice = newMultiSlice(cfMetaData, 0, Bound.START, false, value1, value2); Restriction slice2 = newMultiSlice(cfMetaData, 0, Bound.END, false, value2); - restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator); + restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator, false); restrictions = restrictions.mergeWith(slice).mergeWith(slice2); - bounds = restrictions.boundsAsComposites(Bound.START, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.START, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value1, value2, EOC.END); + assertStartBound(get(bounds, 0), false, value1, value2); - bounds = restrictions.boundsAsComposites(Bound.END, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.END, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value2, EOC.START); + assertEndBound(get(bounds, 0), false, value2); // (clustering_0, clustering1) >= (1, 2) AND (clustering_0, clustering1) <= (2, 1) slice = newMultiSlice(cfMetaData, 0, Bound.START, true, value1, value2); slice2 = newMultiSlice(cfMetaData, 0, Bound.END, true, value2, value1); - restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator); + restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator, false); restrictions = restrictions.mergeWith(slice).mergeWith(slice2); - bounds = restrictions.boundsAsComposites(Bound.START, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.START, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value1, value2, EOC.NONE); + assertStartBound(get(bounds, 0), true, value1, value2); - bounds = restrictions.boundsAsComposites(Bound.END, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.END, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value2, value1, EOC.END); + assertEndBound(get(bounds, 0), true, value2, value1); } /** * Test mixing single and multi equals restrictions (e.g. clustering_0 = 1 AND (clustering_1, clustering_2) = (2, 3)) */ @Test - public void testBoundsAsCompositesWithSingleEqAndMultiEqRestrictions() throws InvalidRequestException + public void testboundsAsClusteringWithSingleEqAndMultiEqRestrictions() throws InvalidRequestException { CFMetaData cfMetaData = newCFMetaData(4); @@ -583,67 +579,67 @@ public class PrimaryKeyRestrictionSetTest // clustering_0 = 1 AND (clustering_1, clustering_2) = (2, 3) Restriction singleEq = newSingleEq(cfMetaData, 0, value1); Restriction multiEq = newMultiEq(cfMetaData, 1, value2, value3); - PrimaryKeyRestrictions restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator); + PrimaryKeyRestrictions restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator, false); restrictions = restrictions.mergeWith(singleEq).mergeWith(multiEq); - List<Composite> bounds = restrictions.boundsAsComposites(Bound.START, QueryOptions.DEFAULT); + SortedSet<Slice.Bound> bounds = restrictions.boundsAsClustering(Bound.START, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value1, value2, value3, EOC.START); + assertStartBound(get(bounds, 0), true, value1, value2, value3); - bounds = restrictions.boundsAsComposites(Bound.END, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.END, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value1, value2, value3, EOC.END); + assertEndBound(get(bounds, 0), true, value1, value2, value3); // clustering_0 = 1 AND clustering_1 = 2 AND (clustering_2, clustering_3) = (3, 4) singleEq = newSingleEq(cfMetaData, 0, value1); Restriction singleEq2 = newSingleEq(cfMetaData, 1, value2); multiEq = newMultiEq(cfMetaData, 2, value3, value4); - restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator); + restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator, false); restrictions = restrictions.mergeWith(singleEq).mergeWith(singleEq2).mergeWith(multiEq); - bounds = restrictions.boundsAsComposites(Bound.START, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.START, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value1, value2, value3, value4, EOC.START); + assertStartBound(get(bounds, 0), true, value1, value2, value3, value4); - bounds = restrictions.boundsAsComposites(Bound.END, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.END, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value1, value2, value3, value4, EOC.END); + assertEndBound(get(bounds, 0), true, value1, value2, value3, value4); // (clustering_0, clustering_1) = (1, 2) AND clustering_2 = 3 singleEq = newSingleEq(cfMetaData, 2, value3); multiEq = newMultiEq(cfMetaData, 0, value1, value2); - restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator); + restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator, false); restrictions = restrictions.mergeWith(singleEq).mergeWith(multiEq); - bounds = restrictions.boundsAsComposites(Bound.START, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.START, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value1, value2, value3, EOC.START); + assertStartBound(get(bounds, 0), true, value1, value2, value3); - bounds = restrictions.boundsAsComposites(Bound.END, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.END, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value1, value2, value3, EOC.END); + assertEndBound(get(bounds, 0), true, value1, value2, value3); // clustering_0 = 1 AND (clustering_1, clustering_2) = (2, 3) AND clustering_3 = 4 singleEq = newSingleEq(cfMetaData, 0, value1); singleEq2 = newSingleEq(cfMetaData, 3, value4); multiEq = newMultiEq(cfMetaData, 1, value2, value3); - restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator); + restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator, false); restrictions = restrictions.mergeWith(singleEq).mergeWith(multiEq).mergeWith(singleEq2); - bounds = restrictions.boundsAsComposites(Bound.START, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.START, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value1, value2, value3, value4, EOC.START); + assertStartBound(get(bounds, 0), true, value1, value2, value3, value4); - bounds = restrictions.boundsAsComposites(Bound.END, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.END, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value1, value2, value3, value4, EOC.END); + assertEndBound(get(bounds, 0), true, value1, value2, value3, value4); } /** * Test clustering_0 = 1 AND (clustering_1, clustering_2) IN ((2, 3), (4, 5)) */ @Test - public void testBoundsAsCompositesWithSingleEqAndMultiINRestrictions() throws InvalidRequestException + public void testboundsAsClusteringWithSingleEqAndMultiINRestrictions() throws InvalidRequestException { CFMetaData cfMetaData = newCFMetaData(4); @@ -656,49 +652,49 @@ public class PrimaryKeyRestrictionSetTest // clustering_0 = 1 AND (clustering_1, clustering_2) IN ((2, 3), (4, 5)) Restriction singleEq = newSingleEq(cfMetaData, 0, value1); Restriction multiIN = newMultiIN(cfMetaData, 1, asList(value2, value3), asList(value4, value5)); - PrimaryKeyRestrictions restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator); + PrimaryKeyRestrictions restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator, false); restrictions = restrictions.mergeWith(singleEq).mergeWith(multiIN); - List<Composite> bounds = restrictions.boundsAsComposites(Bound.START, QueryOptions.DEFAULT); + SortedSet<Slice.Bound> bounds = restrictions.boundsAsClustering(Bound.START, QueryOptions.DEFAULT); assertEquals(2, bounds.size()); - assertComposite(bounds.get(0), value1, value2, value3, EOC.START); - assertComposite(bounds.get(1), value1, value4, value5, EOC.START); + assertStartBound(get(bounds, 0), true, value1, value2, value3); + assertStartBound(get(bounds, 1), true, value1, value4, value5); - bounds = restrictions.boundsAsComposites(Bound.END, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.END, QueryOptions.DEFAULT); assertEquals(2, bounds.size()); - assertComposite(bounds.get(0), value1, value2, value3, EOC.END); - assertComposite(bounds.get(1), value1, value4, value5, EOC.END); + assertEndBound(get(bounds, 0), true, value1, value2, value3); + assertEndBound(get(bounds, 1), true, value1, value4, value5); // clustering_0 = 1 AND (clustering_1, clustering_2) IN ((2, 3)) singleEq = newSingleEq(cfMetaData, 0, value1); multiIN = newMultiIN(cfMetaData, 1, asList(value2, value3)); - restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator); + restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator, false); restrictions = restrictions.mergeWith(multiIN).mergeWith(singleEq); - bounds = restrictions.boundsAsComposites(Bound.START, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.START, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value1, value2, value3, EOC.START); + assertStartBound(get(bounds, 0), true, value1, value2, value3); - bounds = restrictions.boundsAsComposites(Bound.END, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.END, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value1, value2, value3, EOC.END); + assertEndBound(get(bounds, 0), true, value1, value2, value3); // clustering_0 = 1 AND clustering_1 = 5 AND (clustering_2, clustering_3) IN ((2, 3), (4, 5)) singleEq = newSingleEq(cfMetaData, 0, value1); Restriction singleEq2 = newSingleEq(cfMetaData, 1, value5); multiIN = newMultiIN(cfMetaData, 2, asList(value2, value3), asList(value4, value5)); - restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator); + restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator, false); restrictions = restrictions.mergeWith(singleEq).mergeWith(multiIN).mergeWith(singleEq2); - bounds = restrictions.boundsAsComposites(Bound.START, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.START, QueryOptions.DEFAULT); assertEquals(2, bounds.size()); - assertComposite(bounds.get(0), value1, value5, value2, value3, EOC.START); - assertComposite(bounds.get(1), value1, value5, value4, value5, EOC.START); + assertStartBound(get(bounds, 0), true, value1, value5, value2, value3); + assertStartBound(get(bounds, 1), true, value1, value5, value4, value5); - bounds = restrictions.boundsAsComposites(Bound.END, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.END, QueryOptions.DEFAULT); assertEquals(2, bounds.size()); - assertComposite(bounds.get(0), value1, value5, value2, value3, EOC.END); - assertComposite(bounds.get(1), value1, value5, value4, value5, EOC.END); + assertEndBound(get(bounds, 0), true, value1, value5, value2, value3); + assertEndBound(get(bounds, 1), true, value1, value5, value4, value5); } /** @@ -706,7 +702,7 @@ public class PrimaryKeyRestrictionSetTest * (e.g. clustering_0 = 1 AND (clustering_1, clustering_2) > (2, 3)) */ @Test - public void testBoundsAsCompositesWithSingleEqAndSliceRestrictions() throws InvalidRequestException + public void testboundsAsClusteringWithSingleEqAndSliceRestrictions() throws InvalidRequestException { CFMetaData cfMetaData = newCFMetaData(3); @@ -719,46 +715,46 @@ public class PrimaryKeyRestrictionSetTest // clustering_0 = 1 AND (clustering_1, clustering_2) > (2, 3) Restriction singleEq = newSingleEq(cfMetaData, 0, value1); Restriction multiSlice = newMultiSlice(cfMetaData, 1, Bound.START, false, value2, value3); - PrimaryKeyRestrictions restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator); + PrimaryKeyRestrictions restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator, false); restrictions = restrictions.mergeWith(singleEq).mergeWith(multiSlice); - List<Composite> bounds = restrictions.boundsAsComposites(Bound.START, QueryOptions.DEFAULT); + SortedSet<Slice.Bound> bounds = restrictions.boundsAsClustering(Bound.START, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value1, value2, value3, EOC.END); + assertStartBound(get(bounds, 0), false, value1, value2, value3); - bounds = restrictions.boundsAsComposites(Bound.END, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.END, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value1, EOC.END); + assertEndBound(get(bounds, 0), true, value1); // clustering_0 = 1 AND (clustering_1, clustering_2) > (2, 3) AND (clustering_1) < (4) singleEq = newSingleEq(cfMetaData, 0, value1); multiSlice = newMultiSlice(cfMetaData, 1, Bound.START, false, value2, value3); Restriction multiSlice2 = newMultiSlice(cfMetaData, 1, Bound.END, false, value4); - restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator); + restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator, false); restrictions = restrictions.mergeWith(multiSlice2).mergeWith(singleEq).mergeWith(multiSlice); - bounds = restrictions.boundsAsComposites(Bound.START, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.START, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value1, value2, value3, EOC.END); + assertStartBound(get(bounds, 0), false, value1, value2, value3); - bounds = restrictions.boundsAsComposites(Bound.END, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.END, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value1, value4, EOC.START); + assertEndBound(get(bounds, 0), false, value1, value4); // clustering_0 = 1 AND (clustering_1, clustering_2) => (2, 3) AND (clustering_1, clustering_2) <= (4, 5) singleEq = newSingleEq(cfMetaData, 0, value1); multiSlice = newMultiSlice(cfMetaData, 1, Bound.START, true, value2, value3); multiSlice2 = newMultiSlice(cfMetaData, 1, Bound.END, true, value4, value5); - restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator); + restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator, false); restrictions = restrictions.mergeWith(multiSlice2).mergeWith(singleEq).mergeWith(multiSlice); - bounds = restrictions.boundsAsComposites(Bound.START, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.START, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value1, value2, value3, EOC.NONE); + assertStartBound(get(bounds, 0), true, value1, value2, value3); - bounds = restrictions.boundsAsComposites(Bound.END, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.END, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value1, value4, value5, EOC.END); + assertEndBound(get(bounds, 0), true, value1, value4, value5); } /** @@ -766,7 +762,7 @@ public class PrimaryKeyRestrictionSetTest * (e.g. clustering_0 = 1 AND (clustering_1, clustering_2) > (2, 3)) */ @Test - public void testBoundsAsCompositesWithMultiEqAndSingleSliceRestrictions() throws InvalidRequestException + public void testboundsAsClusteringWithMultiEqAndSingleSliceRestrictions() throws InvalidRequestException { CFMetaData cfMetaData = newCFMetaData(3); @@ -777,20 +773,20 @@ public class PrimaryKeyRestrictionSetTest // (clustering_0, clustering_1) = (1, 2) AND clustering_2 > 3 Restriction multiEq = newMultiEq(cfMetaData, 0, value1, value2); Restriction singleSlice = newSingleSlice(cfMetaData, 2, Bound.START, false, value3); - PrimaryKeyRestrictions restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator); + PrimaryKeyRestrictions restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator, false); restrictions = restrictions.mergeWith(multiEq).mergeWith(singleSlice); - List<Composite> bounds = restrictions.boundsAsComposites(Bound.START, QueryOptions.DEFAULT); + SortedSet<Slice.Bound> bounds = restrictions.boundsAsClustering(Bound.START, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value1, value2, value3, EOC.END); + assertStartBound(get(bounds, 0), false, value1, value2, value3); - bounds = restrictions.boundsAsComposites(Bound.END, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.END, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value1, value2, EOC.END); + assertEndBound(get(bounds, 0), true, value1, value2); } @Test - public void testBoundsAsCompositesWithSeveralMultiColumnRestrictions() throws InvalidRequestException + public void testboundsAsClusteringWithSeveralMultiColumnRestrictions() throws InvalidRequestException { CFMetaData cfMetaData = newCFMetaData(4); @@ -803,142 +799,106 @@ public class PrimaryKeyRestrictionSetTest // (clustering_0, clustering_1) = (1, 2) AND (clustering_2, clustering_3) > (3, 4) Restriction multiEq = newMultiEq(cfMetaData, 0, value1, value2); Restriction multiSlice = newMultiSlice(cfMetaData, 2, Bound.START, false, value3, value4); - PrimaryKeyRestrictions restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator); + PrimaryKeyRestrictions restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator, false); restrictions = restrictions.mergeWith(multiEq).mergeWith(multiSlice); - List<Composite> bounds = restrictions.boundsAsComposites(Bound.START, QueryOptions.DEFAULT); + SortedSet<Slice.Bound> bounds = restrictions.boundsAsClustering(Bound.START, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value1, value2, value3, value4, EOC.END); + assertStartBound(get(bounds, 0), false, value1, value2, value3, value4); - bounds = restrictions.boundsAsComposites(Bound.END, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.END, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value1, value2, EOC.END); + assertEndBound(get(bounds, 0), true, value1, value2); // (clustering_0, clustering_1) = (1, 2) AND (clustering_2, clustering_3) IN ((3, 4), (4, 5)) multiEq = newMultiEq(cfMetaData, 0, value1, value2); Restriction multiIN = newMultiIN(cfMetaData, 2, asList(value3, value4), asList(value4, value5)); - restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator); + restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator, false); restrictions = restrictions.mergeWith(multiEq).mergeWith(multiIN); - bounds = restrictions.boundsAsComposites(Bound.START, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.START, QueryOptions.DEFAULT); assertEquals(2, bounds.size()); - assertComposite(bounds.get(0), value1, value2, value3, value4, EOC.START); - assertComposite(bounds.get(1), value1, value2, value4, value5, EOC.START); + assertStartBound(get(bounds, 0), true, value1, value2, value3, value4); + assertStartBound(get(bounds, 1), true, value1, value2, value4, value5); - bounds = restrictions.boundsAsComposites(Bound.END, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.END, QueryOptions.DEFAULT); assertEquals(2, bounds.size()); - assertComposite(bounds.get(0), value1, value2, value3, value4, EOC.END); - assertComposite(bounds.get(1), value1, value2, value4, value5, EOC.END); + assertEndBound(get(bounds, 0), true, value1, value2, value3, value4); + assertEndBound(get(bounds, 1), true, value1, value2, value4, value5); // (clustering_0, clustering_1) = (1, 2) AND (clustering_2, clustering_3) = (3, 4) multiEq = newMultiEq(cfMetaData, 0, value1, value2); Restriction multiEq2 = newMultiEq(cfMetaData, 2, value3, value4); - restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator); + restrictions = new PrimaryKeyRestrictionSet(cfMetaData.comparator, false); restrictions = restrictions.mergeWith(multiEq).mergeWith(multiEq2); - bounds = restrictions.boundsAsComposites(Bound.START, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.START, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value1, value2, value3, value4, EOC.START); + assertStartBound(get(bounds, 0), true, value1, value2, value3, value4); - bounds = restrictions.boundsAsComposites(Bound.END, QueryOptions.DEFAULT); + bounds = restrictions.boundsAsClustering(Bound.END, QueryOptions.DEFAULT); assertEquals(1, bounds.size()); - assertComposite(bounds.get(0), value1, value2, value3, value4, EOC.END); + assertEndBound(get(bounds, 0), true, value1, value2, value3, value4); } /** - * Asserts that the specified <code>Composite</code> is an empty one. + * Asserts that the specified <code>Bound</code> is an empty start. * - * @param composite the composite to check + * @param bound the bound to check */ - private static void assertEmptyComposite(Composite composite) + private static void assertEmptyStart(Slice.Bound bound) { - assertEquals(Composites.EMPTY, composite); + assertEquals(Slice.Bound.BOTTOM, bound); } /** - * Asserts that the specified <code>Composite</code> contains the specified element and the specified EOC. + * Asserts that the specified <code>Bound</code> is an empty end. * - * @param composite the composite to check - * @param element the expected element of the composite - * @param eoc the expected EOC of the composite + * @param bound the bound to check */ - private static void assertComposite(Composite composite, ByteBuffer element, EOC eoc) + private static void assertEmptyEnd(Slice.Bound bound) { - assertComposite(composite, eoc, element); + assertEquals(Slice.Bound.TOP, bound); } /** - * Asserts that the specified <code>Composite</code> contains the 2 specified element and the specified EOC. + * Asserts that the specified <code>Slice.Bound</code> is a start with the specified elements. * - * @param composite the composite to check - * @param eoc the expected EOC of the composite - * @param elements the expected element of the composite + * @param bound the bound to check + * @param isInclusive if the bound is expected to be inclusive + * @param elements the expected elements of the clustering */ - private static void assertComposite(Composite composite, ByteBuffer firstElement, ByteBuffer secondElement, EOC eoc) + private static void assertStartBound(Slice.Bound bound, boolean isInclusive, ByteBuffer... elements) { - assertComposite(composite, eoc, firstElement, secondElement); + assertBound(bound, true, isInclusive, elements); } /** - * Asserts that the specified <code>Composite</code> contains the 3 specified element and the specified EOC. + * Asserts that the specified <code>Slice.Bound</code> is a end with the specified elements. * - * @param composite the composite to check - * @param firstElement the first expected element of the composite - * @param secondElement the second expected element of the composite - * @param thirdElement the third expected element of the composite - * @param eoc the expected EOC of the composite - * @param elements the expected element of the composite + * @param bound the bound to check + * @param isInclusive if the bound is expected to be inclusive + * @param elements the expected elements of the clustering */ - private static void assertComposite(Composite composite, - ByteBuffer firstElement, - ByteBuffer secondElement, - ByteBuffer thirdElement, - EOC eoc) + private static void assertEndBound(Slice.Bound bound, boolean isInclusive, ByteBuffer... elements) { - assertComposite(composite, eoc, firstElement, secondElement, thirdElement); + assertBound(bound, false, isInclusive, elements); } - /** - * Asserts that the specified <code>Composite</code> contains the 4 specified element and the specified EOC. - * - * @param composite the composite to check - * @param firstElement the first expected element of the composite - * @param secondElement the second expected element of the composite - * @param thirdElement the third expected element of the composite - * @param fourthElement the fourth expected element of the composite - * @param eoc the expected EOC of the composite - * @param elements the expected element of the composite - */ - private static void assertComposite(Composite composite, - ByteBuffer firstElement, - ByteBuffer secondElement, - ByteBuffer thirdElement, - ByteBuffer fourthElement, - EOC eoc) + private static void assertBound(Slice.Bound bound, boolean isStart, boolean isInclusive, ByteBuffer... elements) { - assertComposite(composite, eoc, firstElement, secondElement, thirdElement, fourthElement); - } - - /** - * Asserts that the specified <code>Composite</code> contains the specified elements and EOC. - * - * @param composite the composite to check - * @param eoc the expected EOC of the composite - * @param elements the expected elements of the composite - */ - private static void assertComposite(Composite composite, EOC eoc, ByteBuffer... elements) - { - assertEquals("the composite size is not the expected one:", elements.length, composite.size()); + assertEquals("the bound size is not the expected one:", elements.length, bound.size()); + assertEquals("the bound should be a " + (isStart ? "start" : "end") + " but is a " + (bound.isStart() ? "start" : "end"), isStart, bound.isStart()); + assertEquals("the bound inclusiveness is not the expected one", isInclusive, bound.isInclusive()); for (int i = 0, m = elements.length; i < m; i++) { ByteBuffer element = elements[i]; - assertTrue(String.format("the element %s of the composite is not the expected one: expected %s but was %s", + assertTrue(String.format("the element %s of the bound is not the expected one: expected %s but was %s", i, ByteBufferUtil.toInt(element), - ByteBufferUtil.toInt(composite.get(i))), - element.equals(composite.get(i))); + ByteBufferUtil.toInt(bound.get(i))), + element.equals(bound.get(i))); } - assertEquals("the EOC of the composite is not the expected one:", eoc, composite.eoc()); } /** @@ -954,17 +914,13 @@ public class PrimaryKeyRestrictionSetTest for (int i = 0; i < numberOfClusteringColumns; i++) types.add(Int32Type.instance); - CompoundSparseCellNameType cType = new CompoundSparseCellNameType(types); - CFMetaData cfMetaData = new CFMetaData("keyspace", "test", ColumnFamilyType.Standard, cType); + CFMetaData.Builder builder = CFMetaData.Builder.create("keyspace", "test") + .addPartitionKey("partition_key", Int32Type.instance); for (int i = 0; i < numberOfClusteringColumns; i++) - { - ByteBuffer name = ByteBufferUtil.bytes("clustering_" + i); - ColumnDefinition columnDef = ColumnDefinition.clusteringKeyDef(cfMetaData, name, Int32Type.instance, i); - cfMetaData.addColumnDefinition(columnDef); - } - cfMetaData.rebuild(); - return cfMetaData; + builder.addClusteringColumn("clustering_" + i, Int32Type.instance); + + return builder.build(); } /** @@ -978,7 +934,7 @@ public class PrimaryKeyRestrictionSetTest private static Restriction newSingleEq(CFMetaData cfMetaData, int index, ByteBuffer value) { ColumnDefinition columnDef = getClusteringColumnDefinition(cfMetaData, index); - return new SingleColumnRestriction.EQ(columnDef, toTerm(value)); + return new SingleColumnRestriction.EQRestriction(columnDef, toTerm(value)); } /** @@ -996,7 +952,7 @@ public class PrimaryKeyRestrictionSetTest { columnDefinitions.add(getClusteringColumnDefinition(cfMetaData, firstIndex + i)); } - return new MultiColumnRestriction.EQ(columnDefinitions, toMultiItemTerminal(values)); + return new MultiColumnRestriction.EQRestriction(columnDefinitions, toMultiItemTerminal(values)); } /** @@ -1017,7 +973,7 @@ public class PrimaryKeyRestrictionSetTest columnDefinitions.add(getClusteringColumnDefinition(cfMetaData, firstIndex + i)); terms.add(toMultiItemTerminal(values[i].toArray(new ByteBuffer[0]))); } - return new MultiColumnRestriction.InWithValues(columnDefinitions, terms); + return new MultiColumnRestriction.InRestrictionWithValues(columnDefinitions, terms); } /** @@ -1031,7 +987,7 @@ public class PrimaryKeyRestrictionSetTest private static Restriction newSingleIN(CFMetaData cfMetaData, int index, ByteBuffer... values) { ColumnDefinition columnDef = getClusteringColumnDefinition(cfMetaData, index); - return new SingleColumnRestriction.InWithValues(columnDef, toTerms(values)); + return new SingleColumnRestriction.InRestrictionWithValues(columnDef, toTerms(values)); } /** @@ -1059,7 +1015,7 @@ public class PrimaryKeyRestrictionSetTest private static Restriction newSingleSlice(CFMetaData cfMetaData, int index, Bound bound, boolean inclusive, ByteBuffer value) { ColumnDefinition columnDef = getClusteringColumnDefinition(cfMetaData, index); - return new SingleColumnRestriction.Slice(columnDef, bound, inclusive, toTerm(value)); + return new SingleColumnRestriction.SliceRestriction(columnDef, bound, inclusive, toTerm(value)); } /** @@ -1079,7 +1035,7 @@ public class PrimaryKeyRestrictionSetTest { columnDefinitions.add(getClusteringColumnDefinition(cfMetaData, i + firstIndex)); } - return new MultiColumnRestriction.Slice(columnDefinitions, bound, inclusive, toMultiItemTerminal(values)); + return new MultiColumnRestriction.SliceRestriction(columnDefinitions, bound, inclusive, toMultiItemTerminal(values)); } /** @@ -1117,4 +1073,9 @@ public class PrimaryKeyRestrictionSetTest terms.add(toTerm(value)); return terms; } + + private static <T> T get(SortedSet<T> set, int i) + { + return Iterables.get(set, i); + } }
http://git-wip-us.apache.org/repos/asf/cassandra/blob/a991b648/test/unit/org/apache/cassandra/cql3/validation/entities/CollectionsTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/CollectionsTest.java b/test/unit/org/apache/cassandra/cql3/validation/entities/CollectionsTest.java index 2e72c39..72f5ad5 100644 --- a/test/unit/org/apache/cassandra/cql3/validation/entities/CollectionsTest.java +++ b/test/unit/org/apache/cassandra/cql3/validation/entities/CollectionsTest.java @@ -237,7 +237,7 @@ public class CollectionsTest extends CQLTester assertInvalidMessage("Attempted to set an element on a list which is null", "UPDATE %s SET l[0] = ? WHERE k=0", list("v10")); - execute("UPDATE %s SET l = l - ? WHERE k=0 ", list("v11")); + execute("UPDATE %s SET l = l - ? WHERE k=0", list("v11")); assertRows(execute("SELECT l FROM %s WHERE k = 0"), row((Object) null)); } http://git-wip-us.apache.org/repos/asf/cassandra/blob/a991b648/test/unit/org/apache/cassandra/cql3/validation/entities/CountersTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/CountersTest.java b/test/unit/org/apache/cassandra/cql3/validation/entities/CountersTest.java index e5ff251..e54d105 100644 --- a/test/unit/org/apache/cassandra/cql3/validation/entities/CountersTest.java +++ b/test/unit/org/apache/cassandra/cql3/validation/entities/CountersTest.java @@ -59,8 +59,8 @@ public class CountersTest extends CQLTester @Test public void testRegularCounters() throws Throwable { - assertInvalidThrowMessage("Cannot add a non counter column", - ConfigurationException.class, + assertInvalidThrowMessage("Cannot mix counter and non counter columns in the same table", + InvalidRequestException.class, String.format("CREATE TABLE %s.%s (id bigint PRIMARY KEY, count counter, things set<text>)", KEYSPACE, createTableName())); } http://git-wip-us.apache.org/repos/asf/cassandra/blob/a991b648/test/unit/org/apache/cassandra/cql3/validation/entities/FrozenCollectionsTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/FrozenCollectionsTest.java b/test/unit/org/apache/cassandra/cql3/validation/entities/FrozenCollectionsTest.java index 857139d..c76d618 100644 --- a/test/unit/org/apache/cassandra/cql3/validation/entities/FrozenCollectionsTest.java +++ b/test/unit/org/apache/cassandra/cql3/validation/entities/FrozenCollectionsTest.java @@ -631,12 +631,9 @@ public class FrozenCollectionsTest extends CQLTester assertInvalidMessage("Cannot restrict clustering columns by a CONTAINS relation without a secondary index", "SELECT * FROM %s WHERE b CONTAINS ? ALLOW FILTERING", 1); - assertInvalidMessage("No secondary indexes on the restricted columns support the provided operator", + assertInvalidMessage("No supported secondary index found for the non primary key columns restrictions", "SELECT * FROM %s WHERE d CONTAINS KEY ?", 1); - assertInvalidMessage("No secondary indexes on the restricted columns support the provided operator", - "SELECT * FROM %s WHERE d CONTAINS KEY ? ALLOW FILTERING", 1); - assertInvalidMessage("Cannot restrict clustering columns by a CONTAINS relation without a secondary index", "SELECT * FROM %s WHERE b CONTAINS ? AND d CONTAINS KEY ? ALLOW FILTERING", 1, 1); @@ -747,6 +744,11 @@ public class FrozenCollectionsTest extends CQLTester row(0, list(1, 2, 3), set(1, 2, 3), map(1, "a")) ); + assertRows(execute("SELECT * FROM %s WHERE d CONTAINS KEY ? ALLOW FILTERING", 1), + row(0, list(1, 2, 3), set(1, 2, 3), map(1, "a")), + row(0, list(4, 5, 6), set(1, 2, 3), map(1, "a")) + ); + execute("DELETE d FROM %s WHERE a=? AND b=?", 0, list(1, 2, 3)); assertRows(execute("SELECT * FROM %s WHERE d=?", map(1, "a")), row(0, list(4, 5, 6), set(1, 2, 3), map(1, "a")) http://git-wip-us.apache.org/repos/asf/cassandra/blob/a991b648/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java b/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java index 0b812c6..2c30b70 100644 --- a/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java +++ b/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java @@ -97,7 +97,7 @@ public class SecondaryIndexTest extends CQLTester execute("DROP INDEX " + indexName); } - assertInvalidMessage("No secondary indexes on the restricted columns support the provided operators", + assertInvalidMessage("No supported secondary index found for the non primary key columns restrictions", "SELECT * FROM %s where b = ?", 1); dropIndex("DROP INDEX IF EXISTS " + indexName); assertInvalidMessage("Index '" + removeQuotes(indexName.toLowerCase(Locale.US)) + "' could not be found", "DROP INDEX " + indexName); @@ -484,23 +484,6 @@ public class SecondaryIndexTest extends CQLTester } @Test - public void testIndexOnClusteringColumnInsertPartitionKeyAndClusteringsOver64k() throws Throwable - { - createTable("CREATE TABLE %s(a blob, b blob, c blob, d int, PRIMARY KEY (a, b, c))"); - createIndex("CREATE INDEX ON %s(b)"); - - // CompositeIndexOnClusteringKey creates index entries composed of the - // PK plus all of the non-indexed clustering columns from the primary row - // so we should reject where len(a) + len(c) > 65560 as this will form the - // total clustering in the index table - ByteBuffer a = ByteBuffer.allocate(100); - ByteBuffer b = ByteBuffer.allocate(10); - ByteBuffer c = ByteBuffer.allocate(FBUtilities.MAX_UNSIGNED_SHORT - 99); - - failInsert("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, 0)", a, b, c); - } - - @Test public void testCompactTableWithValueOver64k() throws Throwable { createTable("CREATE TABLE %s(a int, b blob, PRIMARY KEY (a)) WITH COMPACT STORAGE"); @@ -509,40 +492,6 @@ public class SecondaryIndexTest extends CQLTester } @Test - public void testIndexOnCollectionValueInsertPartitionKeyAndCollectionKeyOver64k() throws Throwable - { - createTable("CREATE TABLE %s(a blob , b map<blob, int>, PRIMARY KEY (a))"); - createIndex("CREATE INDEX ON %s(b)"); - - // A collection key > 64k by itself will be rejected from - // the primary table. - // To test index validation we need to ensure that - // len(b) < 64k, but len(a) + len(b) > 64k as that will - // form the clustering in the index table - ByteBuffer a = ByteBuffer.allocate(100); - ByteBuffer b = ByteBuffer.allocate(FBUtilities.MAX_UNSIGNED_SHORT - 100); - - failInsert("UPDATE %s SET b[?] = 0 WHERE a = ?", b, a); - } - - @Test - public void testIndexOnCollectionKeyInsertPartitionKeyAndClusteringOver64k() throws Throwable - { - createTable("CREATE TABLE %s(a blob, b blob, c map<blob, int>, PRIMARY KEY (a, b))"); - createIndex("CREATE INDEX ON %s(KEYS(c))"); - - // Basically the same as the case with non-collection clustering - // CompositeIndexOnCollectionKeyy creates index entries composed of the - // PK plus all of the clustering columns from the primary row, except the - // collection element - which becomes the partition key in the index table - ByteBuffer a = ByteBuffer.allocate(100); - ByteBuffer b = ByteBuffer.allocate(FBUtilities.MAX_UNSIGNED_SHORT - 100); - ByteBuffer c = ByteBuffer.allocate(10); - - failInsert("UPDATE %s SET c[?] = 0 WHERE a = ? and b = ?", c, a, b); - } - - @Test public void testIndexOnPartitionKeyInsertValueOver64k() throws Throwable { createTable("CREATE TABLE %s(a int, b int, c blob, PRIMARY KEY ((a, b)))"); http://git-wip-us.apache.org/repos/asf/cassandra/blob/a991b648/test/unit/org/apache/cassandra/cql3/validation/entities/UFAuthTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/UFAuthTest.java b/test/unit/org/apache/cassandra/cql3/validation/entities/UFAuthTest.java index 498f0dd..ee20557 100644 --- a/test/unit/org/apache/cassandra/cql3/validation/entities/UFAuthTest.java +++ b/test/unit/org/apache/cassandra/cql3/validation/entities/UFAuthTest.java @@ -265,7 +265,7 @@ public class UFAuthTest extends CQLTester { setupTable("CREATE TABLE %s (k int, s int STATIC, v1 int, v2 int, PRIMARY KEY(k, v1))"); String functionName = createSimpleFunction(); - String cql = String.format("SELECT k FROM %s WHERE k = 0 AND s = %s", + String cql = String.format("SELECT k FROM %s WHERE k = 0 AND s = %s ALLOW FILTERING", KEYSPACE + "." + currentTable(), functionCall(functionName)); assertPermissionsOnFunction(cql, functionName); http://git-wip-us.apache.org/repos/asf/cassandra/blob/a991b648/test/unit/org/apache/cassandra/cql3/validation/entities/UFIdentificationTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/UFIdentificationTest.java b/test/unit/org/apache/cassandra/cql3/validation/entities/UFIdentificationTest.java index 28b8afc..8ab8a23 100644 --- a/test/unit/org/apache/cassandra/cql3/validation/entities/UFIdentificationTest.java +++ b/test/unit/org/apache/cassandra/cql3/validation/entities/UFIdentificationTest.java @@ -200,13 +200,13 @@ public class UFIdentificationTest extends CQLTester public void testSelectStatementSimpleRestrictions() throws Throwable { assertFunctions(cql("SELECT i_val FROM %s WHERE key=%s", functionCall(iFunc, "1")), iFunc); - assertFunctions(cql("SELECT i_val FROM %s WHERE key=0 AND t_sc=%s", functionCall(tFunc, "'foo'")), tFunc); - assertFunctions(cql("SELECT i_val FROM %s WHERE key=0 AND i_cc=%s AND t_cc='foo'", functionCall(iFunc, "1")), iFunc); - assertFunctions(cql("SELECT i_val FROM %s WHERE key=0 AND i_cc=0 AND t_cc=%s", functionCall(tFunc, "'foo'")), tFunc); + assertFunctions(cql("SELECT i_val FROM %s WHERE key=0 AND t_sc=%s ALLOW FILTERING", functionCall(tFunc, "'foo'")), tFunc); + assertFunctions(cql("SELECT i_val FROM %s WHERE key=0 AND i_cc=%s AND t_cc='foo' ALLOW FILTERING", functionCall(iFunc, "1")), iFunc); + assertFunctions(cql("SELECT i_val FROM %s WHERE key=0 AND i_cc=0 AND t_cc=%s ALLOW FILTERING", functionCall(tFunc, "'foo'")), tFunc); String iFunc2 = createEchoFunction("int"); String tFunc2 = createEchoFunction("text"); - assertFunctions(cql("SELECT i_val FROM %s WHERE key=%s AND t_sc=%s AND i_cc=%s AND t_cc=%s", + assertFunctions(cql("SELECT i_val FROM %s WHERE key=%s AND t_sc=%s AND i_cc=%s AND t_cc=%s ALLOW FILTERING", functionCall(iFunc, "1"), functionCall(tFunc, "'foo'"), functionCall(iFunc2, "1"), http://git-wip-us.apache.org/repos/asf/cassandra/blob/a991b648/test/unit/org/apache/cassandra/cql3/validation/entities/UFTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/UFTest.java b/test/unit/org/apache/cassandra/cql3/validation/entities/UFTest.java index 2e7c2f1..7bd208f 100644 --- a/test/unit/org/apache/cassandra/cql3/validation/entities/UFTest.java +++ b/test/unit/org/apache/cassandra/cql3/validation/entities/UFTest.java @@ -48,6 +48,7 @@ import org.apache.cassandra.dht.ByteOrderedPartitioner; import org.apache.cassandra.exceptions.FunctionExecutionException; import org.apache.cassandra.exceptions.InvalidRequestException; import org.apache.cassandra.service.ClientState; +import org.apache.cassandra.service.StorageService; import org.apache.cassandra.transport.Event; import org.apache.cassandra.transport.Server; import org.apache.cassandra.transport.messages.ResultMessage; @@ -59,7 +60,7 @@ public class UFTest extends CQLTester @BeforeClass public static void setUp() { - DatabaseDescriptor.setPartitioner(ByteOrderedPartitioner.instance); + StorageService.instance.setPartitionerUnsafe(ByteOrderedPartitioner.instance); } @Test http://git-wip-us.apache.org/repos/asf/cassandra/blob/a991b648/test/unit/org/apache/cassandra/cql3/validation/miscellaneous/CrcCheckChanceTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/cql3/validation/miscellaneous/CrcCheckChanceTest.java b/test/unit/org/apache/cassandra/cql3/validation/miscellaneous/CrcCheckChanceTest.java index 98d7d70..097a77d 100644 --- a/test/unit/org/apache/cassandra/cql3/validation/miscellaneous/CrcCheckChanceTest.java +++ b/test/unit/org/apache/cassandra/cql3/validation/miscellaneous/CrcCheckChanceTest.java @@ -69,8 +69,6 @@ public class CrcCheckChanceTest extends CQLTester row("p1", "k1", "sv1", "v1") ); - - //Write a few SSTables then Compact execute("INSERT INTO %s(p, c, v, s) values (?, ?, ?, ?)", "p1", "k1", "v1", "sv1"); @@ -143,7 +141,7 @@ public class CrcCheckChanceTest extends CQLTester } DatabaseDescriptor.setCompactionThroughputMbPerSec(1); - List<Future<?>> futures = CompactionManager.instance.submitMaximal(cfs, CompactionManager.getDefaultGcBefore(cfs), false); + List<Future<?>> futures = CompactionManager.instance.submitMaximal(cfs, CompactionManager.getDefaultGcBefore(cfs, FBUtilities.nowInSeconds()), false); execute("DROP TABLE %s"); try http://git-wip-us.apache.org/repos/asf/cassandra/blob/a991b648/test/unit/org/apache/cassandra/cql3/validation/miscellaneous/SSTableMetadataTrackingTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/cql3/validation/miscellaneous/SSTableMetadataTrackingTest.java b/test/unit/org/apache/cassandra/cql3/validation/miscellaneous/SSTableMetadataTrackingTest.java index 2a2ca7b..89f80f5 100644 --- a/test/unit/org/apache/cassandra/cql3/validation/miscellaneous/SSTableMetadataTrackingTest.java +++ b/test/unit/org/apache/cassandra/cql3/validation/miscellaneous/SSTableMetadataTrackingTest.java @@ -140,6 +140,7 @@ public class SSTableMetadataTrackingTest extends CQLTester assertEquals(metadata.minTimestamp, metadata2.minTimestamp); assertEquals(metadata.maxTimestamp, metadata2.maxTimestamp); } + @Test public void testTrackMetadata_rowMarkerDelete() throws Throwable { http://git-wip-us.apache.org/repos/asf/cassandra/blob/a991b648/test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java b/test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java index 95380f4..05f6c35 100644 --- a/test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java +++ b/test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java @@ -48,6 +48,7 @@ public class AlterTest extends CQLTester assertRows(execute("SELECT * FROM %s;"), row("test", "first test")); } + @Test public void testAddMap() throws Throwable { @@ -80,6 +81,7 @@ public class AlterTest extends CQLTester execute("UPDATE %s set myCollection = ['second element'] WHERE id = 'test';"); assertRows(execute("SELECT * FROM %s;"), row("test", "first test", list("second element"))); } + @Test public void testDropListAndAddMapWithSameName() throws Throwable {
