From 2eac2590bfe85b76c5fc1ea7c818082e124f5ed5 Mon Sep 17 00:00:00 2001 From: Ekaterina Dimitrova Date: Tue, 31 May 2022 11:01:44 -0400 Subject: [PATCH] Revert removal of withBufferSizeInMB(int size) to CQLSSTableWriter.Builder and deprecate it in favor of withBufferSizeIniB(int size);update the docs patch by Ekaterina Dimitrova; reviewed by Michael Semb Wever for CASSANDRA-17675 --- CHANGES.txt | 3 ++- NEWS.txt | 3 +++ .../pages/operating/bulk_loading.adoc | 6 +++++- .../io/sstable/CQLSSTableWriter.java | 20 +++++++++++++++++++ .../io/sstable/CQLSSTableWriterLongTest.java | 2 +- .../io/sstable/CQLSSTableWriterTest.java | 12 +++++------ .../io/sstable/SSTableLoaderTest.java | 2 +- 7 files changed, 38 insertions(+), 10 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index cfb7bcb41a..5540de8433 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,5 +1,6 @@ 4.1-alpha2 - * Remove expired snapshots of dropped tables after restart (CASSANDRA-17619) + * Revert removal of withBufferSizeInMB(int size) in CQLSSTableWriter.Builder class and deprecate it in favor of withBufferSizeInMiB(int size) (CASSANDRA-17675) + * Remove expired snapshots of dropped tables after restart (CASSANDRA-17619) Merged from 4.0: * Ensure FileStreamTask cannot compromise shared channel proxy for system table when interrupted (CASSANDRA-17663) * silence benign SslClosedEngineException (CASSANDRA-17565) diff --git a/NEWS.txt b/NEWS.txt index 87c7804be9..68bf9934fc 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -224,6 +224,9 @@ Upgrading Deprecation ----------- + - `withBufferSizeInMB(int size)` in CQLSSTableWriter.Builder class is deprecated in favor of withBufferSizeInMiB(int size) + No change of functionality in the new one, only name change for clarity in regards to units and to follow naming + standartization. - The properties `keyspace_count_warn_threshold` and `table_count_warn_threshold` in cassandra.yaml have been deprecated in favour of the new `guardrails.keyspaces` and `guardrails.tables` properties and will be removed in a subsequent major version. This also affects the setters and getters for those properties in the JMX MBean diff --git a/doc/modules/cassandra/pages/operating/bulk_loading.adoc b/doc/modules/cassandra/pages/operating/bulk_loading.adoc index 2b11f27460..cf65b12ede 100644 --- a/doc/modules/cassandra/pages/operating/bulk_loading.adoc +++ b/doc/modules/cassandra/pages/operating/bulk_loading.adoc @@ -821,13 +821,17 @@ name. Moreover, said statement must use bind variables since these variables will be bound to values by the resulting SSTable writer. This is a mandatory option. -|withBufferSizeInMB(int size) |The size of the buffer to use. This +|withBufferSizeInMiB(int size) |The size of the buffer to use. This defines how much data will be buffered before being written as a new SSTable. This corresponds roughly to the data size that will have the created SSTable. The default is 128MB, which should be reasonable for a 1GB heap. If OutOfMemory exception gets generated while using the SSTable writer, should lower this value. +|withBufferSizeInMB(int size) |Deprecated, and it will be available +at least until next major release. Please use withBufferSizeInMiB(int size) +which is the same method with a new name. + |sorted() |Creates a CQLSSTableWriter that expects sorted inputs. If this option is used, the resulting SSTable writer will expect rows to be added in SSTable sorted order (and an exception will be thrown if that diff --git a/src/java/org/apache/cassandra/io/sstable/CQLSSTableWriter.java b/src/java/org/apache/cassandra/io/sstable/CQLSSTableWriter.java index 1500f3417c..a0bf6644d9 100644 --- a/src/java/org/apache/cassandra/io/sstable/CQLSSTableWriter.java +++ b/src/java/org/apache/cassandra/io/sstable/CQLSSTableWriter.java @@ -501,6 +501,26 @@ public class CQLSSTableWriter implements Closeable return this; } + /** + * This method is deprecated in favor of the new withBufferSizeInMiB(int size) + * The size of the buffer to use. + *

+ * This defines how much data will be buffered before being written as + * a new SSTable. This correspond roughly to the data size that will have the created + * sstable. + *

+ * The default is 128MiB, which should be reasonable for a 1GiB heap. If you experience + * OOM while using the writer, you should lower this value. + * + * @param size the size to use in MiB. + * @return this builder. + */ + @Deprecated + public Builder withBufferSizeInMB(int size) + { + return withBufferSizeInMiB(size); + } + /** * Creates a CQLSSTableWriter that expects sorted inputs. *

diff --git a/test/long/org/apache/cassandra/io/sstable/CQLSSTableWriterLongTest.java b/test/long/org/apache/cassandra/io/sstable/CQLSSTableWriterLongTest.java index 2cdc447d30..f2bbfa6a60 100644 --- a/test/long/org/apache/cassandra/io/sstable/CQLSSTableWriterLongTest.java +++ b/test/long/org/apache/cassandra/io/sstable/CQLSSTableWriterLongTest.java @@ -76,7 +76,7 @@ public class CQLSSTableWriterLongTest .inDirectory(dataDir) .forTable(schema) .using(insert) - .withBufferSizeInMiB(1) + .withBufferSizeInMB(1) .build(); long high = 100; diff --git a/test/unit/org/apache/cassandra/io/sstable/CQLSSTableWriterTest.java b/test/unit/org/apache/cassandra/io/sstable/CQLSSTableWriterTest.java index f5546b0714..1851314b5d 100644 --- a/test/unit/org/apache/cassandra/io/sstable/CQLSSTableWriterTest.java +++ b/test/unit/org/apache/cassandra/io/sstable/CQLSSTableWriterTest.java @@ -187,7 +187,7 @@ public class CQLSSTableWriterTest .inDirectory(dataDir) .using(insert) .forTable(schema) - .withBufferSizeInMiB(1) + .withBufferSizeInMB(1) .build(); ByteBuffer val = ByteBuffer.allocate(1024 * 1050); @@ -215,7 +215,7 @@ public class CQLSSTableWriterTest .inDirectory(dataDir) .forTable(schema) .using(insert) - .withBufferSizeInMiB(1) + .withBufferSizeInMB(1) .build(); for (int i = 0 ; i < 50000 ; i++) { @@ -926,7 +926,7 @@ public class CQLSSTableWriterTest .inDirectory(dataDir) .forTable(schema) .using(insert) - .withBufferSizeInMiB(1) + .withBufferSizeInMB(1) .build(); final int ID_OFFSET = 1000; @@ -964,7 +964,7 @@ public class CQLSSTableWriterTest .inDirectory(dataDir) .forTable(schema) .using(insert) - .withBufferSizeInMiB(1) + .withBufferSizeInMB(1) .build(); for (int i = 0; i < 100; i++) { @@ -1024,7 +1024,7 @@ public class CQLSSTableWriterTest .inDirectory(dataDir) .forTable(schema) .using(insert) - .withBufferSizeInMiB(1) + .withBufferSizeInMB(1) .build(); UUID uuid1 = UUIDs.timeBased(); UUID uuid2 = UUIDs.timeBased(); @@ -1078,7 +1078,7 @@ public class CQLSSTableWriterTest .inDirectory(dataDir) .forTable(schema) .using(insert) - .withBufferSizeInMiB(1) + .withBufferSizeInMB(1) .build(); UUID uuid1 = UUIDs.startOf(0L); UUID uuid2 = UUIDs.startOf(10000000L); diff --git a/test/unit/org/apache/cassandra/io/sstable/SSTableLoaderTest.java b/test/unit/org/apache/cassandra/io/sstable/SSTableLoaderTest.java index 6d79ed446d..c941a81db2 100644 --- a/test/unit/org/apache/cassandra/io/sstable/SSTableLoaderTest.java +++ b/test/unit/org/apache/cassandra/io/sstable/SSTableLoaderTest.java @@ -168,7 +168,7 @@ public class SSTableLoaderTest .inDirectory(dataDir) .forTable(String.format(schema, KEYSPACE1, CF_STANDARD2)) .using(String.format(query, KEYSPACE1, CF_STANDARD2)) - .withBufferSizeInMiB(1) + .withBufferSizeInMB(1) .build(); int NB_PARTITIONS = 5000; // Enough to write >1MiB and get at least one completed sstable before we've closed the writer