Maxwell-Guo commented on code in PR #2824:
URL: https://github.com/apache/cassandra/pull/2824#discussion_r1364808705
##########
src/java/org/apache/cassandra/io/sstable/CQLSSTableWriter.java:
##########
@@ -554,6 +555,18 @@ public Builder sorted()
return this;
}
+ /**
+ * Defines the maximum SSTable size when using the sorted writer.
+ * By default, i.e. not specified, there is no maximum size limit for
the produced SSTable
+ * @param size the maximum size of each individual SSTable allowed
+ * @return this builder
+ */
+ public Builder withMaxSSTableSizeInMiBForSorted(int size)
+ {
+ this.maxSSTableSizeInMiBForSorted = size;
Review Comment:
we should do a validation for size , it should be positive, if a negative
number is set , then we should remind users explicitly.
If not set then only one sstable will generate, and it's meaningless to set
a negative or add some description to make a clear statement that negative
number will generate only one sstable.
##########
test/unit/org/apache/cassandra/io/sstable/CQLSSTableWriterTest.java:
##########
@@ -1233,6 +1235,77 @@ public void testWriteWithTimestampsAndTtl() throws
Exception
assertFalse(iter.hasNext());
}
+ @Test
+ public void testWriteWithSorted() throws Exception
+ {
+ String schema = "CREATE TABLE " + qualifiedTable + " ("
+ + " k int PRIMARY KEY,"
+ + " v blob )";
+ CQLSSTableWriter writer = CQLSSTableWriter.builder()
+ .inDirectory(dataDir)
+ .forTable(schema)
+ .using("INSERT INTO " +
qualifiedTable +
+ " (k, v) VALUES
(?,text_as_blob(?))" )
Review Comment:
need a space before text_as_blob
##########
src/java/org/apache/cassandra/io/sstable/AbstractSSTableSimpleWriter.java:
##########
@@ -110,6 +112,39 @@ private static SSTableId getNextId(File directory, final
String columnFamily) th
}
}
+ /**
+ * Returns the partition update builder for the given key
Review Comment:
Returns the partition update builder for the given key.
Missing a period (if you think it's needed), just align with the description
of the method below
##########
test/unit/org/apache/cassandra/io/sstable/CQLSSTableWriterTest.java:
##########
@@ -1233,6 +1235,77 @@ public void testWriteWithTimestampsAndTtl() throws
Exception
assertFalse(iter.hasNext());
}
+ @Test
+ public void testWriteWithSorted() throws Exception
+ {
+ String schema = "CREATE TABLE " + qualifiedTable + " ("
+ + " k int PRIMARY KEY,"
+ + " v blob )";
+ CQLSSTableWriter writer = CQLSSTableWriter.builder()
+ .inDirectory(dataDir)
+ .forTable(schema)
+ .using("INSERT INTO " +
qualifiedTable +
+ " (k, v) VALUES
(?,text_as_blob(?))" )
+ .sorted()
+ .build();
+ int rowCount = 10_000;
+ for (int i = 0; i < rowCount; i++)
+ {
+ writer.addRow(i, UUID.randomUUID().toString());
+ }
+ writer.close();
+ loadSSTables(dataDir, keyspace);
+
+ UntypedResultSet resultSet = QueryProcessor.executeInternal("SELECT *
FROM " + qualifiedTable);
+ assertEquals(rowCount, resultSet.size());
+ Iterator<UntypedResultSet.Row> iter = resultSet.iterator();
+ for (int i = 0; i < rowCount; i++)
+ {
+ UntypedResultSet.Row row = iter.next();
+ assertEquals(i, row.getInt("k"));
+ }
+ }
+
+ @Test
+ public void testWriteWithSortedAndMaxSize() throws Exception
+ {
+ String schema = "CREATE TABLE " + qualifiedTable + " ("
+ + " k int PRIMARY KEY,"
+ + " v blob )";
+ CQLSSTableWriter writer = CQLSSTableWriter.builder()
+ .inDirectory(dataDir)
+ .forTable(schema)
+ .using("INSERT INTO " +
qualifiedTable +
+ " (k, v) VALUES
(?,text_as_blob(?))" )
Review Comment:
need a space before text_as_blob
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]