diff --git a/ceresdb-example/src/test/java/io/ceresdb/ReadmeTest.java b/ceresdb-example/src/test/java/io/ceresdb/ReadmeTest.java index 524fa14..754784e 100644 --- a/ceresdb-example/src/test/java/io/ceresdb/ReadmeTest.java +++ b/ceresdb-example/src/test/java/io/ceresdb/ReadmeTest.java @@ -30,7 +30,8 @@ public void readmeTest() throws ExecutionException, InterruptedException { .writeMaxRetries(1) // maximum retry times when read fails // (only some error codes will be retried, such as the routing table failure) - .readMaxRetries(1).build(); + .readMaxRetries(1) + .build(); final CeresDBClient client = new CeresDBClient(); if (!client.init(opts)) { @@ -88,7 +89,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> qf = client.sqlQuery(queryRequest); // here the `future.get` is just for demonstration, a better async programming practice would be using the CompletableFuture API @@ -99,14 +100,6 @@ public void readmeTest() throws ExecutionException, InterruptedException { final SqlQueryOk queryOk = queryResult.getOk(); Assert.assertEquals(3, queryOk.getRowCount()); - // get rows as list - final List rows = queryOk.getRowList(); - Assert.assertEquals(timestamp, rows.get(0).getColumn("ts").getValue().getTimestamp()); - Assert.assertEquals("Singapore", rows.get(0).getColumn("city").getValue().getString()); - Assert.assertEquals("10.0.0.1", rows.get(0).getColumn("ip").getValue().getString()); - Assert.assertEquals(0.23, rows.get(0).getColumn("cpu").getValue().getDouble(), 0.0000001); - Assert.assertEquals(0.55, rows.get(0).getColumn("mem").getValue().getDouble(), 0.0000001); - // get rows as stream final Stream rowStream = queryOk.stream(); rowStream.forEach(row -> System.out.println(row.toString())); diff --git a/ceresdb-protocol/src/main/java/io/ceresdb/util/Utils.java b/ceresdb-protocol/src/main/java/io/ceresdb/util/Utils.java index abffb8e..d95fba5 100644 --- a/ceresdb-protocol/src/main/java/io/ceresdb/util/Utils.java +++ b/ceresdb-protocol/src/main/java/io/ceresdb/util/Utils.java @@ -7,6 +7,7 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -484,7 +485,7 @@ private static List parseArrowRecord(Schema schema, VectorSchemaRoot root) builders.get(rowIdx).setValue(fieldIdx, Value.withStringOrNull(null)); } else { builders.get(rowIdx).setValue(fieldIdx, - Value.withString(new String(varCharVector.get(rowIdx)))); + Value.withString(new String(varCharVector.get(rowIdx), StandardCharsets.UTF_8))); } } break;