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 2021/03/08 10:51:27 UTC
[cassandra] 01/01: Merge branch cassandra-3.11 into trunk
This is an automated email from the ASF dual-hosted git repository.
blerer pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git
commit 2aa22ba99dcc1dacb07b7af31b2664e7db839063
Merge: 78b13cd e3902bc
Author: Benjamin Lerer <b....@gmail.com>
AuthorDate: Mon Mar 8 11:31:12 2021 +0100
Merge branch cassandra-3.11 into trunk
.../apache/cassandra/index/sasi/SASIIndexTest.java | 545 +++++++++++----------
1 file changed, 277 insertions(+), 268 deletions(-)
diff --cc test/unit/org/apache/cassandra/index/sasi/SASIIndexTest.java
index 7619bd2,afc2e7b..3396e3d
--- a/test/unit/org/apache/cassandra/index/sasi/SASIIndexTest.java
+++ b/test/unit/org/apache/cassandra/index/sasi/SASIIndexTest.java
@@@ -32,19 -32,17 +32,20 @@@ import java.util.concurrent.ThreadLocal
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
++import java.util.stream.Stream;
import org.apache.cassandra.SchemaLoader;
-import org.apache.cassandra.config.CFMetaData;
-import org.apache.cassandra.config.ColumnDefinition;
-import org.apache.cassandra.config.Schema;
+import org.apache.cassandra.cql3.CQLTester;
+import org.apache.cassandra.cql3.Operator;
+import org.apache.cassandra.cql3.QueryProcessor;
+import org.apache.cassandra.cql3.UntypedResultSet;
import org.apache.cassandra.index.Index;
+import org.apache.cassandra.schema.ColumnMetadata;
+import org.apache.cassandra.schema.Schema;
+import org.apache.cassandra.schema.TableMetadata;
import org.apache.cassandra.config.DatabaseDescriptor;
-import org.apache.cassandra.cql3.*;
import org.apache.cassandra.cql3.Term;
-import org.apache.cassandra.cql3.statements.IndexTarget;
-import org.apache.cassandra.cql3.statements.SelectStatement;
+import org.apache.cassandra.cql3.statements.schema.IndexTarget;
import org.apache.cassandra.db.*;
import org.apache.cassandra.db.filter.ColumnFilter;
import org.apache.cassandra.db.filter.DataLimits;
@@@ -80,16 -87,11 +83,14 @@@ import org.apache.cassandra.utils.ByteB
import org.apache.cassandra.utils.FBUtilities;
import org.apache.cassandra.utils.Pair;
- import com.google.common.collect.Lists;
+ import com.google.common.collect.Iterables;
+import com.google.common.collect.Sets;
import com.google.common.util.concurrent.Uninterruptibles;
- import org.junit.Assert;
-
import org.junit.*;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+
public class SASIIndexTest
{
private static final IPartitioner PARTITIONER;
@@@ -110,13 -114,18 +113,14 @@@
public static void loadSchema() throws ConfigurationException
{
SchemaLoader.loadSchema();
- MigrationManager.announceNewKeyspace(KeyspaceMetadata.create(KS_NAME,
- KeyspaceParams.simpleTransient(1),
- Tables.of(SchemaLoader.sasiCFMD(KS_NAME, CF_NAME),
- SchemaLoader.clusteringSASICFMD(KS_NAME, CLUSTERING_CF_NAME_1),
- SchemaLoader.clusteringSASICFMD(KS_NAME, CLUSTERING_CF_NAME_2, "location"),
- SchemaLoader.staticSASICFMD(KS_NAME, STATIC_CF_NAME),
- SchemaLoader.fullTextSearchSASICFMD(KS_NAME, FTS_CF_NAME))));
- Keyspace ks = Keyspace.open(KS_NAME);
- for (ColumnFamilyStore store : ks.getColumnFamilyStores())
- {
- store.disableAutoCompaction();
- }
+ SchemaLoader.createKeyspace(KS_NAME,
+ KeyspaceParams.simpleTransient(1),
+ SchemaLoader.sasiCFMD(KS_NAME, CF_NAME),
+ SchemaLoader.clusteringSASICFMD(KS_NAME, CLUSTERING_CF_NAME_1),
+ SchemaLoader.clusteringSASICFMD(KS_NAME, CLUSTERING_CF_NAME_2, "location"),
+ SchemaLoader.staticSASICFMD(KS_NAME, STATIC_CF_NAME),
+ SchemaLoader.fullTextSearchSASICFMD(KS_NAME, FTS_CF_NAME));
++ stores().forEach(ColumnFamilyStore::disableAutoCompaction);
}
@Before
@@@ -778,33 -784,33 +779,33 @@@
{
ColumnFamilyStore store = Keyspace.open(KS_NAME).getColumnFamilyStore(CF_NAME);
- Mutation rm1 = new Mutation(KS_NAME, decoratedKey(AsciiType.instance.decompose("key1")));
- rm1.add(PartitionUpdate.singleRowUpdate(store.metadata,
+ Mutation.PartitionUpdateCollector rm1 = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey(AsciiType.instance.decompose("key1")));
+ rm1.add(PartitionUpdate.singleRowUpdate(store.metadata(),
rm1.key(),
- buildRow(buildCell(store.metadata,
+ buildRow(buildCell(store.metadata(),
UTF8Type.instance.decompose("/data/output/id"),
AsciiType.instance.decompose("jason"),
- System.currentTimeMillis()))));
+ 1000))));
- Mutation rm2 = new Mutation(KS_NAME, decoratedKey(AsciiType.instance.decompose("key2")));
- rm2.add(PartitionUpdate.singleRowUpdate(store.metadata,
+ Mutation.PartitionUpdateCollector rm2 = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey(AsciiType.instance.decompose("key2")));
+ rm2.add(PartitionUpdate.singleRowUpdate(store.metadata(),
rm2.key(),
- buildRow(buildCell(store.metadata,
+ buildRow(buildCell(store.metadata(),
UTF8Type.instance.decompose("/data/output/id"),
AsciiType.instance.decompose("pavel"),
- System.currentTimeMillis()))));
+ 2000))));
- Mutation rm3 = new Mutation(KS_NAME, decoratedKey(AsciiType.instance.decompose("key3")));
- rm3.add(PartitionUpdate.singleRowUpdate(store.metadata,
+ Mutation.PartitionUpdateCollector rm3 = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey(AsciiType.instance.decompose("key3")));
+ rm3.add(PartitionUpdate.singleRowUpdate(store.metadata(),
rm3.key(),
- buildRow(buildCell(store.metadata,
+ buildRow(buildCell(store.metadata(),
UTF8Type.instance.decompose("/data/output/id"),
AsciiType.instance.decompose("Aleksey"),
- System.currentTimeMillis()))));
+ 3000))));
- rm1.apply();
- rm2.apply();
- rm3.apply();
+ rm1.build().apply();
+ rm2.build().apply();
+ rm3.build().apply();
if (forceFlush)
store.forceBlockingFlush();
@@@ -830,20 -836,20 +831,20 @@@
Assert.assertTrue(rows.toString(), rows.isEmpty());
// now let's trigger index rebuild and check if we got the data back
- store.indexManager.buildIndexBlocking(store.indexManager.getIndexByName("data_output_id"));
+ store.indexManager.rebuildIndexesBlocking(Sets.newHashSet(store.name + "_data_output_id"));
rows = getIndexed(store, 10, buildExpression(dataOutputId, Operator.LIKE_CONTAINS, UTF8Type.instance.decompose("a")));
- Assert.assertTrue(rows.toString(), Arrays.equals(new String[] { "key1", "key2" }, rows.toArray(new String[rows.size()])));
+ assertRows(rows, "key1", "key2");
// also let's try to build an index for column which has no data to make sure that doesn't fail
- store.indexManager.buildIndexBlocking(store.indexManager.getIndexByName("first_name"));
- store.indexManager.buildIndexBlocking(store.indexManager.getIndexByName("data_output_id"));
+ store.indexManager.rebuildIndexesBlocking(Sets.newHashSet(store.name + "_first_name"));
+ store.indexManager.rebuildIndexesBlocking(Sets.newHashSet(store.name + "_data_output_id"));
rows = getIndexed(store, 10, buildExpression(dataOutputId, Operator.LIKE_CONTAINS, UTF8Type.instance.decompose("a")));
- Assert.assertTrue(rows.toString(), Arrays.equals(new String[] { "key1", "key2" }, rows.toArray(new String[rows.size()])));
+ assertRows(rows, "key1", "key2");
rows = getIndexed(store, 10, buildExpression(dataOutputId, Operator.LIKE_SUFFIX, UTF8Type.instance.decompose("el")));
- Assert.assertTrue(rows.toString(), Arrays.equals(new String[] { "key2" }, rows.toArray(new String[rows.size()])));
+ assertRows(rows, "key2");
}
@Test
@@@ -1058,15 -1060,14 +1059,14 @@@
put("key41", Pair.create("Dennis", 32));
}};
- loadData(part4, 4000, true);
+ loadData(part4, true, 8);
rows = getIndexed(store, 100, buildExpression(firstName, Operator.LIKE_CONTAINS, UTF8Type.instance.decompose("a")));
- Assert.assertEquals(rows.toString(), 1, rows.size());
+ assertRowsSize(rows, 1);
}
-
@Test
- public void testConcurrentMemtableReadsAndWrites()
+ public void testConcurrentMemtableReadsAndWrites() throws Exception
{
final ColumnFamilyStore store = Keyspace.open(KS_NAME).getColumnFamilyStore(CF_NAME);
@@@ -1080,12 -1081,13 +1080,13 @@@
final String key = "key" + i;
final String firstName = "first_name#" + i;
final String lastName = "last_name#" + i;
+ final long timestamp = 1000 + i;
- scheduler.submit((Runnable) () -> {
+ scheduler.submit(() -> {
try
{
- newMutation(key, firstName, lastName, 26, System.currentTimeMillis()).apply();
- Uninterruptibles.sleepUninterruptibly(5, TimeUnit.MILLISECONDS); // back up a bit to do more reads
+ newMutation(key, firstName, lastName, 26, timestamp).apply();
- Uninterruptibles.sleepUninterruptibly(5, TimeUnit.MILLISECONDS); // back up a bit to do more reads
++ Uninterruptibles.sleepUninterruptibly(5, MILLISECONDS); // back up a bit to do more reads
}
finally
{
@@@ -1218,25 -1189,25 +1193,25 @@@
final ByteBuffer comment = UTF8Type.instance.decompose("comment");
- Mutation rm = new Mutation(KS_NAME, decoratedKey("key1"));
+ Mutation.PartitionUpdateCollector rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key1"));
- update(rm, comment, UTF8Type.instance.decompose("ⓈⓅⒺⒸⒾⒶⓁ ⒞⒣⒜⒭⒮ and normal ones"), System.currentTimeMillis());
+ update(rm, comment, UTF8Type.instance.decompose("ⓈⓅⒺⒸⒾⒶⓁ ⒞⒣⒜⒭⒮ and normal ones"), 1000);
- rm.apply();
+ rm.build().apply();
- rm = new Mutation(KS_NAME, decoratedKey("key2"));
+ rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key2"));
- update(rm, comment, UTF8Type.instance.decompose("龍馭鬱"), System.currentTimeMillis());
+ update(rm, comment, UTF8Type.instance.decompose("龍馭鬱"), 2000);
- rm.apply();
+ rm.build().apply();
- rm = new Mutation(KS_NAME, decoratedKey("key3"));
+ rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key3"));
- update(rm, comment, UTF8Type.instance.decompose("インディアナ"), System.currentTimeMillis());
+ update(rm, comment, UTF8Type.instance.decompose("インディアナ"), 3000);
- rm.apply();
+ rm.build().apply();
- rm = new Mutation(KS_NAME, decoratedKey("key4"));
+ rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key4"));
- update(rm, comment, UTF8Type.instance.decompose("レストラン"), System.currentTimeMillis());
+ update(rm, comment, UTF8Type.instance.decompose("レストラン"), 4000);
- rm.apply();
+ rm.build().apply();
- rm = new Mutation(KS_NAME, decoratedKey("key5"));
+ rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key5"));
- update(rm, comment, UTF8Type.instance.decompose("ベンジャミン ウエスト"), System.currentTimeMillis());
+ update(rm, comment, UTF8Type.instance.decompose("ベンジャミン ウエスト"), 5000);
- rm.apply();
+ rm.build().apply();
if (forceFlush)
store.forceBlockingFlush();
@@@ -1294,21 -1265,21 +1269,21 @@@
final ByteBuffer comment = UTF8Type.instance.decompose("comment_suffix_split");
- Mutation rm = new Mutation(KS_NAME, decoratedKey("key1"));
+ Mutation.PartitionUpdateCollector rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key1"));
- update(rm, comment, UTF8Type.instance.decompose("龍馭鬱"), System.currentTimeMillis());
+ update(rm, comment, UTF8Type.instance.decompose("龍馭鬱"), 1000);
- rm.apply();
+ rm.build().apply();
- rm = new Mutation(KS_NAME, decoratedKey("key2"));
+ rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key2"));
- update(rm, comment, UTF8Type.instance.decompose("インディアナ"), System.currentTimeMillis());
+ update(rm, comment, UTF8Type.instance.decompose("インディアナ"), 2000);
- rm.apply();
+ rm.build().apply();
- rm = new Mutation(KS_NAME, decoratedKey("key3"));
+ rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key3"));
- update(rm, comment, UTF8Type.instance.decompose("レストラン"), System.currentTimeMillis());
+ update(rm, comment, UTF8Type.instance.decompose("レストラン"), 3000);
- rm.apply();
+ rm.build().apply();
- rm = new Mutation(KS_NAME, decoratedKey("key4"));
+ rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key4"));
- update(rm, comment, UTF8Type.instance.decompose("ベンジャミン ウエスト"), System.currentTimeMillis());
+ update(rm, comment, UTF8Type.instance.decompose("ベンジャミン ウエスト"), 4000);
- rm.apply();
+ rm.build().apply();
if (forceFlush)
store.forceBlockingFlush();
@@@ -1363,9 -1334,9 +1338,9 @@@
final ByteBuffer bigValue = UTF8Type.instance.decompose(new String(randomBytes));
- Mutation rm = new Mutation(KS_NAME, decoratedKey("key1"));
+ Mutation.PartitionUpdateCollector rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key1"));
- update(rm, comment, bigValue, System.currentTimeMillis());
+ update(rm, comment, bigValue, 1000 + i);
- rm.apply();
+ rm.build().apply();
Set<String> rows;
@@@ -1423,8 -1395,8 +1398,8 @@@
try (ReadExecutionController controller = command.executionController())
{
- Set<String> rows = getKeys(new QueryPlan(store, command, DatabaseDescriptor.getRangeRpcTimeout()).execute(controller));
+ Set<String> rows = getKeys(new QueryPlan(store, command, DatabaseDescriptor.getRangeRpcTimeout(MILLISECONDS)).execute(controller));
- Assert.assertTrue(rows.toString(), Arrays.equals(new String[] { "key1", "key2", "key3", "key4" }, rows.toArray(new String[rows.size()])));
+ assertRows(rows, "key1", "key2", "key3", "key4");
}
}
@@@ -1443,37 -1415,37 +1418,37 @@@
final ByteBuffer fullName = UTF8Type.instance.decompose("/output/full-name/");
- Mutation rm = new Mutation(KS_NAME, decoratedKey("key1"));
+ Mutation.PartitionUpdateCollector rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key1"));
- update(rm, fullName, UTF8Type.instance.decompose("美加 八田"), System.currentTimeMillis());
+ update(rm, fullName, UTF8Type.instance.decompose("美加 八田"), 1000);
- rm.apply();
+ rm.build().apply();
- rm = new Mutation(KS_NAME, decoratedKey("key2"));
+ rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key2"));
- update(rm, fullName, UTF8Type.instance.decompose("仁美 瀧澤"), System.currentTimeMillis());
+ update(rm, fullName, UTF8Type.instance.decompose("仁美 瀧澤"), 2000);
- rm.apply();
+ rm.build().apply();
- rm = new Mutation(KS_NAME, decoratedKey("key3"));
+ rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key3"));
- update(rm, fullName, UTF8Type.instance.decompose("晃宏 高須"), System.currentTimeMillis());
+ update(rm, fullName, UTF8Type.instance.decompose("晃宏 高須"), 3000);
- rm.apply();
+ rm.build().apply();
- rm = new Mutation(KS_NAME, decoratedKey("key4"));
+ rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key4"));
- update(rm, fullName, UTF8Type.instance.decompose("弘孝 大竹"), System.currentTimeMillis());
+ update(rm, fullName, UTF8Type.instance.decompose("弘孝 大竹"), 4000);
- rm.apply();
+ rm.build().apply();
- rm = new Mutation(KS_NAME, decoratedKey("key5"));
+ rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key5"));
- update(rm, fullName, UTF8Type.instance.decompose("満枝 榎本"), System.currentTimeMillis());
+ update(rm, fullName, UTF8Type.instance.decompose("満枝 榎本"), 5000);
- rm.apply();
+ rm.build().apply();
- rm = new Mutation(KS_NAME, decoratedKey("key6"));
+ rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key6"));
- update(rm, fullName, UTF8Type.instance.decompose("飛鳥 上原"), System.currentTimeMillis());
+ update(rm, fullName, UTF8Type.instance.decompose("飛鳥 上原"), 6000);
- rm.apply();
+ rm.build().apply();
- rm = new Mutation(KS_NAME, decoratedKey("key7"));
+ rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key7"));
- update(rm, fullName, UTF8Type.instance.decompose("大輝 鎌田"), System.currentTimeMillis());
+ update(rm, fullName, UTF8Type.instance.decompose("大輝 鎌田"), 7000);
- rm.apply();
+ rm.build().apply();
- rm = new Mutation(KS_NAME, decoratedKey("key8"));
+ rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key8"));
- update(rm, fullName, UTF8Type.instance.decompose("利久 寺地"), System.currentTimeMillis());
+ update(rm, fullName, UTF8Type.instance.decompose("利久 寺地"), 8000);
- rm.apply();
+ rm.build().apply();
store.forceBlockingFlush();
@@@ -1499,17 -1471,17 +1474,17 @@@
final ByteBuffer comment = UTF8Type.instance.decompose("address");
- Mutation rm = new Mutation(KS_NAME, decoratedKey("key1"));
+ Mutation.PartitionUpdateCollector rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key1"));
- update(rm, comment, UTF8Type.instance.decompose("577 Rogahn Valleys Apt. 178"), System.currentTimeMillis());
+ update(rm, comment, UTF8Type.instance.decompose("577 Rogahn Valleys Apt. 178"), 1000);
- rm.apply();
+ rm.build().apply();
- rm = new Mutation(KS_NAME, decoratedKey("key2"));
+ rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key2"));
- update(rm, comment, UTF8Type.instance.decompose("89809 Beverly Course Suite 089"), System.currentTimeMillis());
+ update(rm, comment, UTF8Type.instance.decompose("89809 Beverly Course Suite 089"), 2000);
- rm.apply();
+ rm.build().apply();
- rm = new Mutation(KS_NAME, decoratedKey("key3"));
+ rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key3"));
- update(rm, comment, UTF8Type.instance.decompose("165 clydie oval apt. 399"), System.currentTimeMillis());
+ update(rm, comment, UTF8Type.instance.decompose("165 clydie oval apt. 399"), 3000);
- rm.apply();
+ rm.build().apply();
if (forceFlush)
store.forceBlockingFlush();
@@@ -1574,42 -1546,42 +1549,42 @@@
final ByteBuffer name = UTF8Type.instance.decompose("first_name_prefix");
- Mutation rm;
+ Mutation.PartitionUpdateCollector rm;
- rm = new Mutation(KS_NAME, decoratedKey("key1"));
+ rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key1"));
- update(rm, name, UTF8Type.instance.decompose("Pavel"), System.currentTimeMillis());
+ update(rm, name, UTF8Type.instance.decompose("Pavel"), 1000);
- rm.apply();
+ rm.build().apply();
- rm = new Mutation(KS_NAME, decoratedKey("key2"));
+ rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key2"));
- update(rm, name, UTF8Type.instance.decompose("Jordan"), System.currentTimeMillis());
+ update(rm, name, UTF8Type.instance.decompose("Jordan"), 2000);
- rm.apply();
+ rm.build().apply();
- rm = new Mutation(KS_NAME, decoratedKey("key3"));
+ rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key3"));
- update(rm, name, UTF8Type.instance.decompose("Mikhail"), System.currentTimeMillis());
+ update(rm, name, UTF8Type.instance.decompose("Mikhail"), 3000);
- rm.apply();
+ rm.build().apply();
- rm = new Mutation(KS_NAME, decoratedKey("key4"));
+ rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key4"));
- update(rm, name, UTF8Type.instance.decompose("Michael"), System.currentTimeMillis());
+ update(rm, name, UTF8Type.instance.decompose("Michael"), 4000);
- rm.apply();
+ rm.build().apply();
- rm = new Mutation(KS_NAME, decoratedKey("key5"));
+ rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key5"));
- update(rm, name, UTF8Type.instance.decompose("Johnny"), System.currentTimeMillis());
+ update(rm, name, UTF8Type.instance.decompose("Johnny"), 5000);
- rm.apply();
+ rm.build().apply();
// first flush would make interval for name - 'johnny' -> 'pavel'
store.forceBlockingFlush();
- rm = new Mutation(KS_NAME, decoratedKey("key6"));
+ rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key6"));
- update(rm, name, UTF8Type.instance.decompose("Jason"), System.currentTimeMillis());
+ update(rm, name, UTF8Type.instance.decompose("Jason"), 6000);
- rm.apply();
+ rm.build().apply();
- rm = new Mutation(KS_NAME, decoratedKey("key7"));
+ rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key7"));
- update(rm, name, UTF8Type.instance.decompose("Vijay"), System.currentTimeMillis());
+ update(rm, name, UTF8Type.instance.decompose("Vijay"), 7000);
- rm.apply();
+ rm.build().apply();
- rm = new Mutation(KS_NAME, decoratedKey("key8")); // this name is going to be tokenized
+ rm = new Mutation.PartitionUpdateCollector(KS_NAME, decoratedKey("key8")); // this name is going to be tokenized
- update(rm, name, UTF8Type.instance.decompose("Jean-Claude"), System.currentTimeMillis());
+ update(rm, name, UTF8Type.instance.decompose("Jean-Claude"), 8000);
- rm.apply();
+ rm.build().apply();
// this flush is going to produce range - 'jason' -> 'vijay'
store.forceBlockingFlush();
@@@ -1696,11 -1668,11 +1671,11 @@@
put(IndexTarget.CUSTOM_INDEX_OPTION_NAME, SASIIndex.class.getName());
}}));
- Assert.assertEquals(true, indexA.isIndexed());
- Assert.assertEquals(false, indexA.isLiteral());
+ Assert.assertTrue(indexA.isIndexed());
+ Assert.assertFalse(indexA.isLiteral());
// now let's double-check that we do get 'true' when we set it
- ColumnDefinition columnB = ColumnDefinition.regularDef(KS_NAME, CF_NAME, "special-B", stringType);
+ ColumnMetadata columnB = ColumnMetadata.regularColumn(KS_NAME, CF_NAME, "special-B", stringType);
ColumnIndex indexB = new ColumnIndex(UTF8Type.instance, columnB, IndexMetadata.fromSchemaMetadata("special-index-B", IndexMetadata.Kind.CUSTOM, new HashMap<String, String>()
{{
@@@ -1708,32 -1680,32 +1683,32 @@@
put("is_literal", "true");
}}));
- Assert.assertEquals(true, indexB.isIndexed());
- Assert.assertEquals(true, indexB.isLiteral());
+ Assert.assertTrue(indexB.isIndexed());
+ Assert.assertTrue(indexB.isLiteral());
// and finally we should also get a 'true' if it's built-in UTF-8/ASCII comparator
- ColumnDefinition columnC = ColumnDefinition.regularDef(KS_NAME, CF_NAME, "special-C", UTF8Type.instance);
+ ColumnMetadata columnC = ColumnMetadata.regularColumn(KS_NAME, CF_NAME, "special-C", UTF8Type.instance);
ColumnIndex indexC = new ColumnIndex(UTF8Type.instance, columnC, IndexMetadata.fromSchemaMetadata("special-index-C", IndexMetadata.Kind.CUSTOM, new HashMap<String, String>()
{{
put(IndexTarget.CUSTOM_INDEX_OPTION_NAME, SASIIndex.class.getName());
}}));
- Assert.assertEquals(true, indexC.isIndexed());
- Assert.assertEquals(true, indexC.isLiteral());
+ Assert.assertTrue(indexC.isIndexed());
+ Assert.assertTrue(indexC.isLiteral());
- ColumnDefinition columnD = ColumnDefinition.regularDef(KS_NAME, CF_NAME, "special-D", AsciiType.instance);
+ ColumnMetadata columnD = ColumnMetadata.regularColumn(KS_NAME, CF_NAME, "special-D", AsciiType.instance);
ColumnIndex indexD = new ColumnIndex(UTF8Type.instance, columnD, IndexMetadata.fromSchemaMetadata("special-index-D", IndexMetadata.Kind.CUSTOM, new HashMap<String, String>()
{{
put(IndexTarget.CUSTOM_INDEX_OPTION_NAME, SASIIndex.class.getName());
}}));
- Assert.assertEquals(true, indexD.isIndexed());
- Assert.assertEquals(true, indexD.isLiteral());
+ Assert.assertTrue(indexD.isIndexed());
+ Assert.assertTrue(indexD.isLiteral());
// and option should supersedes the comparator type
- ColumnDefinition columnE = ColumnDefinition.regularDef(KS_NAME, CF_NAME, "special-E", UTF8Type.instance);
+ ColumnMetadata columnE = ColumnMetadata.regularColumn(KS_NAME, CF_NAME, "special-E", UTF8Type.instance);
ColumnIndex indexE = new ColumnIndex(UTF8Type.instance, columnE, IndexMetadata.fromSchemaMetadata("special-index-E", IndexMetadata.Kind.CUSTOM, new HashMap<String, String>()
{{
@@@ -1741,14 -1713,14 +1716,14 @@@
put("is_literal", "false");
}}));
- Assert.assertEquals(true, indexE.isIndexed());
- Assert.assertEquals(false, indexE.isLiteral());
+ Assert.assertTrue(indexE.isIndexed());
+ Assert.assertFalse(indexE.isLiteral());
// test frozen-collection
- ColumnDefinition columnF = ColumnDefinition.regularDef(KS_NAME,
- CF_NAME,
- "special-F",
- ListType.getInstance(UTF8Type.instance, false));
+ ColumnMetadata columnF = ColumnMetadata.regularColumn(KS_NAME,
+ CF_NAME,
+ "special-F",
+ ListType.getInstance(UTF8Type.instance, false));
ColumnIndex indexF = new ColumnIndex(UTF8Type.instance, columnF, IndexMetadata.fromSchemaMetadata("special-index-F", IndexMetadata.Kind.CUSTOM, new HashMap<String, String>()
{{
@@@ -1981,12 -1953,14 +1956,14 @@@
store.forceBlockingFlush();
SSTable ssTable = store.getSSTables(SSTableSet.LIVE).iterator().next();
- Path path = FileSystems.getDefault().getPath(ssTable.getFilename().replace("-Data", "-SI_age"));
+ Path path = FileSystems.getDefault().getPath(ssTable.getFilename().replace("-Data", "-SI_" + CLUSTERING_CF_NAME_1 + "_age"));
// Overwrite index file with garbage
- Writer writer = new FileWriter(path.toFile(), false);
- writer.write("garbage");
- writer.close();
+ try (Writer writer = new FileWriter(path.toFile(), false))
+ {
+ writer.write("garbage");
+ }
+
long size1 = Files.readAttributes(path, BasicFileAttributes.class).size();
// Trying to query the corrupted index file yields no results
@@@ -2511,11 -2502,13 +2504,15 @@@
return store;
}
- private void cleanupData()
+ private static void cleanupData()
+ {
++ stores().forEach(ColumnFamilyStore::truncateBlocking);
++ }
++
++ private static Stream<ColumnFamilyStore> stores()
+ {
Keyspace ks = Keyspace.open(KS_NAME);
- ks.getColumnFamilyStore(CF_NAME).truncateBlocking();
- ks.getColumnFamilyStore(CLUSTERING_CF_NAME_1).truncateBlocking();
- for (ColumnFamilyStore store : ks.getColumnFamilyStores())
- {
- store.truncateBlocking();
- }
++ return ks.getMetadata().tables.stream().map(t -> ks.getColumnFamilyStore(t.name));
}
private static Set<String> getIndexed(ColumnFamilyStore store, int maxResults, Expression... expressions)
@@@ -2633,13 -2627,20 +2630,13 @@@
return QueryProcessor.executeOnceInternal(String.format(query, KS_NAME, cfName), values);
}
- private Set<String> executeCQLWithKeys(String rawStatement) throws Exception
+ private Set<String> executeCQLWithKeys(String rawStatement)
{
- SelectStatement statement = (SelectStatement) QueryProcessor.parseStatement(rawStatement).prepare(ClientState.forInternalCalls()).statement;
- ResultMessage.Rows cqlRows = statement.executeInternal(QueryState.forInternalCalls(), QueryOptions.DEFAULT);
-
Set<String> results = new TreeSet<>();
- for (CqlRow row : cqlRows.toThriftResult().getRows())
+ for (UntypedResultSet.Row row : QueryProcessor.executeOnceInternal(rawStatement))
{
- for (org.apache.cassandra.thrift.Column col : row.columns)
- {
- String columnName = UTF8Type.instance.getString(col.bufferForName());
- if (columnName.equals("id"))
- results.add(AsciiType.instance.getString(col.bufferForValue()));
- }
+ if (row.has("id"))
+ results.add(row.getString("id"));
}
return results;
@@@ -2655,12 -2656,12 +2652,12 @@@
return decoratedKey(AsciiType.instance.fromString(key));
}
- private static Row buildRow(Collection<Cell> cells)
+ private static Row buildRow(Collection<Cell<?>> cells)
{
- return buildRow(cells.toArray(new Cell<?>[cells.size()]));
+ return buildRow(Iterables.toArray(cells, Cell.class));
}
- private static Row buildRow(Cell... cells)
+ private static Row buildRow(Cell<?>... cells)
{
Row.Builder rowBuilder = BTreeRow.sortedBuilder();
rowBuilder.newRow(Clustering.EMPTY);
@@@ -2713,4 -2714,16 +2710,16 @@@
this.value = value;
}
}
+
- private static void assertRows(Set<String> actual, String... expected)
++ private static void assertRows(Iterable<String> actual, String... expected)
+ {
+ String message = String.format("Expected rows to contain %s but found %s", Arrays.toString(expected), actual);
+ Assert.assertArrayEquals(message, expected, Iterables.toArray(actual, String.class));
+ }
+
+ private static void assertRowsSize(Set<String> actual, int expectedSize)
+ {
+ String message = String.format("Expected %s to have size %d but found size %d", actual, expectedSize, actual.size());
+ Assert.assertEquals(message, expectedSize, actual.size());
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org