This is an automated email from the ASF dual-hosted git repository.

hanahmily pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git


The following commit(s) were added to refs/heads/main by this push:
     new 7d07c78  change operator structure
     new 6626c34  Merge pull request #3 from 
lujiajing1126/feature/change-query-operator-ds
7d07c78 is described below

commit 7d07c780335dce25486b5c773510ebd0f86ef230
Author: Megrez Lu <[email protected]>
AuthorDate: Mon May 31 17:14:37 2021 +0800

    change operator structure
---
 api/fbs/v1/query.fbs          | 18 ++++-----
 api/fbs/v1/query_generated.go | 85 +++++--------------------------------------
 2 files changed, 18 insertions(+), 85 deletions(-)

diff --git a/api/fbs/v1/query.fbs b/api/fbs/v1/query.fbs
index f69dfb0..4677e03 100644
--- a/api/fbs/v1/query.fbs
+++ b/api/fbs/v1/query.fbs
@@ -19,8 +19,11 @@ include "database.fbs";
 
 namespace banyandb.v1;
 
-// BinaryOp specify the operation imposed to the given query condition
-enum BinaryOp: byte {
+// BinaryOp specifies the operation imposed to the given query condition
+// For EQ, NE, LT, GT, LE and GE, only one operand should be given, i.e. 
one-to-one relationship.
+// HAVING and NOT_HAVING allow multi-value to be the operand such as 
array/vector, i.e. one-to-many relationship.
+// For example, "keyA" contains "valueA" **and** "valueB"
+enum BinaryOp : byte {
     EQ,
     NE,
     LT,
@@ -31,11 +34,6 @@ enum BinaryOp: byte {
     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;
@@ -59,9 +57,11 @@ table Pair {
     pair: TypedPair;
 }
 
-// PairQuery consists of the query condition with a binary operator to be 
imposed
+// PairQuery consists of the query condition with a single binary operator to 
be imposed
+// For 1:1 BinaryOp, values in condition must be an array with length = 1,
+// while for 1:N BinaryOp, values can be an array with length >= 1.
 table PairQuery {
-    ops: BinaryOps;
+    op: BinaryOp;
     condition: Pair;
 }
 
diff --git a/api/fbs/v1/query_generated.go b/api/fbs/v1/query_generated.go
index e434166..6990dd0 100644
--- a/api/fbs/v1/query_generated.go
+++ b/api/fbs/v1/query_generated.go
@@ -118,72 +118,6 @@ func (v Sort) String() string {
        return "Sort(" + strconv.FormatInt(int64(v), 10) + ")"
 }
 
-type BinaryOps struct {
-       _tab flatbuffers.Table
-}
-
-func GetRootAsBinaryOps(buf []byte, offset flatbuffers.UOffsetT) *BinaryOps {
-       n := flatbuffers.GetUOffsetT(buf[offset:])
-       x := &BinaryOps{}
-       x.Init(buf, n+offset)
-       return x
-}
-
-func GetSizePrefixedRootAsBinaryOps(buf []byte, offset flatbuffers.UOffsetT) 
*BinaryOps {
-       n := flatbuffers.GetUOffsetT(buf[offset+flatbuffers.SizeUint32:])
-       x := &BinaryOps{}
-       x.Init(buf, n+offset+flatbuffers.SizeUint32)
-       return x
-}
-
-func (rcv *BinaryOps) Init(buf []byte, i flatbuffers.UOffsetT) {
-       rcv._tab.Bytes = buf
-       rcv._tab.Pos = i
-}
-
-func (rcv *BinaryOps) Table() flatbuffers.Table {
-       return rcv._tab
-}
-
-func (rcv *BinaryOps) Ops(j int) BinaryOp {
-       o := flatbuffers.UOffsetT(rcv._tab.Offset(4))
-       if o != 0 {
-               a := rcv._tab.Vector(o)
-               return BinaryOp(rcv._tab.GetInt8(a + flatbuffers.UOffsetT(j*1)))
-       }
-       return 0
-}
-
-func (rcv *BinaryOps) OpsLength() int {
-       o := flatbuffers.UOffsetT(rcv._tab.Offset(4))
-       if o != 0 {
-               return rcv._tab.VectorLen(o)
-       }
-       return 0
-}
-
-func (rcv *BinaryOps) MutateOps(j int, n BinaryOp) bool {
-       o := flatbuffers.UOffsetT(rcv._tab.Offset(4))
-       if o != 0 {
-               a := rcv._tab.Vector(o)
-               return rcv._tab.MutateInt8(a+flatbuffers.UOffsetT(j*1), int8(n))
-       }
-       return false
-}
-
-func BinaryOpsStart(builder *flatbuffers.Builder) {
-       builder.StartObject(1)
-}
-func BinaryOpsAddOps(builder *flatbuffers.Builder, ops flatbuffers.UOffsetT) {
-       builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(ops), 0)
-}
-func BinaryOpsStartOpsVector(builder *flatbuffers.Builder, numElems int) 
flatbuffers.UOffsetT {
-       return builder.StartVector(1, numElems, 1)
-}
-func BinaryOpsEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
-       return builder.EndObject()
-}
-
 type IntPair struct {
        _tab flatbuffers.Table
 }
@@ -417,17 +351,16 @@ func (rcv *PairQuery) Table() flatbuffers.Table {
        return rcv._tab
 }
 
-func (rcv *PairQuery) Ops(obj *BinaryOps) *BinaryOps {
+func (rcv *PairQuery) Op() BinaryOp {
        o := flatbuffers.UOffsetT(rcv._tab.Offset(4))
        if o != 0 {
-               x := rcv._tab.Indirect(o + rcv._tab.Pos)
-               if obj == nil {
-                       obj = new(BinaryOps)
-               }
-               obj.Init(rcv._tab.Bytes, x)
-               return obj
+               return BinaryOp(rcv._tab.GetInt8(o + rcv._tab.Pos))
        }
-       return nil
+       return 0
+}
+
+func (rcv *PairQuery) MutateOp(n BinaryOp) bool {
+       return rcv._tab.MutateInt8Slot(4, int8(n))
 }
 
 func (rcv *PairQuery) Condition(obj *Pair) *Pair {
@@ -446,8 +379,8 @@ func (rcv *PairQuery) Condition(obj *Pair) *Pair {
 func PairQueryStart(builder *flatbuffers.Builder) {
        builder.StartObject(2)
 }
-func PairQueryAddOps(builder *flatbuffers.Builder, ops flatbuffers.UOffsetT) {
-       builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(ops), 0)
+func PairQueryAddOp(builder *flatbuffers.Builder, op BinaryOp) {
+       builder.PrependInt8Slot(0, int8(op), 0)
 }
 func PairQueryAddCondition(builder *flatbuffers.Builder, condition 
flatbuffers.UOffsetT) {
        builder.PrependUOffsetTSlot(1, flatbuffers.UOffsetT(condition), 0)

Reply via email to