From 30ba06605097142d7d6df66fff42ec2758be0b62 Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Thu, 8 Jun 2023 12:05:34 +0300 Subject: [PATCH] Feature - maxDeletedEntryId, entriesAdded, recordedFirstEntryId properties added to StreamInfo object #5092 --- .../java/org/redisson/api/StreamInfo.java | 85 ++++++++++++++----- .../protocol/decoder/StreamInfoDecoder.java | 6 ++ 2 files changed, 69 insertions(+), 22 deletions(-) diff --git a/redisson/src/main/java/org/redisson/api/StreamInfo.java b/redisson/src/main/java/org/redisson/api/StreamInfo.java index 61f0dc30e..aa31657fe 100644 --- a/redisson/src/main/java/org/redisson/api/StreamInfo.java +++ b/redisson/src/main/java/org/redisson/api/StreamInfo.java @@ -19,7 +19,7 @@ import java.util.Map; /** * Object containing details about Stream - * + * * @author Nikita Koksharov * * @param key type @@ -28,18 +28,18 @@ import java.util.Map; public class StreamInfo { public static class Entry { - + final StreamMessageId id; final Map data; - + public Entry(StreamMessageId id, Map data) { this.id = id; this.data = data; } - + /** * Returns StreamMessageId of this stream entry. - * + * * @return StreamMessageId object */ public StreamMessageId getId() { @@ -48,15 +48,15 @@ public class StreamInfo { /** * Returns data stored in this stream entry - * + * * @return Map object */ public Map getData() { return data; } - + } - + int length; int radixTreeKeys; int radixTreeNodes; @@ -64,10 +64,13 @@ public class StreamInfo { StreamMessageId lastGeneratedId; Entry firstEntry; Entry lastEntry; - + StreamMessageId maxDeletedEntryId; + int entriesAdded; + StreamMessageId recordedFirstEntryId; + /** * Returns length of the stream - * + * * @return length of the stream */ public int getLength() { @@ -76,10 +79,10 @@ public class StreamInfo { public void setLength(int length) { this.length = length; } - + /** * Returns amount of keys allocated by Radix tree of the stream. - * + * * @return amount of keys */ public int getRadixTreeKeys() { @@ -88,10 +91,10 @@ public class StreamInfo { public void setRadixTreeKeys(int radixTreeKeys) { this.radixTreeKeys = radixTreeKeys; } - + /** * Returns amount of nodes allocated by Radix tree of the stream. - * + * * @return amount of nodes */ public int getRadixTreeNodes() { @@ -100,10 +103,10 @@ public class StreamInfo { public void setRadixTreeNodes(int radixTreeNodes) { this.radixTreeNodes = radixTreeNodes; } - + /** * Returns amount of groups belonging to the stream - * + * * @return amount of groups */ public int getGroups() { @@ -112,10 +115,10 @@ public class StreamInfo { public void setGroups(int groups) { this.groups = groups; } - + /** * Returns last StreamMessageId used by the stream - * + * * @return StreamMessageId object */ public StreamMessageId getLastGeneratedId() { @@ -124,10 +127,10 @@ public class StreamInfo { public void setLastGeneratedId(StreamMessageId lastGeneratedId) { this.lastGeneratedId = lastGeneratedId; } - + /** * Returns first stream entry - * + * * @return stream entry */ public Entry getFirstEntry() { @@ -139,7 +142,7 @@ public class StreamInfo { /** * Returns last stream entry - * + * * @return stream entry */ public Entry getLastEntry() { @@ -148,5 +151,43 @@ public class StreamInfo { public void setLastEntry(Entry lastEntry) { this.lastEntry = lastEntry; } - + + /** + * Returns the maximal entry ID that was deleted from the stream + * + * @return StreamMessageId object + */ + public StreamMessageId getMaxDeletedEntryId() { + return maxDeletedEntryId; + } + public StreamInfo 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 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 setRecordedFirstEntryId(StreamMessageId recordedFirstEntryId) { + this.recordedFirstEntryId = recordedFirstEntryId; + return this; + } } diff --git a/redisson/src/main/java/org/redisson/client/protocol/decoder/StreamInfoDecoder.java b/redisson/src/main/java/org/redisson/client/protocol/decoder/StreamInfoDecoder.java index 4bdbf4915..8c36668c5 100644 --- a/redisson/src/main/java/org/redisson/client/protocol/decoder/StreamInfoDecoder.java +++ b/redisson/src/main/java/org/redisson/client/protocol/decoder/StreamInfoDecoder.java @@ -38,6 +38,9 @@ public class StreamInfoDecoder implements MultiDecoder decode(List parts, State state) { @@ -53,6 +56,9 @@ public class StreamInfoDecoder implements MultiDecoder firstEntry = (List) map.get(FIRST_ENTRY_KEY); if (firstEntry != null) {