Skip to content

Commit 48d253b

Browse files
limit validity Bytebuffers after query submit
1 parent 8ada411 commit 48d253b

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

src/main/java/io/tiledb/java/api/Query.java

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -133,27 +133,35 @@ public QueryStatus submit() throws TileDBError {
133133
// Set the actual number of bytes received to each ByteBuffer
134134
for (String attribute : byteBuffers_.keySet()) {
135135
boolean isVar;
136+
boolean isNullable = false;
137+
Datatype datatype;
136138

137139
try (ArraySchema arraySchema = array.getSchema()) {
138140
if (arraySchema.hasAttribute(attribute)) {
139141
try (Attribute attr = arraySchema.getAttribute(attribute)) {
140142
isVar = attr.isVar();
143+
isNullable = attr.getNullable();
144+
datatype = attr.getType();
141145
}
142146
} else {
143147
try (Dimension dim = arraySchema.getDomain().getDimension(attribute)) {
144148
isVar = dim.isVar();
149+
datatype = dim.getType();
145150
}
146151
}
147152
}
148153

154+
int nbytes = this.buffer_sizes_.get(attribute).getSecond().getitem(0).intValue();
155+
this.byteBuffers_.get(attribute).getSecond().limit(nbytes);
156+
149157
if (isVar) {
150158
int offset_nbytes = this.buffer_sizes_.get(attribute).getFirst().getitem(0).intValue();
151-
int data_nbytes = this.buffer_sizes_.get(attribute).getSecond().getitem(0).intValue();
152159
this.byteBuffers_.get(attribute).getFirst().limit(offset_nbytes);
153-
this.byteBuffers_.get(attribute).getSecond().limit(data_nbytes);
154-
} else {
155-
int nbytes = this.buffer_sizes_.get(attribute).getSecond().getitem(0).intValue();
156-
this.byteBuffers_.get(attribute).getSecond().limit(nbytes);
160+
}
161+
162+
if (isNullable) {
163+
int validity_nbytes = nbytes / datatype.getNativeSize();
164+
this.validityByteMapsByteBuffers_.get(attribute).limit(validity_nbytes);
157165
}
158166
}
159167

@@ -177,27 +185,35 @@ public QueryStatus submitAndFinalize() throws TileDBError {
177185
// Set the actual number of bytes received to each ByteBuffer
178186
for (String attribute : byteBuffers_.keySet()) {
179187
boolean isVar;
188+
boolean isNullable = false;
189+
Datatype datatype;
180190

181191
try (ArraySchema arraySchema = array.getSchema()) {
182192
if (arraySchema.hasAttribute(attribute)) {
183193
try (Attribute attr = arraySchema.getAttribute(attribute)) {
184194
isVar = attr.isVar();
195+
isNullable = attr.getNullable();
196+
datatype = attr.getType();
185197
}
186198
} else {
187199
try (Dimension dim = arraySchema.getDomain().getDimension(attribute)) {
188200
isVar = dim.isVar();
201+
datatype = dim.getType();
189202
}
190203
}
191204
}
192205

206+
int nbytes = this.buffer_sizes_.get(attribute).getSecond().getitem(0).intValue();
207+
this.byteBuffers_.get(attribute).getSecond().limit(nbytes);
208+
193209
if (isVar) {
194210
int offset_nbytes = this.buffer_sizes_.get(attribute).getFirst().getitem(0).intValue();
195-
int data_nbytes = this.buffer_sizes_.get(attribute).getSecond().getitem(0).intValue();
196211
this.byteBuffers_.get(attribute).getFirst().limit(offset_nbytes);
197-
this.byteBuffers_.get(attribute).getSecond().limit(data_nbytes);
198-
} else {
199-
int nbytes = this.buffer_sizes_.get(attribute).getSecond().getitem(0).intValue();
200-
this.byteBuffers_.get(attribute).getSecond().limit(nbytes);
212+
}
213+
214+
if (isNullable) {
215+
int validity_nbytes = nbytes / datatype.getNativeSize();
216+
this.validityByteMapsByteBuffers_.get(attribute).limit(validity_nbytes);
201217
}
202218
}
203219

0 commit comments

Comments
 (0)