This is an automated email from the ASF dual-hosted git repository. wusheng pushed a commit to branch order_by in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb-java-client.git
commit 95eb3308a9d093a109bd39e8879be3e44a5a1990 Author: Wu Sheng <[email protected]> AuthorDate: Fri Jul 26 10:38:03 2024 +0800 Provide a new method to order data by timestamp --- .../banyandb/v1/client/AbstractQuery.java | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/apache/skywalking/banyandb/v1/client/AbstractQuery.java b/src/main/java/org/apache/skywalking/banyandb/v1/client/AbstractQuery.java index 1de95e2..b255fdd 100644 --- a/src/main/java/org/apache/skywalking/banyandb/v1/client/AbstractQuery.java +++ b/src/main/java/org/apache/skywalking/banyandb/v1/client/AbstractQuery.java @@ -165,7 +165,6 @@ public abstract class AbstractQuery<T> { return b.build(); } - @RequiredArgsConstructor public static class OrderBy { /** * The field name for ordering. @@ -176,9 +175,27 @@ public abstract class AbstractQuery<T> { */ private final Sort type; + /** + * Create an orderBy condition with given rule name and sort type + */ + public OrderBy(final String indexRuleName, final Sort type) { + this.indexRuleName = indexRuleName; + this.type = type; + } + + /** + * Create an orderBy condition with timestamp and sort type + */ + public OrderBy(final Sort type) { + this.indexRuleName = null; + this.type = type; + } + BanyandbModel.QueryOrder build() { final BanyandbModel.QueryOrder.Builder builder = BanyandbModel.QueryOrder.newBuilder(); - builder.setIndexRuleName(indexRuleName); + if (indexRuleName != null) { + builder.setIndexRuleName(indexRuleName); + } builder.setSort( Sort.DESC.equals(type) ? BanyandbModel.Sort.SORT_DESC : BanyandbModel.Sort.SORT_ASC); return builder.build();
