Skip to content

Commit aa55767

Browse files
committed
Renaem nullable -> use/hasNullBitmap
"Nullable" is a confusing concept due to QuestDB null sentinels, which means a "non-nullable" column could still hold nulls via sentinel values.
1 parent 8afd5f6 commit aa55767

9 files changed

Lines changed: 36 additions & 36 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ private void encodeColumn(
5858
) {
5959
long dataAddr = col.getDataAddress();
6060

61-
if (colDef.isNullable()) {
61+
if (colDef.hasNullBitmap()) {
6262
writeNullBitmap(col, rowCount);
6363
}
6464

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ private static int utf8Length(CharSequence s) {
703703
return len;
704704
}
705705

706-
private QwpTableBuffer.ColumnBuffer acquireColumn(CharSequence name, byte type, boolean nullable) {
706+
private QwpTableBuffer.ColumnBuffer acquireColumn(CharSequence name, byte type, boolean useNullBitmap) {
707707
QwpTableBuffer.ColumnBuffer col = currentTableBuffer.getExistingColumn(name, type);
708708
if (col == null && currentTableBuffer.getRowCount() > 0) {
709709
// schema change while having some rows accumulated -> we flush committed rows of the current table
@@ -718,7 +718,7 @@ private QwpTableBuffer.ColumnBuffer acquireColumn(CharSequence name, byte type,
718718
}
719719

720720
if (col == null) {
721-
col = currentTableBuffer.getOrCreateColumn(name, type, nullable);
721+
col = currentTableBuffer.getOrCreateColumn(name, type, useNullBitmap);
722722
}
723723
return col;
724724
}
@@ -1043,7 +1043,7 @@ private long estimateCurrentDatagramSizeWithInProgressRow(int targetRows) {
10431043
for (int i = 0; i < inProgressColumnCount; i++) {
10441044
InProgressColumnState state = inProgressColumns[i];
10451045
estimate += state.payloadEstimateDelta;
1046-
if (state.nullable) {
1046+
if (state.useNullBitmap) {
10471047
estimate += bitmapBytes(targetRows) - bitmapBytes(state.sizeBefore);
10481048
}
10491049
}
@@ -1343,7 +1343,7 @@ private static final class InProgressColumnState {
13431343
private int arrayDataOffsetBefore;
13441344
private int arrayShapeOffsetBefore;
13451345
private QwpTableBuffer.ColumnBuffer column;
1346-
private boolean nullable;
1346+
private boolean useNullBitmap;
13471347
private long payloadEstimateDelta;
13481348
private int sizeBefore;
13491349
private long stringDataSizeBefore;
@@ -1356,13 +1356,13 @@ void captureAfterWrite() {
13561356

13571357
void clear() {
13581358
column = null;
1359-
nullable = false;
1359+
useNullBitmap = false;
13601360
payloadEstimateDelta = 0;
13611361
}
13621362

13631363
void of(QwpTableBuffer.ColumnBuffer column) {
13641364
this.column = column;
1365-
this.nullable = column.usesNullBitmap();
1365+
this.useNullBitmap = column.usesNullBitmap();
13661366
this.payloadEstimateDelta = 0;
13671367
this.sizeBefore = column.getSize();
13681368
this.valueCountBefore = column.getValueCount();

core/src/main/java/io/questdb/client/cutlass/qwp/protocol/QwpColumnDef.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,33 +34,33 @@
3434
*/
3535
public final class QwpColumnDef {
3636
private final String name;
37-
private final boolean nullable;
37+
private final boolean hasNullBitmap;
3838
private final byte typeCode;
3939

4040
/**
4141
* Creates a column definition.
4242
*
4343
* @param name the column name (UTF-8)
44-
* @param typeCode the QWP v1 type code (0x01-0x0F, optionally OR'd with 0x80 for nullable)
44+
* @param typeCode the QWP v1 type code (0x01-0x0F, optionally OR'd with 0x80 for null bitmap)
4545
*/
4646
public QwpColumnDef(String name, byte typeCode) {
4747
this.name = name;
48-
// Extract nullable flag (high bit) and base type
49-
this.nullable = (typeCode & 0x80) != 0;
48+
// Extract null bitmap flag (high bit) and base type
49+
this.hasNullBitmap = (typeCode & 0x80) != 0;
5050
this.typeCode = (byte) (typeCode & 0x7F);
5151
}
5252

5353
/**
54-
* Creates a column definition with explicit nullable flag.
54+
* Creates a column definition with explicit null bitmap flag.
5555
*
56-
* @param name the column name
57-
* @param typeCode the base type code (0x01-0x0F)
58-
* @param nullable whether the column is nullable
56+
* @param name the column name
57+
* @param typeCode the base type code (0x01-0x0F)
58+
* @param hasNullBitmap whether the column has a null bitmap
5959
*/
60-
public QwpColumnDef(String name, byte typeCode, boolean nullable) {
60+
public QwpColumnDef(String name, byte typeCode, boolean hasNullBitmap) {
6161
this.name = name;
6262
this.typeCode = (byte) (typeCode & 0x7F);
63-
this.nullable = nullable;
63+
this.hasNullBitmap = hasNullBitmap;
6464
}
6565

6666
@Override
@@ -69,7 +69,7 @@ public boolean equals(Object o) {
6969
if (o == null || getClass() != o.getClass()) return false;
7070
QwpColumnDef that = (QwpColumnDef) o;
7171
return typeCode == that.typeCode &&
72-
nullable == that.nullable &&
72+
hasNullBitmap == that.hasNullBitmap &&
7373
name.equals(that.name);
7474
}
7575

@@ -81,7 +81,7 @@ public String getName() {
8181
}
8282

8383
/**
84-
* Gets the base type code (without nullable flag).
84+
* Gets the base type code (without null bitmap flag).
8585
*
8686
* @return type code 0x01-0x0F
8787
*/
@@ -97,34 +97,34 @@ public String getTypeName() {
9797
}
9898

9999
/**
100-
* Gets the wire type code (with nullable flag if applicable).
100+
* Gets the wire type code (with null bitmap flag if applicable).
101101
*
102102
* @return type code as sent on wire
103103
*/
104104
public byte getWireTypeCode() {
105-
return nullable ? (byte) (typeCode | 0x80) : typeCode;
105+
return hasNullBitmap ? (byte) (typeCode | 0x80) : typeCode;
106106
}
107107

108108
@Override
109109
public int hashCode() {
110110
int result = name.hashCode();
111111
result = 31 * result + typeCode;
112-
result = 31 * result + (nullable ? 1 : 0);
112+
result = 31 * result + (hasNullBitmap ? 1 : 0);
113113
return result;
114114
}
115115

116116
/**
117-
* Returns true if this column is nullable.
117+
* Returns true if this column has a null bitmap.
118118
*/
119-
public boolean isNullable() {
120-
return nullable;
119+
public boolean hasNullBitmap() {
120+
return hasNullBitmap;
121121
}
122122

123123
@Override
124124
public String toString() {
125125
StringBuilder sb = new StringBuilder();
126126
sb.append(name).append(':').append(getTypeName());
127-
if (nullable) {
127+
if (hasNullBitmap) {
128128
sb.append('?');
129129
}
130130
return sb.toString();

core/src/main/java/io/questdb/client/cutlass/qwp/protocol/QwpConstants.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ public static int getFixedTypeSize(byte typeCode) {
309309
*/
310310
public static String getTypeName(byte typeCode) {
311311
int code = typeCode & TYPE_MASK;
312-
boolean nullable = (typeCode & TYPE_NULLABLE_FLAG) != 0;
312+
boolean hasNullBitmap = (typeCode & TYPE_NULLABLE_FLAG) != 0;
313313
String name;
314314
switch (code) {
315315
case TYPE_BOOLEAN:
@@ -382,7 +382,7 @@ public static String getTypeName(byte typeCode) {
382382
name = "UNKNOWN(" + code + ")";
383383
break;
384384
}
385-
return nullable ? name + "?" : name;
385+
return hasNullBitmap ? name + "?" : name;
386386
}
387387

388388
/**

core/src/main/java/io/questdb/client/cutlass/qwp/protocol/QwpSchemaHash.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public static long computeSchemaHashDirect(io.questdb.client.std.ObjList<QwpTabl
152152
hasher.update((byte) (0x80 | (c & 0x3F)));
153153
}
154154
}
155-
// Wire type code: type | (nullable ? 0x80 : 0)
155+
// Wire type code: type | (useNullBitmap ? 0x80 : 0)
156156
byte wireType = (byte) (col.getType() | (col.useNullBitmap ? 0x80 : 0));
157157
hasher.update(wireType);
158158
}

core/src/main/java/io/questdb/client/cutlass/qwp/protocol/QwpTableBuffer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public ColumnBuffer getExistingColumn(CharSequence name, byte type) {
205205
* semantics. The check is a single field comparison on the hot path and has
206206
* no measurable cost.
207207
*/
208-
public ColumnBuffer getOrCreateColumn(CharSequence name, byte type, boolean nullable) {
208+
public ColumnBuffer getOrCreateColumn(CharSequence name, byte type, boolean useNullBitmap) {
209209
if (name == null || name.length() == 0) {
210210
throw new LineSenderException("column name cannot be empty");
211211
}
@@ -217,7 +217,7 @@ public ColumnBuffer getOrCreateColumn(CharSequence name, byte type, boolean null
217217
return existing.size <= rowCount ? existing : null;
218218
}
219219
if (TableUtils.isValidColumnName(name, MAX_COLUMN_NAME_LENGTH)) {
220-
return createColumn(name, type, nullable);
220+
return createColumn(name, type, useNullBitmap);
221221
}
222222
throw new LineSenderException(
223223
name.length() > MAX_COLUMN_NAME_LENGTH ? "column name too long [maxLength=" + MAX_COLUMN_NAME_LENGTH + "]"
@@ -361,8 +361,8 @@ private static void assertColumnType(CharSequence name, byte type, ColumnBuffer
361361
}
362362
}
363363

364-
private ColumnBuffer createColumn(CharSequence name, byte type, boolean nullable) {
365-
ColumnBuffer col = new ColumnBuffer(Chars.toString(name), type, nullable);
364+
private ColumnBuffer createColumn(CharSequence name, byte type, boolean useNullBitmap) {
365+
ColumnBuffer col = new ColumnBuffer(Chars.toString(name), type, useNullBitmap);
366366
col.sender = sender;
367367
int index = columns.size();
368368
col.index = index;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public void testEdgeCase_nullSymbolValues() throws Exception {
184184
GlobalSymbolDictionary globalDict = new GlobalSymbolDictionary();
185185

186186
try (QwpTableBuffer batch = new QwpTableBuffer("test")) {
187-
QwpTableBuffer.ColumnBuffer col = batch.getOrCreateColumn("sym", TYPE_SYMBOL, true); // nullable
187+
QwpTableBuffer.ColumnBuffer col = batch.getOrCreateColumn("sym", TYPE_SYMBOL, true); // useNullBitmap
188188

189189
int aaplId = globalDict.getOrAddSymbol("AAPL");
190190
col.addSymbolWithGlobalId("AAPL", aaplId);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2164,7 +2164,7 @@ private void decodeBooleans(Object[] values, boolean[] nulls, int valueCount) {
21642164
}
21652165

21662166
private ColumnValues decodeColumn(QwpColumnDef def, int rowCount) {
2167-
boolean[] nulls = def.isNullable() ? reader.readNullBitmap(rowCount) : new boolean[rowCount];
2167+
boolean[] nulls = def.hasNullBitmap() ? reader.readNullBitmap(rowCount) : new boolean[rowCount];
21682168
int valueCount = rowCount - countNulls(nulls);
21692169
Object[] values = new Object[rowCount];
21702170

core/src/test/java/io/questdb/client/test/cutlass/qwp/protocol/QwpColumnDefTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public void testValidateNullableCharType() {
8080
byte nullableChar = (byte) (QwpConstants.TYPE_CHAR | QwpConstants.TYPE_NULLABLE_FLAG);
8181
QwpColumnDef col = new QwpColumnDef("ch", nullableChar);
8282
col.validate();
83-
assertTrue(col.isNullable());
83+
assertTrue(col.hasNullBitmap());
8484
assertEquals(QwpConstants.TYPE_CHAR, col.getTypeCode());
8585
}
8686

0 commit comments

Comments
 (0)