You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2021/05/25 09:55:22 UTC

[GitHub] [skywalking-banyandb] kezhenxu94 commented on a change in pull request #2: Add definitions for Query module in flatbuffers

kezhenxu94 commented on a change in pull request #2:
URL: https://github.com/apache/skywalking-banyandb/pull/2#discussion_r638634801



##########
File path: api/fbs/v1/query.fbs
##########
@@ -0,0 +1,133 @@
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you 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.
+
+namespace banyandb.v1;
+
+// BinaryOp specify the operation imposed to the given query condition
+enum BinaryOp: byte {
+    EQ,
+    NE,
+    LT,
+    GT,
+    LE,
+    GE,
+    HAVING,
+    NOT_HAVING
+}
+
+// BinaryOps is an array of binary operators.
+table BinaryOps {
+    ops: [BinaryOp];
+}
+
+// IntPair in a typed pair with an array of int64 as values
+table IntPair {
+    key: string;
+    values: [int64];
+}
+
+// StrPair in a typed pair with an array of string as values
+table StrPair {
+    key: string;
+    values: [string];
+}
+
+// Pair is the building block of a record which is equivalent to a key-value pair.
+// In the context of Trace, it could be metadata of a trace such as service_name, serivce_instance, etc.
+// Besides, other fields/tags are organized in key-value pair in the underlying storage layer.
+// One should notice that the values can be a multi-value.
+union TypedPair { IntPair, StrPair }
+
+// Pair is a workaround since vector of unions is not yet supported in some of languages.
+table Pair {
+    pair: TypedPair;
+}
+
+// PairQuery consists of the query condition with a binary operator to be imposed
+table PairQuery {
+    ops: BinaryOps;
+    condition: Pair;
+}
+
+// Sort is either descending or ascending
+enum Sort : byte {
+    DESC,
+    ASC
+}
+
+// QueryOrder means a Sort operation to be done for a given field.
+// The key_name refers to the key of a Pair.
+table QueryOrder {
+    key_name: string;
+    sort: Sort;
+}
+
+// Entity represents a Span defined in Google Dapper paper.
+// Or equivalently a Segment in Skywalking.
+table Entity {
+    // entity_id could be span_id of a Span or segment_id of a Segment
+    entity_id: string;
+    // start_time_nanoseconds is the start time of the entity in timeunit of nanosecond
+    start_time_nanoseconds: uint64;
+    // data_binary contains all unindexed Tags and other key-value pairs
+    data_binary: [ubyte];
+    // fields contains all indexed Field. Some typical names,
+    // - trace_id
+    // - duration
+    // - service_name
+    // - service_instance_id
+    // - end_time_nanoseconds
+    fields: [Pair];
+}
+
+// TracesResponse is the response for a query to the Query module. 
+table TracesResponse {
+    // entities are the actual data returned
+    entities: [Entity];
+}
+
+// Projection is used to select the names of keys to be returned.
+table Projection {
+    // The key_name refers to the key(s) of Pair(s).
+    key_names: [string];
+}
+
+// RangeQuery is a range query for uint64
+table RangeQuery {
+    start: uint64;
+    end: uint64;
+    ops: BinaryOps;
+}
+
+// EntityCriteria is the request contract for query.
+table EntityCriteria {
+    // start_time_nanoseconds is a range query with start/end time of the entity in timeunit of nanoseconds
+    // it is always recommended to specify time range for performance reason
+    start_time_nanoseconds: RangeQuery;

Review comment:
       ```suggestion
       time_range_nanoseconds: RangeQuery;
   ```

##########
File path: api/fbs/v1/query.fbs
##########
@@ -0,0 +1,133 @@
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you 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.
+
+namespace banyandb.v1;
+
+// BinaryOp specify the operation imposed to the given query condition
+enum BinaryOp: byte {
+    EQ,
+    NE,
+    LT,
+    GT,
+    LE,
+    GE,
+    HAVING,
+    NOT_HAVING
+}
+
+// BinaryOps is an array of binary operators.
+table BinaryOps {
+    ops: [BinaryOp];
+}
+
+// IntPair in a typed pair with an array of int64 as values
+table IntPair {
+    key: string;
+    values: [int64];
+}
+
+// StrPair in a typed pair with an array of string as values
+table StrPair {
+    key: string;
+    values: [string];
+}
+
+// Pair is the building block of a record which is equivalent to a key-value pair.
+// In the context of Trace, it could be metadata of a trace such as service_name, serivce_instance, etc.
+// Besides, other fields/tags are organized in key-value pair in the underlying storage layer.
+// One should notice that the values can be a multi-value.
+union TypedPair { IntPair, StrPair }
+
+// Pair is a workaround since vector of unions is not yet supported in some of languages.
+table Pair {
+    pair: TypedPair;
+}
+
+// PairQuery consists of the query condition with a binary operator to be imposed
+table PairQuery {
+    ops: BinaryOps;
+    condition: Pair;
+}
+
+// Sort is either descending or ascending
+enum Sort : byte {
+    DESC,
+    ASC
+}
+
+// QueryOrder means a Sort operation to be done for a given field.
+// The key_name refers to the key of a Pair.
+table QueryOrder {
+    key_name: string;
+    sort: Sort;
+}
+
+// Entity represents a Span defined in Google Dapper paper.
+// Or equivalently a Segment in Skywalking.
+table Entity {
+    // entity_id could be span_id of a Span or segment_id of a Segment
+    entity_id: string;
+    // start_time_nanoseconds is the start time of the entity in timeunit of nanosecond
+    start_time_nanoseconds: uint64;
+    // data_binary contains all unindexed Tags and other key-value pairs
+    data_binary: [ubyte];
+    // fields contains all indexed Field. Some typical names,
+    // - trace_id
+    // - duration
+    // - service_name
+    // - service_instance_id
+    // - end_time_nanoseconds
+    fields: [Pair];
+}
+
+// TracesResponse is the response for a query to the Query module. 
+table TracesResponse {
+    // entities are the actual data returned
+    entities: [Entity];
+}
+
+// Projection is used to select the names of keys to be returned.
+table Projection {
+    // The key_name refers to the key(s) of Pair(s).
+    key_names: [string];
+}
+
+// RangeQuery is a range query for uint64
+table RangeQuery {
+    start: uint64;
+    end: uint64;
+    ops: BinaryOps;

Review comment:
       Since the name `RangeQuery` is already clear enough, I don't think we need `ops`.
   
   For range query, it's usually `[lower, upper)`, namely, lower bound is inclusive and upper bound is exclusive.

##########
File path: api/fbs/v1/query.fbs
##########
@@ -0,0 +1,133 @@
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you 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.
+
+namespace banyandb.v1;
+
+// BinaryOp specify the operation imposed to the given query condition
+enum BinaryOp: byte {
+    EQ,
+    NE,
+    LT,
+    GT,
+    LE,
+    GE,
+    HAVING,
+    NOT_HAVING
+}
+
+// BinaryOps is an array of binary operators.
+table BinaryOps {
+    ops: [BinaryOp];
+}
+
+// IntPair in a typed pair with an array of int64 as values
+table IntPair {
+    key: string;
+    values: [int64];
+}
+
+// StrPair in a typed pair with an array of string as values
+table StrPair {
+    key: string;
+    values: [string];
+}
+
+// Pair is the building block of a record which is equivalent to a key-value pair.
+// In the context of Trace, it could be metadata of a trace such as service_name, serivce_instance, etc.
+// Besides, other fields/tags are organized in key-value pair in the underlying storage layer.
+// One should notice that the values can be a multi-value.
+union TypedPair { IntPair, StrPair }
+
+// Pair is a workaround since vector of unions is not yet supported in some of languages.
+table Pair {
+    pair: TypedPair;
+}
+
+// PairQuery consists of the query condition with a binary operator to be imposed
+table PairQuery {
+    ops: BinaryOps;
+    condition: Pair;
+}
+
+// Sort is either descending or ascending
+enum Sort : byte {
+    DESC,
+    ASC
+}
+
+// QueryOrder means a Sort operation to be done for a given field.
+// The key_name refers to the key of a Pair.
+table QueryOrder {
+    key_name: string;
+    sort: Sort;
+}
+
+// Entity represents a Span defined in Google Dapper paper.
+// Or equivalently a Segment in Skywalking.
+table Entity {
+    // entity_id could be span_id of a Span or segment_id of a Segment
+    entity_id: string;
+    // start_time_nanoseconds is the start time of the entity in timeunit of nanosecond
+    start_time_nanoseconds: uint64;
+    // data_binary contains all unindexed Tags and other key-value pairs
+    data_binary: [ubyte];
+    // fields contains all indexed Field. Some typical names,
+    // - trace_id
+    // - duration
+    // - service_name
+    // - service_instance_id
+    // - end_time_nanoseconds
+    fields: [Pair];
+}
+
+// TracesResponse is the response for a query to the Query module. 
+table TracesResponse {
+    // entities are the actual data returned
+    entities: [Entity];
+}
+
+// Projection is used to select the names of keys to be returned.
+table Projection {
+    // The key_name refers to the key(s) of Pair(s).
+    key_names: [string];
+}
+
+// RangeQuery is a range query for uint64
+table RangeQuery {
+    start: uint64;
+    end: uint64;
+    ops: BinaryOps;
+}
+
+// EntityCriteria is the request contract for query.
+table EntityCriteria {
+    // start_time_nanoseconds is a range query with start/end time of the entity in timeunit of nanoseconds

Review comment:
       ```suggestion
       // time_range_nanoseconds is a range query with start/end time of the entity in time unit of nanoseconds
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org