Feature - maxDeletedEntryId, entriesAdded, recordedFirstEntryId properties added to StreamInfo object #5092

pull/5099/head
Nikita Koksharov 2 years ago
parent 066b5f2bb6
commit 30ba066050

@ -64,6 +64,9 @@ public class StreamInfo<K, V> {
StreamMessageId lastGeneratedId;
Entry<K, V> firstEntry;
Entry<K, V> lastEntry;
StreamMessageId maxDeletedEntryId;
int entriesAdded;
StreamMessageId recordedFirstEntryId;
/**
* Returns length of the stream
@ -149,4 +152,42 @@ public class StreamInfo<K, V> {
this.lastEntry = lastEntry;
}
/**
* Returns the maximal entry ID that was deleted from the stream
*
* @return StreamMessageId object
*/
public StreamMessageId getMaxDeletedEntryId() {
return maxDeletedEntryId;
}
public StreamInfo<K, V> setMaxDeletedEntryId(StreamMessageId maxDeletedEntryId) {
this.maxDeletedEntryId = maxDeletedEntryId;
return this;
}
/**
* Returns the count of all entries added to the stream during its lifetime
*
* @return entries count
*/
public int getEntriesAdded() {
return entriesAdded;
}
public StreamInfo<K, V> setEntriesAdded(int entriesAdded) {
this.entriesAdded = entriesAdded;
return this;
}
/**
* Returns the first ID what was added to the stream
*
* @return StreamMessageId object
*/
public StreamMessageId getRecordedFirstEntryId() {
return recordedFirstEntryId;
}
public StreamInfo<K, V> setRecordedFirstEntryId(StreamMessageId recordedFirstEntryId) {
this.recordedFirstEntryId = recordedFirstEntryId;
return this;
}
}

@ -38,6 +38,9 @@ public class StreamInfoDecoder implements MultiDecoder<StreamInfo<Object, Object
private static final String LAST_GENERATED_ID_KEY = "last-generated-id";
private static final String FIRST_ENTRY_KEY = "first-entry";
private static final String LAST_ENTRY_KEY = "last-entry";
private static final String MAX_DELETED_ENTRY_ID = "max-deleted-entry-id";
private static final String ENTRIES_ADDED = "entries-added";
private static final String RECORDED_FIRST_ENTRY_ID = "recorded-first-entry-id";
@Override
public StreamInfo<Object, Object> decode(List<Object> parts, State state) {
@ -53,6 +56,9 @@ public class StreamInfoDecoder implements MultiDecoder<StreamInfo<Object, Object
info.setRadixTreeNodes(((Long) map.get(RADIX_TREE_NODES_KEY)).intValue());
info.setGroups(((Long) map.get(GROUPS_KEY)).intValue());
info.setLastGeneratedId(StreamIdConvertor.INSTANCE.convert(map.get(LAST_GENERATED_ID_KEY)));
info.setMaxDeletedEntryId(StreamIdConvertor.INSTANCE.convert(map.getOrDefault(MAX_DELETED_ENTRY_ID, "0-0")));
info.setRecordedFirstEntryId(StreamIdConvertor.INSTANCE.convert(map.getOrDefault(RECORDED_FIRST_ENTRY_ID, "0-0")));
info.setEntriesAdded(((Long) map.getOrDefault(ENTRIES_ADDED, -1L)).intValue());
List<?> firstEntry = (List<?>) map.get(FIRST_ENTRY_KEY);
if (firstEntry != null) {

Loading…
Cancel
Save