Skip to content

Commit 872c182

Browse files
mtopolnikclaude
andcommitted
refactor(qwp): rename sf_max_bytes to sf_max_segment_bytes
The connect-string key caps a single SF segment, and the new name says so; it also pairs cleanly with sf_max_total_bytes. The builder method follows: storeAndForwardMaxBytes() is now storeAndForwardMaxSegmentBytes(). Internal identifiers and error messages rename in step so the old spelling is gone entirely. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 5cc68a9 commit 872c182

10 files changed

Lines changed: 32 additions & 32 deletions

File tree

core/src/main/java/io/questdb/client/Sender.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,7 +1123,7 @@ public int getConnectTimeout() {
11231123
// implemented; FLUSH and APPEND are deferred follow-ups (cursor needs
11241124
// to learn fsync first).
11251125
private SfDurability sfDurability = SfDurability.MEMORY;
1126-
private long sfMaxBytes = PARAMETER_NOT_SET_EXPLICITLY;
1126+
private long sfMaxSegmentBytes = PARAMETER_NOT_SET_EXPLICITLY;
11271127
private long sfMaxTotalBytes = PARAMETER_NOT_SET_EXPLICITLY;
11281128
private boolean shouldDestroyPrivKey;
11291129
private boolean tlsEnabled;
@@ -1446,17 +1446,17 @@ public Sender build() {
14461446
// (same lock-free architecture, no disk involvement). The
14471447
// sf_durability != memory rejection lives in validateParameters
14481448
// so it is reached by build() and by no-connect validation alike.
1449-
long actualSfMaxBytes = sfMaxBytes == PARAMETER_NOT_SET_EXPLICITLY
1449+
long actualSfMaxSegmentBytes = sfMaxSegmentBytes == PARAMETER_NOT_SET_EXPLICITLY
14501450
? DEFAULT_SEGMENT_BYTES
1451-
: sfMaxBytes;
1451+
: sfMaxSegmentBytes;
14521452
// Default cap depends on backing: RAM (memory mode) is tight
14531453
// by default; disk (SF mode) is cheap so the default is
14541454
// generous enough that normal traffic never hits it.
14551455
long defaultMaxTotal = sfDir == null
14561456
? DEFAULT_MAX_BYTES_MEMORY
14571457
: DEFAULT_MAX_BYTES_SF;
14581458
long actualSfMaxTotalBytes = sfMaxTotalBytes == PARAMETER_NOT_SET_EXPLICITLY
1459-
? Math.max(defaultMaxTotal, actualSfMaxBytes * 2)
1459+
? Math.max(defaultMaxTotal, actualSfMaxSegmentBytes * 2)
14601460
: sfMaxTotalBytes;
14611461
long actualCloseFlushTimeoutMillis = closeFlushTimeoutMillis == CLOSE_FLUSH_TIMEOUT_NOT_SET
14621462
? DEFAULT_CLOSE_FLUSH_TIMEOUT_MILLIS
@@ -1541,7 +1541,7 @@ public Sender build() {
15411541
? CursorSendEngine.DEFAULT_APPEND_DEADLINE_NANOS
15421542
: sfAppendDeadlineMillis * 1_000_000L;
15431543
CursorSendEngine cursorEngine = new CursorSendEngine(
1544-
slotPath, actualSfMaxBytes,
1544+
slotPath, actualSfMaxSegmentBytes,
15451545
actualSfMaxTotalBytes, actualSfAppendDeadlineNanos);
15461546
int actualErrorInboxCapacity = errorInboxCapacity != PARAMETER_NOT_SET_EXPLICITLY
15471547
? errorInboxCapacity
@@ -1622,7 +1622,7 @@ public Sender build() {
16221622
connected.startOrphanDrainers(
16231623
orphans,
16241624
maxBackgroundDrainers,
1625-
actualSfMaxBytes,
1625+
actualSfMaxSegmentBytes,
16261626
actualSfMaxTotalBytes);
16271627
}
16281628
}
@@ -2757,14 +2757,14 @@ public LineSenderBuilder storeAndForwardDurability(SfDurability durability) {
27572757
* (4 MiB). Smaller segments mean faster trim of acked data; larger
27582758
* segments mean fewer rotations.
27592759
*/
2760-
public LineSenderBuilder storeAndForwardMaxBytes(long maxBytes) {
2760+
public LineSenderBuilder storeAndForwardMaxSegmentBytes(long maxBytes) {
27612761
if (protocol != PARAMETER_NOT_SET_EXPLICITLY && protocol != PROTOCOL_WEBSOCKET) {
27622762
throw new LineSenderException("store_and_forward is only supported for WebSocket transport");
27632763
}
27642764
if (maxBytes <= 0) {
2765-
throw new LineSenderException("sf_max_bytes must be positive: ").put(maxBytes);
2765+
throw new LineSenderException("sf_max_segment_bytes must be positive: ").put(maxBytes);
27662766
}
2767-
this.sfMaxBytes = maxBytes;
2767+
this.sfMaxSegmentBytes = maxBytes;
27682768
return this;
27692769
}
27702770

@@ -3352,12 +3352,12 @@ private LineSenderBuilder fromConfig(CharSequence configurationString) {
33523352
}
33533353
pos = getValue(configurationString, pos, sink, "sender_id");
33543354
senderId(sink.toString());
3355-
} else if (Chars.equals("sf_max_bytes", sink)) {
3355+
} else if (Chars.equals("sf_max_segment_bytes", sink)) {
33563356
if (protocol != PROTOCOL_WEBSOCKET) {
3357-
throw new LineSenderException("sf_max_bytes is only supported for WebSocket transport");
3357+
throw new LineSenderException("sf_max_segment_bytes is only supported for WebSocket transport");
33583358
}
3359-
pos = getValue(configurationString, pos, sink, "sf_max_bytes");
3360-
storeAndForwardMaxBytes(parseSizeValue(sink, "sf_max_bytes"));
3359+
pos = getValue(configurationString, pos, sink, "sf_max_segment_bytes");
3360+
storeAndForwardMaxSegmentBytes(parseSizeValue(sink, "sf_max_segment_bytes"));
33613361
} else if (Chars.equals("sf_max_total_bytes", sink)) {
33623362
if (protocol != PROTOCOL_WEBSOCKET) {
33633363
throw new LineSenderException("sf_max_total_bytes is only supported for WebSocket transport");
@@ -3689,8 +3689,8 @@ private LineSenderBuilder fromConfigWebSocket(CharSequence configurationString)
36893689
if (view.has("sf_append_deadline_millis")) {
36903690
sfAppendDeadlineMillis(wsLong(view, v, "sf_append_deadline_millis"));
36913691
}
3692-
if (view.has("sf_max_bytes")) {
3693-
storeAndForwardMaxBytes(wsSize(view, v, "sf_max_bytes"));
3692+
if (view.has("sf_max_segment_bytes")) {
3693+
storeAndForwardMaxSegmentBytes(wsSize(view, v, "sf_max_segment_bytes"));
36943694
}
36953695
if (view.has("sf_max_total_bytes")) {
36963696
storeAndForwardMaxTotalBytes(wsSize(view, v, "sf_max_total_bytes"));
@@ -3848,7 +3848,7 @@ public java.util.Map<String, Object> wsConfigSnapshotForTest() {
38483848
m.put("request_durable_ack", requestDurableAck);
38493849
m.put("sender_id", senderId);
38503850
m.put("sf_dir", sfDir);
3851-
m.put("sf_max_bytes", sfMaxBytes);
3851+
m.put("sf_max_segment_bytes", sfMaxSegmentBytes);
38523852
m.put("sf_max_total_bytes", sfMaxTotalBytes);
38533853
m.put("sf_durability", sfDurability == null ? null : sfDurability.name());
38543854
m.put("sf_append_deadline_millis", sfAppendDeadlineMillis);

core/src/main/java/io/questdb/client/cutlass/qwp/client/sf/cursor/CursorWebSocketSendLoop.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public final class CursorWebSocketSendLoop implements QuietCloseable {
159159
// drained from the head every time a STATUS_DURABLE_ACK frame advances
160160
// any watermark; an entry pops when every (name, seqTxn) it carries is
161161
// covered by durableTableWatermarks. Bounded in practice by the SF on-disk
162-
// cap: once the producer hits sf_max_bytes it blocks, which caps how far
162+
// cap: once the producer hits sf_max_segment_bytes it blocks, which caps how far
163163
// the durable watermark can lag behind the OK watermark.
164164
private final ArrayDeque<PendingDurableEntry> pendingDurable = new ArrayDeque<>();
165165
private final ArrayDeque<PendingDurableEntry> pendingDurablePool = new ArrayDeque<>();

core/src/main/java/io/questdb/client/cutlass/qwp/client/sf/cursor/MmapSegment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ public static MmapSegment create(FilesFacade ff, long pathPtr, String displayPat
177177
// the JVM).
178178
if (!ff.allocate(fd, sizeBytes)) {
179179
ff.close(fd);
180-
// Unlink the partially-created file so a sf_max_bytes-sized
180+
// Unlink the partially-created file so a sf_max_segment_bytes-sized
181181
// empty file does not survive the failure. Under sustained
182182
// disk-full pressure with the manager polling, hundreds would
183183
// otherwise accumulate.

core/src/main/java/io/questdb/client/cutlass/qwp/client/sf/cursor/SegmentRing.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ public static SegmentRing openExisting(String sfDir, long maxBytesPerSegment) {
255255
return null;
256256
}
257257
// Sort by baseSeq ascending. Worst-case segment count is
258-
// sf_max_total_bytes / sf_max_bytes -- at the documented ceiling
258+
// sf_max_total_bytes / sf_max_segment_bytes -- at the documented ceiling
259259
// (1 TiB / 64 MiB) that is ~16K entries, where an O(N²) sort spends
260260
// multiple seconds in compares + shifts before the I/O thread can
261261
// start. In-place quicksort with median-of-three pivot keeps the

core/src/main/java/io/questdb/client/impl/ConfigSchema.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public final class ConfigSchema {
8686
str("sf_append_deadline_millis", Side.INGRESS);
8787
str("sf_dir", Side.INGRESS);
8888
str("sf_durability", Side.INGRESS);
89-
str("sf_max_bytes", Side.INGRESS);
89+
str("sf_max_segment_bytes", Side.INGRESS);
9090
str("sf_max_total_bytes", Side.INGRESS);
9191
str("transaction", Side.INGRESS);
9292

core/src/test/java/io/questdb/client/test/cutlass/qwp/client/QwpQueryClientFromConfigTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ public void testIngressOnlyKeysSilentlyAcceptedOnEgress() {
720720
"sf_append_deadline_millis=30000",
721721
"sf_dir=/var/lib/qdb-sf",
722722
"sf_durability=memory",
723-
"sf_max_bytes=4m",
723+
"sf_max_segment_bytes=4m",
724724
"sf_max_total_bytes=10g",
725725
"transaction=on",
726726
};

core/src/test/java/io/questdb/client/test/cutlass/qwp/client/RecoveryReplayTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public void testRestartReplaysSealedSegmentsAgainstFreshServer() throws Exceptio
8686
String pad = repeat("x", 64);
8787
String cfg1 = "ws::addr=localhost:" + port1
8888
+ ";sf_dir=" + sfDir
89-
+ ";sf_max_bytes=4096"
89+
+ ";sf_max_segment_bytes=4096"
9090
+ ";close_flush_timeout_millis=0;";
9191
try (Sender s1 = Sender.fromConfig(cfg1)) {
9292
for (int i = 0; i < 50; i++) {

core/src/test/java/io/questdb/client/test/cutlass/qwp/client/sf/SfFromConfigTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public void testSfDirOnTcpRejected() throws Exception {
9292
}
9393

9494
@Test
95-
public void testSfMaxBytesParsing() throws Exception {
95+
public void testSfMaxSegmentBytesParsing() throws Exception {
9696
TestUtils.assertMemoryLeak(() -> {
9797
AckHandler handler = new AckHandler();
9898
try (TestWebSocketServer server = new TestWebSocketServer(handler)) {
@@ -101,7 +101,7 @@ public void testSfMaxBytesParsing() throws Exception {
101101

102102
int port = server.getPort();
103103
String config = "ws::addr=localhost:" + port
104-
+ ";sf_dir=" + sfDir + ";sf_max_bytes=131072;";
104+
+ ";sf_dir=" + sfDir + ";sf_max_segment_bytes=131072;";
105105
try (Sender sender = Sender.fromConfig(config)) {
106106
// Write enough data that segments rotate at ~128 KiB boundary.
107107
for (int i = 0; i < 50; i++) {
@@ -139,7 +139,7 @@ public void testNoSfDirMeansNoSf() throws Exception {
139139
}
140140

141141
/**
142-
* Regression test for the connect-string {@code sf_max_bytes} /
142+
* Regression test for the connect-string {@code sf_max_segment_bytes} /
143143
* {@code sf_max_total_bytes} parser accepting values larger than
144144
* {@code Integer.MAX_VALUE}. The pre-cursor parser used parseInt which
145145
* artificially capped the SF size from the connect string at ~2 GiB.
@@ -222,7 +222,7 @@ public void testSfDurabilityOnTcpRejected() throws Exception {
222222
}
223223

224224
@Test
225-
public void testSfMaxBytesAcceptsSizeSuffixes() throws Exception {
225+
public void testSfMaxSegmentBytesAcceptsSizeSuffixes() throws Exception {
226226
TestUtils.assertMemoryLeak(() -> {
227227
AckHandler handler = new AckHandler();
228228
try (TestWebSocketServer server = new TestWebSocketServer(handler)) {
@@ -233,7 +233,7 @@ public void testSfMaxBytesAcceptsSizeSuffixes() throws Exception {
233233
// 64m / 4g should parse identically to their byte-count equivalents.
234234
String config = "ws::addr=localhost:" + port
235235
+ ";sf_dir=" + sfDir
236-
+ ";sf_max_bytes=64m"
236+
+ ";sf_max_segment_bytes=64m"
237237
+ ";sf_max_total_bytes=4g;";
238238
try (Sender sender = Sender.fromConfig(config)) {
239239
sender.table("foo").longColumn("v", 1L).atNow();
@@ -346,14 +346,14 @@ public void testSenderIdInvalidCharRejected() throws Exception {
346346
}
347347

348348
@Test
349-
public void testSfMaxBytesInvalidSizeSuffixRejected() throws Exception {
349+
public void testSfMaxSegmentBytesInvalidSizeSuffixRejected() throws Exception {
350350
TestUtils.assertMemoryLeak(() -> {
351-
String config = "ws::addr=localhost:1;sf_dir=" + sfDir + ";sf_max_bytes=64x;";
351+
String config = "ws::addr=localhost:1;sf_dir=" + sfDir + ";sf_max_segment_bytes=64x;";
352352
try (Sender ignored = Sender.fromConfig(config)) {
353353
Assert.fail("expected rejection of unknown unit suffix");
354354
} catch (LineSenderException expected) {
355355
Assert.assertTrue(expected.getMessage(),
356-
expected.getMessage().contains("invalid sf_max_bytes"));
356+
expected.getMessage().contains("invalid sf_max_segment_bytes"));
357357
}
358358
});
359359
}

core/src/test/java/io/questdb/client/test/cutlass/qwp/client/sf/cursor/SegmentRingTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ public void testNextSealedAfterStillReturnsCorrectlyWhenCursorWasTrimmed() throw
530530

531531
/**
532532
* Open-time sort regression: at the documented {@code sf_max_total_bytes
533-
* / sf_max_bytes} ceiling (~16K segments) an O(N²) sort over the
533+
* / sf_max_segment_bytes} ceiling (~16K segments) an O(N²) sort over the
534534
* recovered segments burns multi-second wall time before the I/O thread
535535
* can start. The previous selection-sort implementation regressed an
536536
* earlier perf fix on the legacy {@code SegmentLog} path; this test

core/src/test/java/io/questdb/client/test/impl/WsSenderConfigHonoredTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public void testEveryIngressKeyIsHonored() {
6161
assertHonored("request_durable_ack=on", "request_durable_ack", true);
6262
assertHonored("sender_id=probe-1", "sender_id", "probe-1");
6363
assertHonored("sf_dir=/var/probe", "sf_dir", "/var/probe");
64-
assertHonored("sf_max_bytes=4096", "sf_max_bytes", 4096L);
64+
assertHonored("sf_max_segment_bytes=4096", "sf_max_segment_bytes", 4096L);
6565
assertHonored("sf_max_total_bytes=8192", "sf_max_total_bytes", 8192L);
6666
assertHonored("sf_durability=flush", "sf_durability", "FLUSH");
6767
assertHonored("sf_append_deadline_millis=1500", "sf_append_deadline_millis", 1500L);

0 commit comments

Comments
 (0)