[GitHub] [cassandra] adelapena commented on a change in pull request #624: CASSANDRA-10968 2.2

2020-07-06 Thread GitBox


adelapena commented on a change in pull request #624:
URL: https://github.com/apache/cassandra/pull/624#discussion_r450171852



##
File path: src/java/org/apache/cassandra/db/Directories.java
##
@@ -809,6 +809,11 @@ public long getTrueAllocatedSizeIn(File input)
 return result;
 }
 
+public static boolean isSecondaryIndexFolder(File dir)

Review comment:
   Nice new method





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



-
To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org
For additional commands, e-mail: pr-h...@cassandra.apache.org



[GitHub] [cassandra] adelapena commented on a change in pull request #624: CASSANDRA-10968 2.2

2020-07-06 Thread GitBox


adelapena commented on a change in pull request #624:
URL: https://github.com/apache/cassandra/pull/624#discussion_r450165010



##
File path: test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
##
@@ -2356,4 +2360,41 @@ public void testRebuildSecondaryIndex() throws 
IOException
 
 PerRowSecondaryIndexTest.TestIndex.reset();
 }
+
+@Test
+public void testSnapshotWithoutFlushWithSecondaryIndexes() throws Exception
+{
+String keyspaceName = KEYSPACE1;
+String cfName= CF_INDEX1;
+Keyspace keyspace = Keyspace.open(keyspaceName);
+ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(cfName);
+cfs.truncateBlocking();
+
+List rms = new LinkedList<>();
+Mutation rm;
+
+rm = new Mutation(keyspaceName, ByteBufferUtil.bytes("k1"));
+rm.add(cfName, cellname("birthdate"), ByteBufferUtil.bytes(1L), 0);
+rm.add(cfName, cellname("nobirthdate"), ByteBufferUtil.bytes(1L), 0);
+rms.add(rm);
+Util.writeColumnFamily(rms);
+
+String snapshotName = "newSnapshot";
+cfs.snapshotWithoutFlush(snapshotName);
+
+File snapshotManifestFile = 
cfs.directories.getSnapshotManifestFile(snapshotName);
+JSONParser parser = new JSONParser();
+JSONObject manifest = (JSONObject) parser.parse(new 
FileReader(snapshotManifestFile));
+JSONArray files = (JSONArray) manifest.get("files");
+
+// Keyspace1-Indexed1 and the corresponding index
+assert files.size() == 2;
+
+// Snapshot of the secondary index is stored in the subfolder with the 
same file name
+String file0 = (String)files.get(0);

Review comment:
   Optional nit: we might name this file `baseTableFile`, and the one below 
`indexTableFile`, to slightly improve readability. There is also a missed space:
   ```suggestion
   String file0 = (String) files.get(0);
   ```





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



-
To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org
For additional commands, e-mail: pr-h...@cassandra.apache.org



[GitHub] [cassandra] adelapena commented on a change in pull request #624: CASSANDRA-10968 2.2

2020-07-06 Thread GitBox


adelapena commented on a change in pull request #624:
URL: https://github.com/apache/cassandra/pull/624#discussion_r450165010



##
File path: test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
##
@@ -2356,4 +2360,41 @@ public void testRebuildSecondaryIndex() throws 
IOException
 
 PerRowSecondaryIndexTest.TestIndex.reset();
 }
+
+@Test
+public void testSnapshotWithoutFlushWithSecondaryIndexes() throws Exception
+{
+String keyspaceName = KEYSPACE1;
+String cfName= CF_INDEX1;
+Keyspace keyspace = Keyspace.open(keyspaceName);
+ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(cfName);
+cfs.truncateBlocking();
+
+List rms = new LinkedList<>();
+Mutation rm;
+
+rm = new Mutation(keyspaceName, ByteBufferUtil.bytes("k1"));
+rm.add(cfName, cellname("birthdate"), ByteBufferUtil.bytes(1L), 0);
+rm.add(cfName, cellname("nobirthdate"), ByteBufferUtil.bytes(1L), 0);
+rms.add(rm);
+Util.writeColumnFamily(rms);
+
+String snapshotName = "newSnapshot";
+cfs.snapshotWithoutFlush(snapshotName);
+
+File snapshotManifestFile = 
cfs.directories.getSnapshotManifestFile(snapshotName);
+JSONParser parser = new JSONParser();
+JSONObject manifest = (JSONObject) parser.parse(new 
FileReader(snapshotManifestFile));
+JSONArray files = (JSONArray) manifest.get("files");
+
+// Keyspace1-Indexed1 and the corresponding index
+assert files.size() == 2;
+
+// Snapshot of the secondary index is stored in the subfolder with the 
same file name
+String file0 = (String)files.get(0);

Review comment:
   Optional nit: we might name this file `baseTableFile`, and the one below 
`indexTableFile`, to slightly improve readability.





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



-
To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org
For additional commands, e-mail: pr-h...@cassandra.apache.org