Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@
import org.apache.arrow.flight.Location;
import org.apache.arrow.memory.BufferAllocator;
import org.apache.arrow.memory.RootAllocator;
import org.apache.arrow.vector.VectorSchemaRoot;
import org.apache.arrow.vector.ipc.ArrowReader;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand All @@ -61,6 +63,8 @@ public class DorisFlightSqlReader extends DorisReader {
private AdbcConnection connection;
private final ArrowReader arrowReader;
private final Boolean datetimeJava8ApiEnabled;
private int totalBatches = 0;
private long totalRows = 0;

public DorisFlightSqlReader(DorisReaderPartition partition) throws Exception {
super(partition);
Expand Down Expand Up @@ -91,7 +95,18 @@ public DorisFlightSqlReader(DorisReaderPartition partition) throws Exception {
public boolean hasNext() throws DorisException {
if (!endOfStream.get() && (rowBatch == null || !rowBatch.hasNext())) {
try {
long batchStart = System.currentTimeMillis();
endOfStream.set(!arrowReader.loadNextBatch());
if (!endOfStream.get()) {
VectorSchemaRoot root = arrowReader.getVectorSchemaRoot();
int rows = root.getRowCount();
totalBatches++;
totalRows += rows;
log.info("Batch loaded: tablet={}, rows={}, cost={}ms",
Arrays.toString(partition.getTablets()), rows, System.currentTimeMillis() - batchStart);
} else {
log.info("No more data from tablet={}", Arrays.toString(partition.getTablets()));
}
} catch (IOException e) {
throw new DorisException(e);
}
Expand All @@ -112,6 +127,8 @@ public Object next() throws DorisException {

@Override
public void close() {
log.info("Partition read finished: tablet={}, batches={}, totalRows={}",
partition.getTablets(), totalBatches, totalRows);
if (rowBatch != null) {
rowBatch.close();
}
Expand Down Expand Up @@ -147,7 +164,9 @@ private ArrowReader executeQuery() throws AdbcException, OptionRequiredException
String flightSql = generateQuerySql(partition);
log.info("Query SQL Sending to Doris FE is: {}", flightSql);
statement.setSqlQuery(flightSql);
long start = System.currentTimeMillis();
AdbcStatement.QueryResult queryResult = statement.executeQuery();
log.info("Query submitted, tablet={}, cost={}ms", Arrays.toString(partition.getTablets()), System.currentTimeMillis() - start);
return queryResult.getReader();
}

Expand Down
Loading