You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by bl...@apache.org on 2017/07/14 15:31:02 UTC
[2/7] cassandra git commit: Merge branch cassandra-2.2 into
cassandra-3.0
http://git-wip-us.apache.org/repos/asf/cassandra/blob/e2445cfb/test/unit/org/apache/cassandra/cql3/validation/operations/SelectLimitTest.java
----------------------------------------------------------------------
diff --cc test/unit/org/apache/cassandra/cql3/validation/operations/SelectLimitTest.java
index aeb3d56,0ffb799..7e90c0a
--- a/test/unit/org/apache/cassandra/cql3/validation/operations/SelectLimitTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/operations/SelectLimitTest.java
@@@ -26,14 -26,14 +26,15 @@@ import org.junit.Test
import org.apache.cassandra.config.DatabaseDescriptor;
import org.apache.cassandra.cql3.CQLTester;
import org.apache.cassandra.dht.ByteOrderedPartitioner;
--import org.apache.cassandra.exceptions.InvalidRequestException;
++import org.apache.cassandra.service.StorageService;
public class SelectLimitTest extends CQLTester
{
@BeforeClass
public static void setUp()
{
- DatabaseDescriptor.setPartitioner(ByteOrderedPartitioner.instance);
++ StorageService.instance.setPartitionerUnsafe(ByteOrderedPartitioner.instance);
+ DatabaseDescriptor.setPartitionerUnsafe(ByteOrderedPartitioner.instance);
}
/**
@@@ -125,43 -125,217 +126,296 @@@
row(1, 1),
row(1, 2),
row(1, 3));
+ assertRows(execute("SELECT * FROM %s WHERE v > 1 AND v <= 3 LIMIT 6 ALLOW FILTERING"),
+ row(0, 2),
+ row(0, 3),
+ row(1, 2),
+ row(1, 3),
+ row(2, 2),
+ row(2, 3));
+ }
- // strict bound (v > 1) over a range of partitions is not supported for compact storage if limit is provided
- assertInvalidThrow(InvalidRequestException.class, "SELECT * FROM %s WHERE v > 1 AND v <= 3 LIMIT 6 ALLOW FILTERING");
+ @Test
+ public void testLimitWithDeletedRowsAndStaticColumns() throws Throwable
+ {
+ createTable("CREATE TABLE %s (pk int, c int, v int, s int static, PRIMARY KEY (pk, c))");
+
+ execute("INSERT INTO %s (pk, c, v, s) VALUES (1, -1, 1, 1)");
+ execute("INSERT INTO %s (pk, c, v, s) VALUES (2, -1, 1, 1)");
+ execute("INSERT INTO %s (pk, c, v, s) VALUES (3, -1, 1, 1)");
+ execute("INSERT INTO %s (pk, c, v, s) VALUES (4, -1, 1, 1)");
+ execute("INSERT INTO %s (pk, c, v, s) VALUES (5, -1, 1, 1)");
+
+ assertRows(execute("SELECT * FROM %s"),
+ row(1, -1, 1, 1),
+ row(2, -1, 1, 1),
+ row(3, -1, 1, 1),
+ row(4, -1, 1, 1),
+ row(5, -1, 1, 1));
+
+ execute("DELETE FROM %s WHERE pk = 2");
+
+ assertRows(execute("SELECT * FROM %s"),
+ row(1, -1, 1, 1),
+ row(3, -1, 1, 1),
+ row(4, -1, 1, 1),
+ row(5, -1, 1, 1));
+
+ assertRows(execute("SELECT * FROM %s LIMIT 2"),
+ row(1, -1, 1, 1),
+ row(3, -1, 1, 1));
}
+
+ @Test
+ public void testFilteringOnClusteringColumnsWithLimitAndStaticColumns() throws Throwable
+ {
+ // With only one clustering column
+ createTable("CREATE TABLE %s (a int, b int, s int static, c int, primary key (a, b))"
+ + " WITH caching = {'keys': 'ALL', 'rows_per_partition' : 'ALL'}");
+
+ for (int i = 0; i < 4; i++)
+ {
+ execute("INSERT INTO %s (a, s) VALUES (?, ?)", i, i);
+ for (int j = 0; j < 3; j++)
+ if (!((i == 0 || i == 3) && j == 1))
+ execute("INSERT INTO %s (a, b, c) VALUES (?, ?, ?)", i, j, i + j);
+ }
+
- for (boolean forceFlush : new boolean[]{false, true})
++ beforeAndAfterFlush(() ->
+ {
- if (forceFlush)
- flush();
-
+ assertRows(execute("SELECT * FROM %s"),
+ row(0, 0, 0, 0),
+ row(0, 2, 0, 2),
+ row(1, 0, 1, 1),
+ row(1, 1, 1, 2),
+ row(1, 2, 1, 3),
+ row(2, 0, 2, 2),
+ row(2, 1, 2, 3),
+ row(2, 2, 2, 4),
+ row(3, 0, 3, 3),
+ row(3, 2, 3, 5));
+
+ assertRows(execute("SELECT * FROM %s WHERE b = 1 ALLOW FILTERING"),
+ row(1, 1, 1, 2),
+ row(2, 1, 2, 3));
+
+ // The problem was that the static row of the partition 0 used to be only filtered in SelectStatement and was
+ // by consequence counted as a row. In which case the query was returning one row less.
+ assertRows(execute("SELECT * FROM %s WHERE b = 1 LIMIT 2 ALLOW FILTERING"),
+ row(1, 1, 1, 2),
+ row(2, 1, 2, 3));
+
+ assertRows(execute("SELECT * FROM %s WHERE b >= 1 AND b <= 1 LIMIT 2 ALLOW FILTERING"),
+ row(1, 1, 1, 2),
+ row(2, 1, 2, 3));
+
+ // Test with paging
+ for (int pageSize = 1; pageSize < 4; pageSize++)
+ {
+ assertRowsNet(executeNetWithPaging("SELECT * FROM %s WHERE b = 1 LIMIT 2 ALLOW FILTERING", pageSize),
+ row(1, 1, 1, 2),
+ row(2, 1, 2, 3));
+
+ assertRowsNet(executeNetWithPaging("SELECT * FROM %s WHERE b >= 1 AND b <= 1 LIMIT 2 ALLOW FILTERING", pageSize),
+ row(1, 1, 1, 2),
+ row(2, 1, 2, 3));
+ }
- }
++ });
+
+ assertRows(execute("SELECT * FROM %s WHERE a IN (0, 1, 2, 3) AND b = 1 LIMIT 2 ALLOW FILTERING"),
+ row(1, 1, 1, 2),
+ row(2, 1, 2, 3));
+
+ assertRows(execute("SELECT * FROM %s WHERE a IN (0, 1, 2, 3) AND b >= 1 AND b <= 1 LIMIT 2 ALLOW FILTERING"),
+ row(1, 1, 1, 2),
+ row(2, 1, 2, 3));
+
+ assertRows(execute("SELECT * FROM %s WHERE a IN (0, 1, 2, 3) AND b = 1 ORDER BY b DESC LIMIT 2 ALLOW FILTERING"),
- row(2, 1, 2, 3),
- row(1, 1, 1, 2));
++ row(1, 1, 1, 2),
++ row(2, 1, 2, 3));
+
+ assertRows(execute("SELECT * FROM %s WHERE a IN (0, 1, 2, 3) AND b >= 1 AND b <= 1 ORDER BY b DESC LIMIT 2 ALLOW FILTERING"),
- row(2, 1, 2, 3),
- row(1, 1, 1, 2));
++ row(1, 1, 1, 2),
++ row(2, 1, 2, 3));
+
+ execute("SELECT * FROM %s WHERE a IN (0, 1, 2, 3)"); // Load all data in the row cache
+
++ // Partition range queries
+ assertRows(execute("SELECT * FROM %s WHERE b = 1 LIMIT 2 ALLOW FILTERING"),
+ row(1, 1, 1, 2),
+ row(2, 1, 2, 3));
+
+ assertRows(execute("SELECT * FROM %s WHERE b >= 1 AND b <= 1 LIMIT 2 ALLOW FILTERING"),
+ row(1, 1, 1, 2),
+ row(2, 1, 2, 3));
+
++ // Multiple partitions queries
++ assertRows(execute("SELECT * FROM %s WHERE a IN (0, 1, 2) AND b = 1 LIMIT 2 ALLOW FILTERING"),
++ row(1, 1, 1, 2),
++ row(2, 1, 2, 3));
++
++ assertRows(execute("SELECT * FROM %s WHERE a IN (0, 1, 2) AND b >= 1 AND b <= 1 LIMIT 2 ALLOW FILTERING"),
++ row(1, 1, 1, 2),
++ row(2, 1, 2, 3));
++
+ // Test with paging
+ for (int pageSize = 1; pageSize < 4; pageSize++)
+ {
+ assertRowsNet(executeNetWithPaging("SELECT * FROM %s WHERE b = 1 LIMIT 2 ALLOW FILTERING", pageSize),
+ row(1, 1, 1, 2),
+ row(2, 1, 2, 3));
+
+ assertRowsNet(executeNetWithPaging("SELECT * FROM %s WHERE b >= 1 AND b <= 1 LIMIT 2 ALLOW FILTERING", pageSize),
+ row(1, 1, 1, 2),
+ row(2, 1, 2, 3));
+ }
+
+ // With multiple clustering columns
+ createTable("CREATE TABLE %s (a int, b int, c int, s int static, d int, primary key (a, b, c))"
- + " WITH caching = {'keys': 'ALL', 'rows_per_partition' : 'ALL'}");
++ + " WITH caching = {'keys': 'ALL', 'rows_per_partition' : 'ALL'}");
+
+ for (int i = 0; i < 3; i++)
+ {
+ execute("INSERT INTO %s (a, s) VALUES (?, ?)", i, i);
- for (int j = 0; j < 3; j++)
- if (!(i == 0 && j == 1))
- execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", i, j, j, i + j);
++ for (int j = 0; j < 3; j++)
++ if (!(i == 0 && j == 1))
++ execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", i, j, j, i + j);
+ }
+
- for (boolean forceFlush : new boolean[]{false, true})
++ beforeAndAfterFlush(() ->
+ {
- if (forceFlush)
- flush();
-
+ assertRows(execute("SELECT * FROM %s"),
+ row(0, 0, 0, 0, 0),
+ row(0, 2, 2, 0, 2),
+ row(1, 0, 0, 1, 1),
+ row(1, 1, 1, 1, 2),
+ row(1, 2, 2, 1, 3),
+ row(2, 0, 0, 2, 2),
+ row(2, 1, 1, 2, 3),
+ row(2, 2, 2, 2, 4));
+
+ assertRows(execute("SELECT * FROM %s WHERE b = 1 ALLOW FILTERING"),
+ row(1, 1, 1, 1, 2),
+ row(2, 1, 1, 2, 3));
+
+ assertRows(execute("SELECT * FROM %s WHERE b IN (1, 2, 3, 4) AND c >= 1 AND c <= 1 LIMIT 2 ALLOW FILTERING"),
+ row(1, 1, 1, 1, 2),
+ row(2, 1, 1, 2, 3));
+
+ // Test with paging
+ for (int pageSize = 1; pageSize < 4; pageSize++)
+ {
+ assertRowsNet(executeNetWithPaging("SELECT * FROM %s WHERE b = 1 LIMIT 2 ALLOW FILTERING", pageSize),
+ row(1, 1, 1, 1, 2),
+ row(2, 1, 1, 2, 3));
+
+ assertRowsNet(executeNetWithPaging("SELECT * FROM %s WHERE b IN (1, 2, 3, 4) AND c >= 1 AND c <= 1 LIMIT 2 ALLOW FILTERING", pageSize),
+ row(1, 1, 1, 1, 2),
+ row(2, 1, 1, 2, 3));
+ }
- }
++ });
+
+ execute("SELECT * FROM %s WHERE a IN (0, 1, 2)"); // Load data in the row cache
+
+ assertRows(execute("SELECT * FROM %s WHERE b = 1 ALLOW FILTERING"),
+ row(1, 1, 1, 1, 2),
+ row(2, 1, 1, 2, 3));
+
+ assertRows(execute("SELECT * FROM %s WHERE b IN (1, 2, 3, 4) AND c >= 1 AND c <= 1 LIMIT 2 ALLOW FILTERING"),
+ row(1, 1, 1, 1, 2),
+ row(2, 1, 1, 2, 3));
+
++ assertRows(execute("SELECT * FROM %s WHERE a IN (1, 2, 3, 4) AND b = 1 ALLOW FILTERING"),
++ row(1, 1, 1, 1, 2),
++ row(2, 1, 1, 2, 3));
++
++ assertRows(execute("SELECT * FROM %s WHERE a IN (1, 2, 3, 4) AND b IN (1, 2, 3, 4) AND c >= 1 AND c <= 1 LIMIT 2 ALLOW FILTERING"),
++ row(1, 1, 1, 1, 2),
++ row(2, 1, 1, 2, 3));
++
+ // Test with paging
+ for (int pageSize = 1; pageSize < 4; pageSize++)
+ {
+ assertRowsNet(executeNetWithPaging("SELECT * FROM %s WHERE b = 1 LIMIT 2 ALLOW FILTERING", pageSize),
+ row(1, 1, 1, 1, 2),
+ row(2, 1, 1, 2, 3));
+
+ assertRowsNet(executeNetWithPaging("SELECT * FROM %s WHERE b IN (1, 2, 3, 4) AND c >= 1 AND c <= 1 LIMIT 2 ALLOW FILTERING", pageSize),
+ row(1, 1, 1, 1, 2),
+ row(2, 1, 1, 2, 3));
+ }
+ }
+
+ @Test
+ public void testIndexOnRegularColumnWithPartitionWithoutRows() throws Throwable
+ {
+ createTable("CREATE TABLE %s (pk int, c int, s int static, v int, PRIMARY KEY(pk, c))");
+ createIndex("CREATE INDEX ON %s (v)");
+
+ execute("INSERT INTO %s (pk, c, s, v) VALUES (?, ?, ?, ?)", 1, 1, 9, 1);
+ execute("INSERT INTO %s (pk, c, s, v) VALUES (?, ?, ?, ?)", 1, 2, 9, 2);
+ execute("INSERT INTO %s (pk, c, s, v) VALUES (?, ?, ?, ?)", 3, 1, 9, 1);
+ execute("INSERT INTO %s (pk, c, s, v) VALUES (?, ?, ?, ?)", 4, 1, 9, 1);
+ flush();
+
+ assertRows(execute("SELECT * FROM %s WHERE v = ?", 1),
+ row(1, 1, 9, 1),
+ row(3, 1, 9, 1),
+ row(4, 1, 9, 1));
+
- execute("DELETE FROM %s WHERE pk = ? AND c = ?", 3, 1);
++ execute("DELETE FROM %s WHERE pk = ? and c = ?", 3, 1);
+
+ // Test without paging
- assertRows(execute("SELECT * FROM %s WHERE v = ?", 1),
++ assertRows(execute("SELECT * FROM %s WHERE v = ? LIMIT 2", 1),
+ row(1, 1, 9, 1),
+ row(4, 1, 9, 1));
+
- assertRows(execute("SELECT * FROM %s WHERE v = ? LIMIT 2", 1),
++ // Test with paging
++ for (int pageSize = 1; pageSize < 4; pageSize++)
++ {
++ assertRowsNet(executeNetWithPaging("SELECT * FROM %s WHERE v = 1 LIMIT 2", pageSize),
++ row(1, 1, 9, 1),
++ row(4, 1, 9, 1));
++ }
++ }
++
++ @Test
++ public void testFilteringWithPartitionWithoutRows() throws Throwable
++ {
++ createTable("CREATE TABLE %s (pk int, c int, s int static, v int, PRIMARY KEY(pk, c))");
++
++ execute("INSERT INTO %s (pk, c, s, v) VALUES (?, ?, ?, ?)", 1, 1, 9, 1);
++ execute("INSERT INTO %s (pk, c, s, v) VALUES (?, ?, ?, ?)", 1, 2, 9, 2);
++ execute("INSERT INTO %s (pk, c, s, v) VALUES (?, ?, ?, ?)", 3, 1, 9, 1);
++ execute("INSERT INTO %s (pk, c, s, v) VALUES (?, ?, ?, ?)", 4, 1, 9, 1);
++ flush();
++
++ assertRows(execute("SELECT * FROM %s WHERE v = ? ALLOW FILTERING", 1),
++ row(1, 1, 9, 1),
++ row(3, 1, 9, 1),
++ row(4, 1, 9, 1));
++
++ execute("DELETE FROM %s WHERE pk = ? and c = ?", 3, 1);
++
++ // Test without paging
++ assertRows(execute("SELECT * FROM %s WHERE v = ? LIMIT 2 ALLOW FILTERING", 1),
++ row(1, 1, 9, 1),
++ row(4, 1, 9, 1));
++
++ assertRows(execute("SELECT * FROM %s WHERE pk IN ? AND v = ? LIMIT 2 ALLOW FILTERING", list(1, 3, 4), 1),
+ row(1, 1, 9, 1),
+ row(4, 1, 9, 1));
+
+ // Test with paging
+ for (int pageSize = 1; pageSize < 4; pageSize++)
+ {
- assertRowsNet(executeNetWithPaging("SELECT * FROM %s WHERE v = 1", pageSize),
++ assertRowsNet(executeNetWithPaging("SELECT * FROM %s WHERE v = 1 LIMIT 2 ALLOW FILTERING", pageSize),
+ row(1, 1, 9, 1),
+ row(4, 1, 9, 1));
+
- assertRowsNet(executeNetWithPaging("SELECT * FROM %s WHERE v = 1 LIMIT 2", pageSize),
++ assertRowsNet(executeNetWithPaging("SELECT * FROM %s WHERE pk IN (1, 3, 4) AND v = 1 LIMIT 2 ALLOW FILTERING", pageSize),
+ row(1, 1, 9, 1),
+ row(4, 1, 9, 1));
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/cassandra/blob/e2445cfb/test/unit/org/apache/cassandra/db/rows/UnfilteredRowIteratorsTest.java
----------------------------------------------------------------------
diff --cc test/unit/org/apache/cassandra/db/rows/UnfilteredRowIteratorsTest.java
index 43b9549,0000000..0387ba2
mode 100644,000000..100644
--- a/test/unit/org/apache/cassandra/db/rows/UnfilteredRowIteratorsTest.java
+++ b/test/unit/org/apache/cassandra/db/rows/UnfilteredRowIteratorsTest.java
@@@ -1,185 -1,0 +1,185 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cassandra.db.rows;
+
+import java.util.Arrays;
+import java.util.Iterator;
+
+import org.junit.Test;
+
+import junit.framework.Assert;
+import org.apache.cassandra.Util;
+import org.apache.cassandra.config.CFMetaData;
+import org.apache.cassandra.config.ColumnDefinition;
+import org.apache.cassandra.db.BufferDecoratedKey;
+import org.apache.cassandra.db.DecoratedKey;
+import org.apache.cassandra.db.DeletionTime;
+import org.apache.cassandra.db.EmptyIterators;
+import org.apache.cassandra.db.PartitionColumns;
+import org.apache.cassandra.db.filter.DataLimits;
+import org.apache.cassandra.db.marshal.Int32Type;
+import org.apache.cassandra.dht.Murmur3Partitioner;
+import org.apache.cassandra.utils.ByteBufferUtil;
+import org.apache.cassandra.utils.FBUtilities;
+
+public class UnfilteredRowIteratorsTest
+{
+ static final CFMetaData metadata;
+ static final ColumnDefinition v1Metadata;
+ static final ColumnDefinition v2Metadata;
+
+ static
+ {
+ metadata = CFMetaData.Builder.create("", "")
+ .addPartitionKey("pk", Int32Type.instance)
+ .addClusteringColumn("ck", Int32Type.instance)
+ .addRegularColumn("v1", Int32Type.instance)
+ .addRegularColumn("v2", Int32Type.instance)
+ .build();
+ v1Metadata = metadata.partitionColumns().columns(false).getSimple(0);
+ v2Metadata = metadata.partitionColumns().columns(false).getSimple(1);
+ }
+
+
+ @Test
+ public void concatTest()
+ {
+ UnfilteredRowIterator iter1, iter2, iter3, concat;
+ // simple concatenation
+ iter1 = rows(metadata.partitionColumns(), 1,
+ row(1, cell(v1Metadata, 1), cell(v2Metadata, 1)),
+ row(2, cell(v1Metadata, 2), cell(v2Metadata, 2)));
+ iter2 = rows(metadata.partitionColumns(), 1,
+ row(3, cell(v1Metadata, 3), cell(v2Metadata, 3)),
+ row(4, cell(v1Metadata, 4), cell(v2Metadata, 4)));
+ concat = UnfilteredRowIterators.concat(iter1, iter2);
+ Assert.assertEquals(concat.columns(), metadata.partitionColumns());
+ assertRows(concat,
+ row(1, cell(v1Metadata, 1), cell(v2Metadata, 1)),
+ row(2, cell(v1Metadata, 2), cell(v2Metadata, 2)),
+ row(3, cell(v1Metadata, 3), cell(v2Metadata, 3)),
+ row(4, cell(v1Metadata, 4), cell(v2Metadata, 4)));
+
+ // concat with RHS empty iterator
+ iter1 = rows(metadata.partitionColumns(), 1,
+ row(1, cell(v1Metadata, 1), cell(v2Metadata, 1)),
+ row(2, cell(v1Metadata, 2), cell(v2Metadata, 2)));
+ Assert.assertEquals(concat.columns(), metadata.partitionColumns());
+ assertRows(UnfilteredRowIterators.concat(iter1, EmptyIterators.unfilteredRow(metadata, dk(1), false, Rows.EMPTY_STATIC_ROW, DeletionTime.LIVE)),
+ row(1, cell(v1Metadata, 1), cell(v2Metadata, 1)),
+ row(2, cell(v1Metadata, 2), cell(v2Metadata, 2)));
+
+ // concat with LHS empty iterator
+ iter1 = rows(metadata.partitionColumns(), 1,
+ row(1, cell(v1Metadata, 1), cell(v2Metadata, 1)),
+ row(2, cell(v1Metadata, 2), cell(v2Metadata, 2)));
+ Assert.assertEquals(concat.columns(), metadata.partitionColumns());
+ assertRows(UnfilteredRowIterators.concat(EmptyIterators.unfilteredRow(metadata, dk(1), false, Rows.EMPTY_STATIC_ROW, DeletionTime.LIVE), iter1),
+ row(1, cell(v1Metadata, 1), cell(v2Metadata, 1)),
+ row(2, cell(v1Metadata, 2), cell(v2Metadata, 2)));
+
+ // concat with different columns
+ iter1 = rows(metadata.partitionColumns().without(v1Metadata), 1,
+ row(1, cell(v2Metadata, 1)), row(2, cell(v2Metadata, 2)));
+ iter2 = rows(metadata.partitionColumns().without(v2Metadata), 1,
+ row(3, cell(v1Metadata, 3)), row(4, cell(v1Metadata, 4)));
+ concat = UnfilteredRowIterators.concat(iter1, iter2);
+ Assert.assertEquals(concat.columns(), PartitionColumns.of(v1Metadata).mergeTo(PartitionColumns.of(v2Metadata)));
+ assertRows(concat,
+ row(1, cell(v2Metadata, 1)), row(2, cell(v2Metadata, 2)),
+ row(3, cell(v1Metadata, 3)), row(4, cell(v1Metadata, 4)));
+
+ // concat with CQL limits
+ iter1 = rows(metadata.partitionColumns(), 1,
+ row(1, cell(v1Metadata, 1), cell(v2Metadata, 1)),
+ row(2, cell(v1Metadata, 2), cell(v2Metadata, 2)));
+ iter2 = rows(metadata.partitionColumns(), 1,
+ row(3, cell(v1Metadata, 3), cell(v2Metadata, 3)),
+ row(4, cell(v1Metadata, 4), cell(v2Metadata, 4)));
- concat = UnfilteredRowIterators.concat(DataLimits.cqlLimits(1).filter(iter1, FBUtilities.nowInSeconds()),
- DataLimits.cqlLimits(1).filter(iter2, FBUtilities.nowInSeconds()));
++ concat = UnfilteredRowIterators.concat(DataLimits.cqlLimits(1).filter(iter1, FBUtilities.nowInSeconds(), true),
++ DataLimits.cqlLimits(1).filter(iter2, FBUtilities.nowInSeconds(), true));
+ Assert.assertEquals(concat.columns(), metadata.partitionColumns());
+ assertRows(concat,
+ row(1, cell(v1Metadata, 1), cell(v2Metadata, 1)),
+ row(3, cell(v1Metadata, 3), cell(v2Metadata, 3)));
+
+ // concat concatenated iterators
+ iter1 = rows(metadata.partitionColumns(), 1,
+ row(1, cell(v1Metadata, 1), cell(v2Metadata, 1)),
+ row(2, cell(v1Metadata, 2), cell(v2Metadata, 2)));
+ iter2 = rows(metadata.partitionColumns(), 1,
+ row(3, cell(v1Metadata, 3), cell(v2Metadata, 3)),
+ row(4, cell(v1Metadata, 4), cell(v2Metadata, 4)));
+
- concat = UnfilteredRowIterators.concat(DataLimits.cqlLimits(1).filter(iter1, FBUtilities.nowInSeconds()),
- DataLimits.cqlLimits(1).filter(iter2, FBUtilities.nowInSeconds()));
++ concat = UnfilteredRowIterators.concat(DataLimits.cqlLimits(1).filter(iter1, FBUtilities.nowInSeconds(), true),
++ DataLimits.cqlLimits(1).filter(iter2, FBUtilities.nowInSeconds(), true));
+
+ iter3 = rows(metadata.partitionColumns(), 1,
+ row(4, cell(v1Metadata, 4), cell(v2Metadata, 4)),
+ row(5, cell(v1Metadata, 5), cell(v2Metadata, 5)));
- concat = UnfilteredRowIterators.concat(concat, DataLimits.cqlLimits(1).filter(iter3, FBUtilities.nowInSeconds()));
++ concat = UnfilteredRowIterators.concat(concat, DataLimits.cqlLimits(1).filter(iter3, FBUtilities.nowInSeconds(), true));
+
+ Assert.assertEquals(concat.columns(), metadata.partitionColumns());
+ assertRows(concat,
+ row(1, cell(v1Metadata, 1), cell(v2Metadata, 1)),
+ row(3, cell(v1Metadata, 3), cell(v2Metadata, 3)),
+ row(4, cell(v1Metadata, 4), cell(v2Metadata, 4)));
+ }
+
+ public static void assertRows(UnfilteredRowIterator iterator, Row... rows)
+ {
+ Iterator<Row> rowsIterator = Arrays.asList(rows).iterator();
+
+ while (iterator.hasNext() && rowsIterator.hasNext())
+ Assert.assertEquals(iterator.next(), rowsIterator.next());
+
+ Assert.assertTrue(iterator.hasNext() == rowsIterator.hasNext());
+ }
+
+ public static DecoratedKey dk(int pk)
+ {
+ return new BufferDecoratedKey(new Murmur3Partitioner.LongToken(pk), ByteBufferUtil.bytes(pk));
+ }
+
+ public static UnfilteredRowIterator rows(PartitionColumns columns, int pk, Row... rows)
+ {
+ Iterator<Row> rowsIterator = Arrays.asList(rows).iterator();
+ return new AbstractUnfilteredRowIterator(metadata, dk(pk), DeletionTime.LIVE, columns, Rows.EMPTY_STATIC_ROW, false, EncodingStats.NO_STATS) {
+ protected Unfiltered computeNext()
+ {
+ return rowsIterator.hasNext() ? rowsIterator.next() : endOfData();
+ }
+ };
+ }
+
+ public Row row(int ck, Cell... columns)
+ {
+ BTreeRow.Builder builder = new BTreeRow.Builder(true);
+ builder.newRow(Util.clustering(metadata.comparator, ck));
+ for (Cell cell : columns)
+ builder.addCell(cell);
+ return builder.build();
+ }
+
+ public Cell cell(ColumnDefinition metadata, int v)
+ {
+ return new BufferCell(metadata,
+ 1L, BufferCell.NO_TTL, BufferCell.NO_DELETION_TIME, ByteBufferUtil.bytes(v), null);
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org