Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions ceresdb-example/src/test/java/io/ceresdb/ReadmeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void readmeTest() throws ExecutionException, InterruptedException {

final SqlQueryRequest queryRequest = SqlQueryRequest.newBuilder()
.forTables("machine_table") // table name is optional. If not provided, SQL parser will parse the `sql` to get the table name and do the routing automaticly
.sql("select * from machine_table where ts = %d", timestamp) //
.sql("select * from machine_table where ts >= %d", timestamp) //
.build();
final CompletableFuture<Result<SqlQueryOk, Err>> qf = client.sqlQuery(queryRequest);
// here the `future.get` is just for demonstration, a better async programming practice would be using the CompletableFuture API
Expand All @@ -97,7 +97,7 @@ public void readmeTest() throws ExecutionException, InterruptedException {
Assert.assertTrue(queryResult.isOk());

final SqlQueryOk queryOk = queryResult.getOk();
Assert.assertEquals(1, queryOk.getRowCount());
Assert.assertEquals(3, queryOk.getRowCount());

// get rows as list
final List<Row> rows = queryOk.getRowList();
Expand Down
8 changes: 6 additions & 2 deletions ceresdb-protocol/src/main/java/io/ceresdb/util/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
Expand Down Expand Up @@ -467,8 +468,11 @@ private static List<Row> parseArrowBatch(ByteString batch, Storage.ArrowPayload.
}

private static List<Row> parseArrowRecord(Schema schema, VectorSchemaRoot root) {
List<Row.RowBuilder> builders = Collections.nCopies(root.getRowCount(),
Row.newRowBuilder(schema.getFields().size()));
// init row builders
List<Row.RowBuilder> builders = new ArrayList<>(root.getRowCount());
for (int i = 0; i < root.getRowCount(); i++) {
builders.add(Row.newRowBuilder(schema.getFields().size()));
}

String[] fields = new String[schema.getFields().size()];
for (int fieldIdx = 0; fieldIdx < schema.getFields().size(); fieldIdx++) {
Expand Down