Skip to content

Commit ffbcd51

Browse files
clean up code
Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
1 parent d70794f commit ffbcd51

7 files changed

Lines changed: 23 additions & 761 deletions

File tree

src/main/java/com/databricks/jdbc/api/impl/ExecutionResultFactory.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.databricks.jdbc.api.impl.arrow.ArrowStreamResult;
44
import com.databricks.jdbc.api.impl.arrow.LazyThriftInlineArrowResult;
55
import com.databricks.jdbc.api.impl.arrow.StreamingInlineArrowResult;
6+
import com.databricks.jdbc.api.impl.thrift.StreamingColumnarResult;
67
import com.databricks.jdbc.api.impl.volume.VolumeOperationResult;
78
import com.databricks.jdbc.api.internal.IDatabricksConnectionContext;
89
import com.databricks.jdbc.api.internal.IDatabricksSession;

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public StreamingInlineArrowResult(
134134
}
135135
}
136136

137-
LOGGER.info(
137+
LOGGER.debug(
138138
"[STREAMING] StreamingInlineArrowResult initialized - firstBatchRows={}, maxRows={}, maxBatchesInMemory={}",
139139
currentBatch != null ? currentBatch.getRowCount() : 0,
140140
maxRows,
@@ -236,7 +236,7 @@ public boolean next() throws DatabricksSQLException {
236236
currentChunkIterator = chunk.getChunkIterator();
237237
currentChunkIterator.nextRow();
238238

239-
LOGGER.info(
239+
LOGGER.debug(
240240
"[CONSUMER] Moved to batch {} - globalRow={}, batchesInMemory={}",
241241
currentBatch.getBatchIndex(),
242242
globalRowIndex,
@@ -295,7 +295,7 @@ public void close() {
295295
provider.close();
296296
}
297297

298-
LOGGER.info(
298+
LOGGER.debug(
299299
"[STREAMING] Closed - totalRowsFetched={}, rowsConsumed={}", totalRows, globalRowIndex + 1);
300300
}
301301

src/main/java/com/databricks/jdbc/api/impl/streaming/ThriftStreamingProvider.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ private ThriftStreamingProvider(
179179
this.maxBatchesInMemory = Math.max(2, maxBatchesInMemory);
180180
this.batchReadyTimeoutSeconds = timeoutSeconds;
181181

182-
LOGGER.info(
182+
LOGGER.debug(
183183
"Creating ThriftStreamingProvider: maxBatches={}, timeout={}s, processor={}",
184184
this.maxBatchesInMemory,
185185
timeoutSeconds,
@@ -193,14 +193,14 @@ private ThriftStreamingProvider(
193193
totalRowsFetched.addAndGet(initialBatch.getRowCount());
194194
nextRowOffset.set(initialBatch.getRowCount());
195195

196-
LOGGER.info(
196+
LOGGER.debug(
197197
"Initial batch processed: rows={}, hasMoreRows={}",
198198
initialBatch.getRowCount(),
199199
initialBatch.hasMoreRows());
200200

201201
if (!initialBatch.hasMoreRows()) {
202202
endOfStreamReached = true;
203-
LOGGER.info("Single batch result - all data in initial response");
203+
LOGGER.debug("Single batch result - all data in initial response");
204204
}
205205

206206
// Start prefetch thread
@@ -337,14 +337,21 @@ public boolean isEndOfStreamReached() {
337337
public void close() {
338338
if (closed) return;
339339

340-
LOGGER.info("Closing ThriftStreamingProvider, total rows: {}", totalRowsFetched.get());
340+
LOGGER.debug("Closing ThriftStreamingProvider, total rows: {}", totalRowsFetched.get());
341341
closed = true;
342342

343343
notifyConsumerAdvanced();
344344
notifyBatchAvailable();
345345

346+
// Interrupt and wait for prefetch thread to terminate before releasing resources
346347
if (prefetchThread != null) {
347348
prefetchThread.interrupt();
349+
try {
350+
prefetchThread.join(5000); // Wait up to 5s for clean shutdown
351+
} catch (InterruptedException e) {
352+
Thread.currentThread().interrupt();
353+
LOGGER.debug("Interrupted while waiting for prefetch thread to terminate");
354+
}
348355
}
349356

350357
// Release all batches using type-safe release action
@@ -431,7 +438,7 @@ private void fetchNextBatchInternal() throws DatabricksSQLException {
431438

432439
if (!batch.hasMoreRows()) {
433440
endOfStreamReached = true;
434-
LOGGER.info("End of stream at batch {}", batchIndex);
441+
LOGGER.debug("End of stream at batch {}", batchIndex);
435442
}
436443

437444
notifyBatchAvailable();

src/main/java/com/databricks/jdbc/api/impl/thrift/StreamingColumnarResult.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public StreamingColumnarResult(
114114
currentBatch = provider.getCurrentBatch();
115115
}
116116

117-
LOGGER.info(
117+
LOGGER.debug(
118118
"[STREAMING] StreamingColumnarResult initialized - firstBatchRows={}, maxRows={}, maxBatchesInMemory={}",
119119
currentBatch != null ? currentBatch.getRowCount() : 0,
120120
maxRows,
@@ -204,7 +204,7 @@ public boolean next() throws DatabricksSQLException {
204204
currentBatchRowIndex = 0;
205205

206206
// Log batch transition
207-
LOGGER.info(
207+
LOGGER.debug(
208208
"[CONSUMER] Moved to batch {} - globalRow={}, batchesInMemory={}",
209209
currentBatch.getBatchIndex(),
210210
globalRowIndex,
@@ -220,7 +220,7 @@ public boolean next() throws DatabricksSQLException {
220220

221221
// Log progress periodically (every 500K rows)
222222
if (globalRowIndex > 0 && globalRowIndex % 500000 == 0) {
223-
LOGGER.info(
223+
LOGGER.debug(
224224
"[CONSUMER] Progress - rows={}, batch={}, batchesInMemory={}",
225225
globalRowIndex,
226226
currentBatch.getBatchIndex(),
@@ -274,7 +274,7 @@ public void close() {
274274
provider.close();
275275
}
276276

277-
LOGGER.info(
277+
LOGGER.debug(
278278
"[STREAMING] Closed - totalRowsFetched={}, rowsConsumed={}", totalRows, globalRowIndex + 1);
279279
}
280280

src/main/java/com/databricks/jdbc/api/impl/thrift/ThriftBatch.java

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

src/main/java/com/databricks/jdbc/api/impl/thrift/ThriftBatchFetcherImpl.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ public TFetchResultsResp fetchNextBatch() throws DatabricksSQLException {
4747
"ThriftBatchFetcher is closed", DatabricksDriverErrorCode.STATEMENT_CLOSED);
4848
}
4949

50-
LOGGER.debug("Fetching next batch for statement {}", statement.getStatementId());
50+
LOGGER.debug(
51+
"Fetching next batch for statement {}",
52+
statement != null ? statement.getStatementId() : "null");
5153
long startTime = System.currentTimeMillis();
5254

5355
TFetchResultsResp response = session.getDatabricksClient().getMoreResults(statement);

0 commit comments

Comments
 (0)