Skip to content

Commit 3de3e23

Browse files
committed
delta datagram size estimation
1 parent 0c20920 commit 3de3e23

8 files changed

Lines changed: 1989 additions & 1048 deletions

File tree

TODO.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# TODO
2+
3+
## QWP UDP Sender
4+
5+
### Documented limitation: mixing `atNow()` with `atMicros()` / `atNanos()`
6+
7+
Current behavior in `QwpUdpSender` is to reject this pattern once committed rows already exist for the table:
8+
9+
1. Write row(s) with `atNow()` (server-assigned designated timestamp).
10+
2. Start a later row and finish it with `atMicros()` or `atNanos()`.
11+
12+
The sender throws:
13+
14+
- `schema change in middle of row is not supported`
15+
16+
Why this happens:
17+
18+
- `atNow()` does not write the designated timestamp column.
19+
- `atMicros()` / `atNanos()` writes designated timestamp into the empty-name column (`""`).
20+
- With committed rows already present, introducing this column is treated as schema evolution.
21+
- The UDP incremental-estimate policy forbids schema changes in the middle of an in-progress row.
22+
23+
Current workaround:
24+
25+
- Use one designated timestamp strategy consistently per table stream:
26+
- always `atNow()`, or
27+
- always `atMicros()` / `atNanos()`.
28+
29+
Future fix options:
30+
31+
- Add explicit support for switching designated timestamp strategy mid-stream by pre-materializing designated timestamp schema state, or
32+
- Harmonize designated timestamp handling so `atNow()` and `atMicros()` / `atNanos()` do not diverge schema shape.

core/src/main/java/io/questdb/client/cutlass/qwp/client/NativeBufferWriter.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,17 @@ public static int utf8Length(String s) {
8181
return len;
8282
}
8383

84+
/**
85+
* Returns the number of bytes required to encode {@code value} as an
86+
* unsigned LEB128 varint.
87+
*/
88+
public static int varintSize(long value) {
89+
if (value == 0) {
90+
return 1;
91+
}
92+
return (64 - Long.numberOfLeadingZeros(value) + 6) / 7;
93+
}
94+
8495
@Override
8596
public void close() {
8697
if (bufferPtr != 0) {

core/src/main/java/io/questdb/client/cutlass/qwp/client/QwpDatagramSizeEstimator.java

Lines changed: 0 additions & 215 deletions
This file was deleted.

0 commit comments

Comments
 (0)