Skip to content

Commit 02349c4

Browse files
authored
Provide a new method to order data by timestamp (#66)
1 parent 78ab486 commit 02349c4

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/main/java/org/apache/skywalking/banyandb/v1/client/AbstractQuery.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ protected BanyandbModel.TagProjection buildTagProjections(MetadataCache.EntityMe
165165
return b.build();
166166
}
167167

168-
@RequiredArgsConstructor
169168
public static class OrderBy {
170169
/**
171170
* The field name for ordering.
@@ -176,9 +175,27 @@ public static class OrderBy {
176175
*/
177176
private final Sort type;
178177

178+
/**
179+
* Create an orderBy condition with given rule name and sort type
180+
*/
181+
public OrderBy(final String indexRuleName, final Sort type) {
182+
this.indexRuleName = indexRuleName;
183+
this.type = type;
184+
}
185+
186+
/**
187+
* Create an orderBy condition with timestamp and sort type
188+
*/
189+
public OrderBy(final Sort type) {
190+
this.indexRuleName = null;
191+
this.type = type;
192+
}
193+
179194
BanyandbModel.QueryOrder build() {
180195
final BanyandbModel.QueryOrder.Builder builder = BanyandbModel.QueryOrder.newBuilder();
181-
builder.setIndexRuleName(indexRuleName);
196+
if (indexRuleName != null) {
197+
builder.setIndexRuleName(indexRuleName);
198+
}
182199
builder.setSort(
183200
Sort.DESC.equals(type) ? BanyandbModel.Sort.SORT_DESC : BanyandbModel.Sort.SORT_ASC);
184201
return builder.build();

0 commit comments

Comments
 (0)