Skip to content

Commit

Permalink
feature/#45 Extend a method query(String entryName, QueryOptions opti…
Browse files Browse the repository at this point in the history
…ons) for Bucket class. Add a QueryOptions class for the new method
  • Loading branch information
Rumpelshtinskiy committed Feb 24, 2025
1 parent 1ca00ff commit 75acf3d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add exists option to BucketSettings. [PR-42](https://github.com/reductstore/reduct-java/issues/42)
- Bucket.writeRecord receives entry name and bucket. [PR-43](https://github.com/reductstore/reduct-java/issues/43)
- Add getBucket method to ReductClient. [PR-44](https://github.com/reductstore/reduct-java/issues/44)
- Extend a method query(String entryName, QueryOptions options) for Bucket class. Add a QueryOptions class for the new method [PR-45](https://github.com/reductstore/reduct-java/issues/45)
### Infrastructure:

- Added GitHub Actions for CI/CD [PR-35](https://github.com/reductstore/reduct-java/pull/35)
12 changes: 12 additions & 0 deletions src/main/java/store/reduct/model/QueryOptions.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package store.reduct.model;

import lombok.Builder;
import lombok.Data;

@Builder
@Data
public class QueryOptions {
private final Long start;
private final Long stop;
private final Long ttl;
}
13 changes: 13 additions & 0 deletions src/main/java/store/reduct/model/bucket/Bucket.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import store.reduct.common.BucketURL;
import store.reduct.common.RecordURL;
import store.reduct.common.exception.ReductException;
import store.reduct.model.QueryOptions;
import store.reduct.model.mapper.BucketMapper;
import store.reduct.model.record.QueryId;
import store.reduct.model.record.Record;
Expand Down Expand Up @@ -288,6 +289,18 @@ public Iterator<Record> query(String entryName, Long start, Long stop, Long ttl)
return new RecordIterator(name, entryName, queryId.getId(), reductClient.getServerProperties().url());
}

/**
* Query records for a time interval
*
* @param entryName
* @param options
* @return
*/
public Iterator<Record> query(String entryName, QueryOptions options)
throws ReductException, IllegalArgumentException {
return query(entryName, options.getStart(), options.getStop(), options.getTtl());
}

public Iterator<Record> getMetaInfos(String entryName, Long start, Long stop, Long ttl)
throws ReductException, IllegalArgumentException {
if (Strings.isBlank(name) || Strings.isBlank(entryName) || Objects.isNull(start) || Objects.isNull(stop)
Expand Down

0 comments on commit 75acf3d

Please sign in to comment.