@@ -56,7 +56,7 @@ The following table creation statement(using the SQL API included in SDK )sh
5656
5757``` java
5858// Create table manually, creating table schema ahead of data ingestion is not required
59- String createTableSql = " CREATE TABLE IF NOT EXISTS machine_table(" + " ts TIMESTAMP NOT NULL, " + //
59+ String createTableSql = " CREATE TABLE IF NOT EXISTS machine_table(" +
6060 " ts TIMESTAMP NOT NULL," +
6161 " city STRING TAG NOT NULL," +
6262 " ip STRING TAG NOT NULL," +
@@ -93,9 +93,12 @@ List<Point> pointList = new LinkedList<>();
9393for (int i = 0 ; i < 100 ; i++ ) {
9494 // build one point
9595 final Point point = Point . newPointBuilder(" machine_table" )
96- .setTimestamp(t0). addTag(" city" , " Singapore" )
97- .addTag(" ip" , " 10.0.0.1" ). addField(" cpu" , Value . withDouble(0.23 ))
98- .addField(" mem" , Value . withDouble(0.55 )). build();
96+ .setTimestamp(t0)
97+ .addTag(" city" , " Singapore" )
98+ .addTag(" ip" , " 10.0.0.1" )
99+ .addField(" cpu" , Value . withDouble(0.23 ))
100+ .addField(" mem" , Value . withDouble(0.55 ))
101+ .build();
99102 points. add(point);
100103}
101104```
@@ -133,11 +136,11 @@ Assert.assertEquals(1, queryOk.getRowCount());
133136
134137// get rows as list
135138final List<Row > rows = queryOk. getRowList();
136- Assert . assertEquals(t0, rows. get(0 ). getColumnValue (" ts" ). getTimestamp());
137- Assert . assertEquals(" Singapore" , rows. get(0 ). getColumnValue (" city" ). getString());
138- Assert . assertEquals(" 10.0.0.1" , rows. get(0 ). getColumnValue (" ip" ). getString());
139- Assert . assertEquals(0.23 , rows. get(0 ). getColumnValue (" cpu" ). getDouble(), 0.0000001 );
140- Assert . assertEquals(0.55 , rows. get(0 ). getColumnValue (" mem" ). getDouble(), 0.0000001 );
139+ Assert . assertEquals(t0, rows. get(0 ). getColumn (" ts" ) . getValue( ). getTimestamp());
140+ Assert . assertEquals(" Singapore" , rows. get(0 ). getColumn (" city" ) . getValue( ). getString());
141+ Assert . assertEquals(" 10.0.0.1" , rows. get(0 ). getColumn (" ip" ) . getValue( ). getString());
142+ Assert . assertEquals(0.23 , rows. get(0 ). getColumn (" cpu" ) . getValue( ). getDouble(), 0.0000001 );
143+ Assert . assertEquals(0.55 , rows. get(0 ). getColumn (" mem" ) . getValue( ). getDouble(), 0.0000001 );
141144
142145// get rows as stream
143146final Stream<Row > rowStream = queryOk. stream();
@@ -154,18 +157,15 @@ CeresDB support streaming writing and reading,suitable for large-scale data re
154157long start = System . currentTimeMillis();
155158long t = start;
156159final StreamWriteBuf<Point , WriteOk > writeBuf = client. streamWrite(" machine_table" );
157-
158160for (int i = 0 ; i < 1000 ; i++ ) {
159- final List<Point > streamData = Point . newPointsBuilder(" machine_table" )
160- .addPoint()
161- .setTimestamp(t)
162- .addTag(" city" , " Beijing" )
163- .addTag(" ip" , " 10.0.0.3" )
164- .addField(" cpu" , Value . withDouble(0.42 ))
165- .addField(" mem" , Value . withDouble(0.67 ))
166- .build()
167- .build();
168- writeBuf. writeAndFlush(streamData);
161+ final Point streamData = Point . newPointBuilder(" machine_table" )
162+ .setTimestamp(t)
163+ .addTag(" city" , " Beijing" )
164+ .addTag(" ip" , " 10.0.0.3" )
165+ .addField(" cpu" , Value . withDouble(0.42 ))
166+ .addField(" mem" , Value . withDouble(0.67 ))
167+ .build();
168+ writeBuf. writeAndFlush(Collections . singletonList(streamData));
169169 t = t+ 1 ;
170170}
171171final CompletableFuture<WriteOk > writeOk = writeBuf. completed();
0 commit comments