You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
thrownewIllegalStateException("Fail to create table");
146
+
}
155
147
```
156
148
157
-
## Write data example
149
+
## How to build write data
158
150
```java
159
-
finallong t0 =System.currentTimeMillis();
160
-
finallong t1 = t0 +1000;
161
-
finallong t2 = t1 +1000;
162
-
finalRows data =Series.newBuilder("machine_metric")
163
-
.tag("city", "Singapore")
164
-
.tag("ip", "127.0.0.1")
165
-
.toRowsBuilder()
166
-
// codes below organizes 3 lines data (3 timestamps) for the `cpu` and `mem` column, this will just transport once through network. CeresDB encourage practices like this, because the SDK could use efficient compression algorithm to reduce network traffic and also be friendly to the sever side.
167
-
.field(t0, "cpu", FieldValue.withDouble(0.23)) // first row, first column
168
-
.field(t0, "mem", FieldValue.withDouble(0.55)) // first row, second column
169
-
.field(t1, "cpu", FieldValue.withDouble(0.25)) // second row, first column
170
-
.field(t1, "mem", FieldValue.withDouble(0.56)) // second row, second column
171
-
.field(t2, "cpu", FieldValue.withDouble(0.21)) // third row, first column
172
-
.field(t2, "mem", FieldValue.withDouble(0.52)) // third row, second column
151
+
finalPoint point =Point.newPointBuilder("machine_table")
// here the `future.get` is just for demonstration, a better async programming practice would be using the CompletableFuture API
177
-
finalResult<WriteOk, Err> wr = wf.get();
178
-
179
-
Assert.assertTrue(wr.isOk());
180
-
Assert.assertEquals(3, wr.getOk().getSuccess());
181
-
// `Result` class referenced the Rust language practice, provides rich functions (such as mapXXX, andThen) transforming the result value to improve programming efficiency. You can refer to the API docs for detail usage.
// `Result` class referenced the Rust language practice, provides rich functions (such as mapXXX, andThen) transforming the result value to improve programming efficiency. You can refer to the API docs for detail usage.
.forMetrics("machine_metric") // table name is optional. If not provided, SQL parser will parse the `ql` to get the table name and do the routing automaticly
192
-
.ql("select timestamp, cpu, mem from machine_metric") //
.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
177
+
.sql("select * from machine_table where ts = %d", t0) //
0 commit comments