This is an automated email from the ASF dual-hosted git repository. benedict pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/cassandra.git
commit 6942c13eebbc18bd3f38ff4566e0a8cc051fc4d6 Merge: aa762c6 a6d32bb Author: Benedict Elliott Smith <[email protected]> AuthorDate: Tue May 14 15:44:38 2019 +0100 Merge branch 'cassandra-3.11' into trunk .../apache/cassandra/db/filter/RowFilterTest.java | 130 +++++++++++++++++++++ 1 file changed, 130 insertions(+) diff --cc test/unit/org/apache/cassandra/db/filter/RowFilterTest.java index 0000000,0e15013..333d3f8 mode 000000,100644..100644 --- a/test/unit/org/apache/cassandra/db/filter/RowFilterTest.java +++ b/test/unit/org/apache/cassandra/db/filter/RowFilterTest.java @@@ -1,0 -1,130 +1,130 @@@ + /* + * 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.filter; + + import java.nio.ByteBuffer; + import java.util.ArrayList; + import java.util.concurrent.atomic.AtomicBoolean; + + import org.junit.Assert; + import org.junit.Test; + -import org.apache.cassandra.config.CFMetaData; -import org.apache.cassandra.config.ColumnDefinition; + import org.apache.cassandra.cql3.ColumnIdentifier; + import org.apache.cassandra.cql3.Operator; + import org.apache.cassandra.db.Clustering; + import org.apache.cassandra.db.DecoratedKey; + import org.apache.cassandra.db.DeletionTime; + import org.apache.cassandra.db.LivenessInfo; -import org.apache.cassandra.db.PartitionColumns; ++import org.apache.cassandra.db.RegularAndStaticColumns; + import org.apache.cassandra.db.marshal.Int32Type; + import org.apache.cassandra.db.partitions.SingletonUnfilteredPartitionIterator; + import org.apache.cassandra.db.partitions.UnfilteredPartitionIterator; + import org.apache.cassandra.db.rows.BTreeRow; + import org.apache.cassandra.db.rows.BufferCell; + import org.apache.cassandra.db.rows.Cell; + import org.apache.cassandra.db.rows.EncodingStats; + import org.apache.cassandra.db.rows.Row; + import org.apache.cassandra.db.rows.Rows; + import org.apache.cassandra.db.rows.Unfiltered; + import org.apache.cassandra.db.rows.UnfilteredRowIterator; ++import org.apache.cassandra.schema.ColumnMetadata; ++import org.apache.cassandra.schema.TableMetadata; + import org.apache.cassandra.utils.btree.BTree; + + public class RowFilterTest + { + + @Test + public void testCQLFilterClose() + { + // CASSANDRA-15126 - CFMetaData metadata = CFMetaData.Builder.create("testks", "testcf") - .addPartitionKey("pk", Int32Type.instance) - .addStaticColumn("s", Int32Type.instance) - .addRegularColumn("r", Int32Type.instance) - .build(); - ColumnDefinition s = metadata.getColumnDefinition(new ColumnIdentifier("s", true)); - ColumnDefinition r = metadata.getColumnDefinition(new ColumnIdentifier("r", true)); ++ TableMetadata metadata = TableMetadata.builder("testks", "testcf") ++ .addPartitionKeyColumn("pk", Int32Type.instance) ++ .addStaticColumn("s", Int32Type.instance) ++ .addRegularColumn("r", Int32Type.instance) ++ .build(); ++ ColumnMetadata s = metadata.getColumn(new ColumnIdentifier("s", true)); ++ ColumnMetadata r = metadata.getColumn(new ColumnIdentifier("r", true)); + + ByteBuffer one = Int32Type.instance.decompose(1); + RowFilter filter = RowFilter.NONE.withNewExpressions(new ArrayList<>()); + filter.add(s, Operator.NEQ, one); + AtomicBoolean closed = new AtomicBoolean(); + UnfilteredPartitionIterator iter = filter.filter(new SingletonUnfilteredPartitionIterator(new UnfilteredRowIterator() + { + public DeletionTime partitionLevelDeletion() { return null; } + public EncodingStats stats() { return null; } - public CFMetaData metadata() { return metadata; } ++ public TableMetadata metadata() { return metadata; } + public boolean isReverseOrder() { return false; } - public PartitionColumns columns() { return null; } ++ public RegularAndStaticColumns columns() { return null; } + public DecoratedKey partitionKey() { return null; } + public boolean hasNext() { return false; } + public Unfiltered next() { return null; } + public Row staticRow() + { + return BTreeRow.create(Clustering.STATIC_CLUSTERING, + LivenessInfo.EMPTY, + Row.Deletion.LIVE, + BTree.singleton(new BufferCell(s, 1, Cell.NO_TTL, Cell.NO_DELETION_TIME, one, null))); + } + public void close() + { + closed.set(true); + } - }, false), 1); ++ }), 1); + Assert.assertFalse(iter.hasNext()); + Assert.assertTrue(closed.get()); + + filter = RowFilter.NONE.withNewExpressions(new ArrayList<>()); + filter.add(r, Operator.NEQ, one); + closed.set(false); + iter = filter.filter(new SingletonUnfilteredPartitionIterator(new UnfilteredRowIterator() + { + boolean hasNext = true; + public DeletionTime partitionLevelDeletion() { return null; } + public EncodingStats stats() { return null; } - public CFMetaData metadata() { return metadata; } ++ public TableMetadata metadata() { return metadata; } + public boolean isReverseOrder() { return false; } - public PartitionColumns columns() { return null; } ++ public RegularAndStaticColumns columns() { return null; } + public DecoratedKey partitionKey() { return null; } + public Row staticRow() { return Rows.EMPTY_STATIC_ROW; } + public boolean hasNext() + { + boolean r = hasNext; + hasNext = false; + return r; + } + public Unfiltered next() + { + return BTreeRow.create(Clustering.EMPTY, + LivenessInfo.EMPTY, + Row.Deletion.LIVE, + BTree.singleton(new BufferCell(r, 1, Cell.NO_TTL, Cell.NO_DELETION_TIME, one, null))); + } + public void close() + { + closed.set(true); + } - }, false), 1); ++ }), 1); + Assert.assertFalse(iter.hasNext()); + Assert.assertTrue(closed.get()); + } + + + } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
