Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/main/java/com/aliyun/openservices/log/common/SubStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class SubStore {
private int sortedKeyCount;
private int timeIndex;
private List<SubStoreKey> keys;
private boolean tsMode = false;

public SubStore() {
super();
Expand All @@ -30,6 +31,18 @@ public SubStore(String name, int ttl, int sortedKeyCount, int timeIndex, List<Su
}
}

public SubStore(String name, int ttl, int sortedKeyCount, int timeIndex, List<SubStoreKey> keys, boolean tsMode) {
this.name = name;
this.ttl = ttl;
this.sortedKeyCount = sortedKeyCount;
this.timeIndex = timeIndex;
this.keys = keys;
this.tsMode = tsMode;
if (!isValid()) {
throw new IllegalArgumentException("SubStore is invalid");
}
}

public boolean isValid() {
if (this.sortedKeyCount <= 0 || this.sortedKeyCount >= this.keys.size()) {
return false;
Expand Down Expand Up @@ -94,6 +107,14 @@ public void setKeys(List<SubStoreKey> keys) {
this.keys = keys;
}

public boolean getTsMode() {
return tsMode;
}

public void setTsMode(boolean tsMode) {
this.tsMode = tsMode;
}

public void fromJsonString(String subStoreString) throws LogException {
try {
JSONObject dict = JSONObject.parseObject(subStoreString);
Expand All @@ -108,6 +129,9 @@ private void fromJsonObject(JSONObject dict) {
this.setTtl(dict.getIntValue("ttl"));
this.setSortedKeyCount(dict.getIntValue("sortedKeyCount"));
this.setTimeIndex(dict.getIntValue("timeIndex"));
if (dict.containsKey("tsMode")) {
this.setTsMode(dict.getBooleanValue("tsMode"));
}

if (dict.containsKey("keys")) {
JSONArray keysDict = dict.getJSONArray("keys");
Expand All @@ -133,6 +157,7 @@ public JSONObject toRequestJson() {
subStoreDict.put("ttl", getTtl());
subStoreDict.put("sortedKeyCount", getSortedKeyCount());
subStoreDict.put("timeIndex", getTimeIndex());
subStoreDict.put("tsMode", getTsMode());

JSONArray keysDict = new JSONArray();
for (SubStoreKey key : getKeys()) {
Expand Down