Skip to content

Commit 77bbeba

Browse files
bluestreak01claude
andcommitted
Drop dangling TYPE_STRING references
The previous merge (#12) removed TYPE_STRING from QwpConstants but left references in the decoder hot paths and one example. Replace the TYPE_STRING || TYPE_VARCHAR unions with TYPE_VARCHAR alone, drop the TYPE_STRING entry from the symbol-vs-varchar dispatch in getColumnValue/lookupStringBytes, and update the hardening test + the TypedResultExample to advertise/consume TYPE_VARCHAR on the wire. The module now compiles and all QWP decoder/table-buffer tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 3e826cb commit 77bbeba

4 files changed

Lines changed: 7 additions & 8 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ public Object getValue(int col, int row) {
403403
if (wt == QwpConstants.TYPE_BOOLEAN) return getBool(col, row);
404404
if (wt == QwpConstants.TYPE_FLOAT) return getFloat(col, row);
405405
if (wt == QwpConstants.TYPE_DOUBLE) return getDouble(col, row);
406-
if (wt == QwpConstants.TYPE_STRING || wt == QwpConstants.TYPE_SYMBOL) return getString(col, row);
406+
if (wt == QwpConstants.TYPE_SYMBOL) return getString(col, row);
407407
if (wt == QwpConstants.TYPE_VARCHAR) return getVarchar(col, row);
408408
if (wt == QwpConstants.TYPE_UUID || wt == QwpConstants.TYPE_DECIMAL128
409409
|| wt == QwpConstants.TYPE_LONG256 || wt == QwpConstants.TYPE_DECIMAL256) {
@@ -562,7 +562,7 @@ private DirectUtf8Sequence lookupStringBytes(int col, int row, DirectUtf8String
562562
QwpColumnLayout l = columnLayouts.getQuick(col);
563563
byte wt = l.info.wireType;
564564
int denseIdx = l.denseIndex(row);
565-
if (wt == QwpConstants.TYPE_STRING || wt == QwpConstants.TYPE_VARCHAR) {
565+
if (wt == QwpConstants.TYPE_VARCHAR) {
566566
int startOff = Unsafe.getUnsafe().getInt(l.valuesAddr + 4L * denseIdx);
567567
int endOff = Unsafe.getUnsafe().getInt(l.valuesAddr + 4L * (denseIdx + 1));
568568
return view.of(l.stringBytesAddr + startOff, l.stringBytesAddr + endOff);

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -584,9 +584,8 @@ private long parseColumn(QwpColumnLayout layout, int rowCount, long p, long limi
584584
layout.info.scale = Unsafe.getUnsafe().getByte(p++) & 0xFF;
585585
return advanceFixed(layout, p, limit, 32);
586586
}
587-
if (wt == QwpConstants.TYPE_STRING || wt == QwpConstants.TYPE_VARCHAR
588-
|| wt == QwpConstants.TYPE_BINARY) {
589-
// STRING/VARCHAR/BINARY all share the (N+1) x uint32 offsets + concatenated bytes layout.
587+
if (wt == QwpConstants.TYPE_VARCHAR || wt == QwpConstants.TYPE_BINARY) {
588+
// VARCHAR/BINARY share the (N+1) x uint32 offsets + concatenated bytes layout.
590589
// BINARY differs only in that the bytes are opaque (no UTF-8 contract).
591590
return parseStringColumn(layout, p, limit);
592591
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,10 +461,10 @@ private static int writeStringResultBatch(long buf, int nonNull, int totalBytes)
461461
p = putVarint(p, 1L); // column_count
462462
p = putByte(p, QwpConstants.SCHEMA_MODE_FULL);
463463
p = putVarint(p, 0L); // schema_id
464-
// Schema entries (full): one column "s" of TYPE_STRING
464+
// Schema entries (full): one column "s" of TYPE_VARCHAR
465465
p = putVarint(p, 1L); // column name length
466466
p = putByte(p, (byte) 's');
467-
p = putByte(p, QwpConstants.TYPE_STRING);
467+
p = putByte(p, QwpConstants.TYPE_VARCHAR);
468468
// Column body: null_flag = 0 (no nulls), offsets[nonNull+1] u32, then bytes.
469469
p = putByte(p, (byte) 0); // null_flag
470470
for (int i = 0; i < nonNull; i++) {

examples/src/main/java/com/example/query/TypedResultExample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ private static void appendCell(StringBuilder out, QwpColumnBatch batch, int col,
8484
out.append(batch.getFloat(col, row));
8585
} else if (type == QwpConstants.TYPE_DOUBLE) {
8686
out.append(batch.getDouble(col, row));
87-
} else if (type == QwpConstants.TYPE_STRING || type == QwpConstants.TYPE_SYMBOL) {
87+
} else if (type == QwpConstants.TYPE_SYMBOL) {
8888
out.append(batch.getString(col, row));
8989
} else if (type == QwpConstants.TYPE_VARCHAR) {
9090
out.append(new String(batch.getVarchar(col, row)));

0 commit comments

Comments
 (0)