Skip to content

Commit c11ee05

Browse files
tom-s-powelliamthomaspowellsamikshya-db
authored
Log number of rows in a chunk (#1104)
For debugging purposes it would be useful to understand the number of rows fetched in a chunk. I don't believe this is currently captured anywhere in the existing logs. Co-authored-by: Thomas Powell <tpowell@palantir.com> Co-authored-by: Samikshya Chand <148681192+samikshya-db@users.noreply.github.com>
1 parent f2b2453 commit c11ee05

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

src/main/java/com/databricks/jdbc/api/impl/arrow/AbstractArrowResultChunk.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,12 @@ public abstract class AbstractArrowResultChunk {
6565
static final class ArrowData {
6666
private final List<List<ValueVector>> valueVectors;
6767
private final List<String> metadata;
68+
private final long rowCount;
6869

69-
public ArrowData(List<List<ValueVector>> valueVectors, List<String> metadata) {
70+
public ArrowData(List<List<ValueVector>> valueVectors, List<String> metadata, long rowCount) {
7071
this.valueVectors = valueVectors;
7172
this.metadata = metadata;
73+
this.rowCount = rowCount;
7274
}
7375

7476
public List<List<ValueVector>> getValueVectors() {
@@ -78,6 +80,10 @@ public List<List<ValueVector>> getValueVectors() {
7880
public List<String> getMetadata() {
7981
return metadata;
8082
}
83+
84+
public long getRowCount() {
85+
return rowCount;
86+
}
8187
}
8288

8389
protected AbstractArrowResultChunk(
@@ -291,7 +297,11 @@ protected void initializeData(InputStream inputStream)
291297
ArrowData arrowData = getRecordBatchList(inputStream, rootAllocator, statementId, chunkIndex);
292298
recordBatchList = arrowData.getValueVectors();
293299
arrowMetadata = arrowData.getMetadata();
294-
LOGGER.debug("Data parsed for chunk index {} and statement {}", chunkIndex, statementId);
300+
LOGGER.debug(
301+
"Data parsed for chunk index {} and statement {}. Row count: {}",
302+
chunkIndex,
303+
statementId,
304+
arrowData.getRowCount());
295305
setStatus(ChunkStatus.PROCESSING_SUCCEEDED);
296306
}
297307

@@ -311,10 +321,12 @@ private ArrowData getRecordBatchList(
311321
throws IOException {
312322
List<List<ValueVector>> recordBatchList = new ArrayList<>();
313323
List<String> metadata = new ArrayList<>();
324+
long rowCount = 0L;
314325
try (ArrowStreamReader arrowStreamReader = new ArrowStreamReader(inputStream, rootAllocator)) {
315326
VectorSchemaRoot vectorSchemaRoot = arrowStreamReader.getVectorSchemaRoot();
316327
boolean fetchedMetadata = false;
317328
while (arrowStreamReader.loadNextBatch()) {
329+
rowCount += vectorSchemaRoot.getRowCount();
318330
if (!fetchedMetadata) {
319331
metadata = getMetadataInformationFromSchemaRoot(vectorSchemaRoot);
320332
fetchedMetadata = true;
@@ -338,7 +350,7 @@ private ArrowData getRecordBatchList(
338350
throw e;
339351
}
340352

341-
return new ArrowData(recordBatchList, metadata);
353+
return new ArrowData(recordBatchList, metadata, rowCount);
342354
}
343355

344356
private List<String> getMetadataInformationFromSchemaRoot(VectorSchemaRoot vectorSchemaRoot) {

0 commit comments

Comments
 (0)