Skip to content

Commit

Permalink
feat: update protos and make it work (#19)
Browse files Browse the repository at this point in the history
* feat: update protos and make it work

* ci: update greptimedb to 0.3.0

* feat: impl write_batch, close #20

* refactor: spec for write_batch

* ci: update greptimedb to 0.3.0
  • Loading branch information
killme2008 authored Jun 5, 2023
1 parent 28c9644 commit 6e37ec0
Show file tree
Hide file tree
Showing 11 changed files with 560 additions and 71 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/erlang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- uses: actions/checkout@v3
- name: Setup greptimedb
run: |
GREPTIMEDB_VER=v0.2.0
GREPTIMEDB_VER=v0.3.0
DOWNLOAD_URL=https://github.com/GreptimeTeam/greptimedb
curl -L ${DOWNLOAD_URL}/releases/download/${GREPTIMEDB_VER}/greptime-linux-amd64.tgz -o /tmp/greptimedb-${GREPTIMEDB_VER}-linux-amd64.tar.gz
mkdir -p /tmp/greptimedb-download
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ greptimedb-client-erl
An Erlang client library for [GreptimeDB](https://github.com/GreptimeTeam/greptimedb).

> **_NOTE:_** GreptimeDB and this project is under heavy development. Do not use it in production at the moment.
> 0.1.0: only working for GreptimeDB 0.2, otherwise for the latest GreptimeDB releases.
## Usage

Expand Down Expand Up @@ -51,6 +52,17 @@ Write data by rows:
greptimedb:write(Client, Metric, Points).
```

Batch write:
```erlang
Metric1 = <<"temperatures">>,
Points1 = [...],
Metric2 = <<"humidities">>,
Points2 = [...],
Batch = [{Metric1, Points1}, {Metric2, Points}],

{ok, _} = greptimedb:write_batch(Client, Batch).
```

Streaming write:

```erlang
Expand Down
22 changes: 19 additions & 3 deletions protos/column.proto
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
// Copyright 2023 Greptime Team
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package greptime.v1;

option java_package="io.greptime.v1";
option java_package = "io.greptime.v1";
option java_outer_classname = "Columns";
option go_package = "github.com/GreptimeTeam/greptime-proto/go/greptime/v1";

Expand Down Expand Up @@ -43,7 +57,8 @@ message Column {
}
// The array of non-null values in this column.
//
// For example: suppose there is a column "foo" that contains some int32 values (1, 2, 3, 4, 5, null, 7, 8, 9, null);
// For example: suppose there is a column "foo" that contains some int32
// values (1, 2, 3, 4, 5, null, 7, 8, 9, null);
// column:
// column_name: foo
// semantic_type: Tag
Expand All @@ -52,7 +67,8 @@ message Column {
Values values = 3;

// Mask maps the positions of null values.
// If a bit in null_mask is 1, it indicates that the column value at that position is null.
// If a bit in null_mask is 1, it indicates that the column value at that
// position is null.
bytes null_mask = 4;

// Helpful in creating vector from column.
Expand Down
26 changes: 17 additions & 9 deletions protos/common.proto
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright 2023 Greptime Team
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package greptime.v1;
Expand Down Expand Up @@ -31,14 +45,8 @@ message Basic {
string password = 2;
}

message Token {
string token = 1;
}
message Token { string token = 1; }

message AffectedRows {
uint32 value = 1;
}
message AffectedRows { uint32 value = 1; }

message FlightMetadata {
AffectedRows affected_rows = 1;
}
message FlightMetadata { AffectedRows affected_rows = 1; }
41 changes: 37 additions & 4 deletions protos/database.proto
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright 2023 Greptime Team
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package greptime.v1;
Expand All @@ -19,26 +33,30 @@ service GreptimeDatabase {
message GreptimeRequest {
RequestHeader header = 1;
oneof request {
InsertRequest insert = 2;
InsertRequests inserts = 2;
QueryRequest query = 3;
DdlRequest ddl = 4;
DeleteRequest delete = 5;
}
}

message GreptimeResponse {
ResponseHeader header = 1;
oneof response {
AffectedRows affected_rows = 2;
}
oneof response { AffectedRows affected_rows = 2; }
}

message QueryRequest {
oneof query {
string sql = 1;
bytes logical_plan = 2;
// PromRangeQuery prom_range_query = 3;
}
}

message InsertRequests {
repeated InsertRequest inserts = 1;
}

message InsertRequest {
string table_name = 1;

Expand All @@ -53,3 +71,18 @@ message InsertRequest {
// The region number of current insert request.
uint32 region_number = 5;
}

message DeleteRequest {
// The table name to delete from. Catalog name and schema name are in the
// `RequestHeader`.
string table_name = 1;

// The region number of current delete request.
uint32 region_number = 2;

// The data to delete, indexed by key columns.
repeated Column key_columns = 3;

// The row count of all columns above.
uint32 row_count = 4;
}
15 changes: 14 additions & 1 deletion protos/health.proto
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright 2023 Greptime Team
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package greptime.v1;
Expand All @@ -6,7 +20,6 @@ option java_package = "io.greptime.v1";
option java_outer_classname = "Health";
option go_package = "github.com/GreptimeTeam/greptime-proto/go/greptime/v1";


service HealthCheck {
rpc HealthCheck(HealthCheckRequest) returns (HealthCheckResponse);
}
Expand Down
Loading

0 comments on commit 6e37ec0

Please sign in to comment.