You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by lu...@apache.org on 2022/05/01 12:42:15 UTC

[skywalking-banyandb-java-client] branch support-measure created (now b94cbd5)

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

lujiajing pushed a change to branch support-measure
in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb-java-client.git


      at b94cbd5  add id query

This branch includes the following new commits:

     new b94cbd5  add id query

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[skywalking-banyandb-java-client] 01/01: add id query

Posted by lu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

lujiajing pushed a commit to branch support-measure
in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb-java-client.git

commit b94cbd54e15603e99831c54b778fe7fd7677b138
Author: Megrez Lu <lu...@gmail.com>
AuthorDate: Sun May 1 20:42:03 2022 +0800

    add id query
---
 .../banyandb/v1/client/PairQueryCondition.java     | 23 +++++++++++++++++++---
 .../skywalking/banyandb/v1/client/TagAndValue.java | 20 +++++++++++++++++++
 2 files changed, 40 insertions(+), 3 deletions(-)

diff --git a/src/main/java/org/apache/skywalking/banyandb/v1/client/PairQueryCondition.java b/src/main/java/org/apache/skywalking/banyandb/v1/client/PairQueryCondition.java
index f2f2b0c..13210eb 100644
--- a/src/main/java/org/apache/skywalking/banyandb/v1/client/PairQueryCondition.java
+++ b/src/main/java/org/apache/skywalking/banyandb/v1/client/PairQueryCondition.java
@@ -159,6 +159,24 @@ public abstract class PairQueryCondition<T> {
         }
     }
 
+    public static class IDQueryCondition extends PairQueryCondition<String> {
+        private IDQueryCondition(String tagName, BanyandbModel.Condition.BinaryOp op, String value) {
+            super(op, new TagAndValue.IDTagPair(tagName, value));
+        }
+
+        /**
+         * Build a query condition for {@link String} type
+         * and {@link BanyandbModel.Condition.BinaryOp#BINARY_OP_EQ} as the relation
+         *
+         * @param tagName name of the tag
+         * @param val     value of the tag
+         * @return a query that `String == value`
+         */
+        public static PairQueryCondition<String> eq(String tagName, String val) {
+            return new IDQueryCondition(tagName, BanyandbModel.Condition.BinaryOp.BINARY_OP_EQ, val);
+        }
+    }
+
     /**
      * StringArrayQueryCondition represents `tag(List of String) $op value` condition.
      */
@@ -264,9 +282,8 @@ public abstract class PairQueryCondition<T> {
          * Build a query condition for {@link List} of {@link Long} as the type
          * and {@link BanyandbModel.Condition.BinaryOp#BINARY_OP_NOT_HAVING} as the relation
          *
-         * @param tagFamilyName family name of the tag
-         * @param tagName       name of the tag
-         * @param val           value of the tag
+         * @param tagName name of the tag
+         * @param val     value of the tag
          * @return a query that `[Long] not having values`
          */
         public static PairQueryCondition<List<Long>> notHaving(String tagName, List<Long> val) {
diff --git a/src/main/java/org/apache/skywalking/banyandb/v1/client/TagAndValue.java b/src/main/java/org/apache/skywalking/banyandb/v1/client/TagAndValue.java
index 32cd163..e8d8872 100644
--- a/src/main/java/org/apache/skywalking/banyandb/v1/client/TagAndValue.java
+++ b/src/main/java/org/apache/skywalking/banyandb/v1/client/TagAndValue.java
@@ -104,6 +104,26 @@ public abstract class TagAndValue<T> extends Value<T> {
         return new StringTagPair(tagName, value);
     }
 
+    @EqualsAndHashCode(callSuper = true)
+    public static class IDTagPair extends TagAndValue<String> {
+        IDTagPair(final String tagName, final String value) {
+            super(tagName, value);
+        }
+
+        @Override
+        protected BanyandbModel.TagValue buildTypedTagValue() {
+            return BanyandbModel.TagValue.newBuilder()
+                    .setId(BanyandbModel.ID
+                            .newBuilder()
+                            .setValue(value).build())
+                    .build();
+        }
+    }
+
+    public static TagAndValue<String> newIDTag(final String tagName, final String value) {
+        return new IDTagPair(tagName, value);
+    }
+
     @EqualsAndHashCode(callSuper = true)
     public static class StringArrayTagPair extends TagAndValue<List<String>> {
         StringArrayTagPair(final String tagName, final List<String> value) {