提交 d4de8d0c 编写于 作者: G Gao Hongtao

Update some fields

Signed-off-by: NGao Hongtao <hanahmily@gmail.com>
上级 207a5dfa
...@@ -34,32 +34,32 @@ public interface FieldAndValue extends Field { ...@@ -34,32 +34,32 @@ public interface FieldAndValue extends Field {
static FieldAndValue build(Banyandb.TypedPair typedPair) { static FieldAndValue build(Banyandb.TypedPair typedPair) {
if (typedPair.hasIntPair()) { if (typedPair.hasIntPair()) {
final Banyandb.IntPair intPair = typedPair.getIntPair(); final Banyandb.Int intPair = typedPair.getIntPair();
if (intPair.getIsNull()) { if (typedPair.getIsNull()) {
return new LongFieldPair(intPair.getKey(), null); return new LongFieldPair(typedPair.getKey(), null);
} else { } else {
return new LongFieldPair(intPair.getKey(), intPair.getValue()); return new LongFieldPair(typedPair.getKey(), intPair.getValue());
} }
} else if (typedPair.hasStrPair()) { } else if (typedPair.hasStrPair()) {
final Banyandb.StrPair strPair = typedPair.getStrPair(); final Banyandb.Str strPair = typedPair.getStrPair();
if (strPair.getIsNull()) { if (typedPair.getIsNull()) {
return new StringFieldPair(strPair.getKey(), null); return new StringFieldPair(typedPair.getKey(), null);
} else { } else {
return new StringFieldPair(strPair.getKey(), strPair.getValue()); return new StringFieldPair(typedPair.getKey(), strPair.getValue());
} }
} else if (typedPair.hasIntArrayPair()) { } else if (typedPair.hasIntArrayPair()) {
final Banyandb.IntArrayPair intArrayPair = typedPair.getIntArrayPair(); final Banyandb.IntArray intArrayPair = typedPair.getIntArrayPair();
if (intArrayPair.getIsNull()) { if (typedPair.getIsNull()) {
return new LongArrayFieldPair(intArrayPair.getKey(), null); return new LongArrayFieldPair(typedPair.getKey(), null);
} else { } else {
return new LongArrayFieldPair(intArrayPair.getKey(), intArrayPair.getValueList()); return new LongArrayFieldPair(typedPair.getKey(), intArrayPair.getValueList());
} }
} else if (typedPair.hasStrArrayPair()) { } else if (typedPair.hasStrArrayPair()) {
final Banyandb.StrArrayPair strArrayPair = typedPair.getStrArrayPair(); final Banyandb.StrArray strArrayPair = typedPair.getStrArrayPair();
if (strArrayPair.getIsNull()) { if (typedPair.getIsNull()) {
return new StringArrayFieldPair(strArrayPair.getKey(), null); return new StringArrayFieldPair(typedPair.getKey(), null);
} else { } else {
return new StringArrayFieldPair(strArrayPair.getKey(), strArrayPair.getValueList()); return new StringArrayFieldPair(typedPair.getKey(), strArrayPair.getValueList());
} }
} }
throw new IllegalArgumentException("Unrecognized TypedPair, " + typedPair); throw new IllegalArgumentException("Unrecognized TypedPair, " + typedPair);
......
...@@ -47,9 +47,8 @@ public abstract class PairQueryCondition { ...@@ -47,9 +47,8 @@ public abstract class PairQueryCondition {
.setOp(BINARY_OP_EQ) .setOp(BINARY_OP_EQ)
.setCondition( .setCondition(
Banyandb.TypedPair.newBuilder() Banyandb.TypedPair.newBuilder()
.setIntPair( .setKey(fieldName).setIntPair(
Banyandb.IntPair.newBuilder() Banyandb.Int.newBuilder()
.setKey(fieldName)
.setValue(value))) .setValue(value)))
.build(); .build();
} }
......
...@@ -19,38 +19,38 @@ syntax = "proto3"; ...@@ -19,38 +19,38 @@ syntax = "proto3";
option java_package = "org.apache.skywalking.banyandb.v1.trace"; option java_package = "org.apache.skywalking.banyandb.v1.trace";
package banyandb.v1.trace; package banyandb.trace.v1;
import "google/protobuf/timestamp.proto"; import "google/protobuf/timestamp.proto";
import "google/protobuf/struct.proto"; import "google/protobuf/struct.proto";
import "banyandb/v1/banyandb.proto"; import "banyandb/v1/banyandb.proto";
service TraceService { service TraceService {
rpc Query(banyandb.v1.trace.QueryRequest) returns (banyandb.v1.trace.QueryResponse); rpc Query(banyandb.trace.v1.QueryRequest) returns (banyandb.trace.v1.QueryResponse);
rpc Write(stream banyandb.v1.trace.WriteRequest) returns (stream banyandb.v1.trace.WriteResponse); rpc Write(stream banyandb.trace.v1.WriteRequest) returns (stream banyandb.trace.v1.WriteResponse);
} }
// QueryRequest is the request contract for query. // QueryRequest is the request contract for query.
message QueryRequest { message QueryRequest {
// metadata is required // metadata is required
Metadata metadata = 1; banyandb.v1.Metadata metadata = 1;
// time_range is a range query with begin/end time of entities in the timeunit of nanoseconds. // time_range is a range query with begin/end time of entities in the timeunit of nanoseconds.
// In the context of Trace, it represents the range of the `startTime` for spans/segments, // In the context of Trace, it represents the range of the `startTime` for spans/segments,
// while in the context of Log, it means the range of the timestamp(s) for logs. // while in the context of Log, it means the range of the timestamp(s) for logs.
// it is always recommended to specify time range for performance reason // it is always recommended to specify time range for performance reason
TimeRange time_range = 2; banyandb.v1.TimeRange time_range = 2;
// offset is used to support pagination, together with the following limit // offset is used to support pagination, together with the following limit
uint32 offset = 3; uint32 offset = 3;
// limit is used to impose a boundary on the number of records being returned // limit is used to impose a boundary on the number of records being returned
uint32 limit = 4; uint32 limit = 4;
// order_by is given to specify the sort for a field. So far, only fields in the type of Integer are supported // order_by is given to specify the sort for a field. So far, only fields in the type of Integer are supported
QueryOrder order_by = 5; banyandb.v1.QueryOrder order_by = 5;
// fields are indexed. Some typical fields are listed below, // fields are indexed. Some typical fields are listed below,
// - trace_id: if given, it takes precedence over other fields and will be used to retrieve entities before other conditions are imposed // - trace_id: if given, it takes precedence over other fields and will be used to retrieve entities before other conditions are imposed
// - duration: typical for trace context // - duration: typical for trace context
repeated PairQuery fields = 6; repeated banyandb.v1.PairQuery fields = 6;
// projection can be used to select the key names of the entities in the response // projection can be used to select the key names of the entities in the response
Projection projection = 7; banyandb.v1.Projection projection = 7;
} }
// QueryResponse is the response for a query to the Query module. // QueryResponse is the response for a query to the Query module.
...@@ -77,13 +77,13 @@ message Entity { ...@@ -77,13 +77,13 @@ message Entity {
// - service_name // - service_name
// - service_instance_id // - service_instance_id
// - end_time_nanoseconds // - end_time_nanoseconds
repeated TypedPair fields = 4; repeated banyandb.v1.TypedPair fields = 4;
} }
message WriteRequest { message WriteRequest {
// the metadata is only required in the first write. // the metadata is only required in the first write.
Metadata metadata = 1; banyandb.v1.Metadata metadata = 1;
// the entity is required. // the entity is required.
EntityValue entity = 2; EntityValue entity = 2;
} }
...@@ -103,5 +103,5 @@ message EntityValue { ...@@ -103,5 +103,5 @@ message EntityValue {
// Pair only has value, as the value of PairValue match with the key // Pair only has value, as the value of PairValue match with the key
// by the index rules and index rule bindings of Metadata group. // by the index rules and index rule bindings of Metadata group.
// indexed fields of multiple entities are compression in the fields. // indexed fields of multiple entities are compression in the fields.
repeated Field fields = 4; repeated banyandb.v1.Field fields = 4;
} }
\ No newline at end of file
...@@ -32,44 +32,18 @@ message Metadata { ...@@ -32,44 +32,18 @@ message Metadata {
string name = 2; string name = 2;
} }
// IntPair in a typed pair with an int64 as values
message IntPair {
string key = 1;
int64 value = 2;
bool isNull = 3;
}
// StrPair in a typed pair with a string as values
message StrPair {
string key = 1;
string value = 2;
bool isNull = 3;
}
// IntPair in a typed pair with an array of int64 as values
message IntArrayPair {
string key = 1;
repeated int64 value = 2;
bool isNull = 3;
}
// StrPair in a typed pair with an array of string as values
message StrArrayPair {
string key = 1;
repeated string value = 2;
bool isNull = 3;
}
// Pair is the building block of a record which is equivalent to a key-value pair. // 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, service_instance, etc. // In the context of Trace, it could be metadata of a trace such as service_name, service_instance, etc.
// Besides, other fields/tags are organized in key-value pair in the underlying storage layer. // 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. // One should notice that the values can be a multi-value.
message TypedPair { message TypedPair {
string key = 1;
bool is_null = 2;
oneof typed { oneof typed {
IntPair int_pair = 1; Int int_pair = 3;
StrPair str_pair = 2; Str str_pair = 4;
IntArrayPair int_array_pair = 3; IntArray int_array_pair = 5;
StrArrayPair str_array_pair = 4; StrArray str_array_pair = 6;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册