Skip to content

Commit 51a7923

Browse files
committed
New values type - integer. Rename new values.
1 parent 0fdf02a commit 51a7923

File tree

4 files changed

+86
-46
lines changed

4 files changed

+86
-46
lines changed

src/main/java/redis/clients/jedis/BuilderFactory.java

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,13 +1377,7 @@ public StreamEntry build(Object data) {
13771377
while (hashIterator.hasNext()) {
13781378
map.put(SafeEncoder.encode(hashIterator.next()), SafeEncoder.encode(hashIterator.next()));
13791379
}
1380-
Long idle = null;
1381-
Long times = null;
1382-
if (objectList.size() >= 4) {
1383-
idle = LONG.build(objectList.get(2));
1384-
times = LONG.build(objectList.get(3));
1385-
}
1386-
return new StreamEntry(entryID, map, idle, times);
1380+
return new StreamEntry(entryID, map);
13871381
}
13881382

13891383
@Override
@@ -1421,22 +1415,24 @@ public List<StreamEntry> build(Object data) {
14211415

14221416
Iterator<byte[]> hashIterator = hash.iterator();
14231417
Map<String, String> map = new HashMap<>(hash.size() / 2, 1f);
1418+
14241419
while (hashIterator.hasNext()) {
14251420
map.put(SafeEncoder.encode(hashIterator.next()), SafeEncoder.encode(hashIterator.next()));
14261421
}
1427-
Long idle = null;
1428-
Long times = null;
1422+
1423+
Long millisElapsedFromDelivery = null;
1424+
Long deliveredCount = null;
1425+
14291426
if (res.size() >= 4) {
14301427
Object idleObj = res.get(2);
14311428
Object timesObj = res.get(3);
1432-
idle = (idleObj instanceof Long) ? (Long) idleObj : Long.valueOf(STRING.build(idleObj));
1433-
times = (timesObj instanceof Long) ? (Long) timesObj : Long.valueOf(STRING.build(timesObj));
1434-
if (idle != null && times != null && idle == 0L && times == 0L) {
1435-
idle = null;
1436-
times = null;
1437-
}
1429+
millisElapsedFromDelivery = LONG.build(idleObj);
1430+
deliveredCount = LONG.build(timesObj);
1431+
}
1432+
1433+
if (Objects.nonNull(millisElapsedFromDelivery) && Objects.nonNull(deliveredCount)) {
1434+
responses.add(new StreamEntry(entryID, map, millisElapsedFromDelivery, deliveredCount));
14381435
}
1439-
responses.add(new StreamEntry(entryID, map, idle, times));
14401436
}
14411437

14421438
return responses;
@@ -1984,22 +1980,25 @@ public List<StreamEntryBinary> build(Object data) {
19841980

19851981
Iterator<byte[]> hashIterator = hash.iterator();
19861982
Map<byte[], byte[]> map = new JedisByteHashMap();
1983+
19871984
while (hashIterator.hasNext()) {
19881985
map.put(BINARY.build(hashIterator.next()), BINARY.build(hashIterator.next()));
19891986
}
1990-
Long idle = null;
1991-
Long times = null;
1987+
1988+
Long millisElapsedFromDelivery = null;
1989+
Long deliveredCount = null;
1990+
19921991
if (res.size() >= 4) {
19931992
Object idleObj = res.get(2);
19941993
Object timesObj = res.get(3);
1995-
idle = (idleObj instanceof Long) ? (Long) idleObj : Long.valueOf(STRING.build(idleObj));
1996-
times = (timesObj instanceof Long) ? (Long) timesObj : Long.valueOf(STRING.build(timesObj));
1997-
if (idle != null && times != null && idle == 0L && times == 0L) {
1998-
idle = null;
1999-
times = null;
2000-
}
1994+
millisElapsedFromDelivery = LONG.build(idleObj);
1995+
deliveredCount = LONG.build(timesObj);
1996+
}
1997+
1998+
if (Objects.nonNull(millisElapsedFromDelivery) && Objects.nonNull(deliveredCount)) {
1999+
responses.add(
2000+
new StreamEntryBinary(entryID, map, millisElapsedFromDelivery, deliveredCount));
20012001
}
2002-
responses.add(new StreamEntryBinary(entryID, map, idle, times));
20032002
}
20042003

20052004
return responses;

src/main/java/redis/clients/jedis/params/XReadGroupParams.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ public XReadGroupParams claim(long minIdleMillis) {
3636
return this;
3737
}
3838

39-
4039
@Override
4140
public void addParams(CommandArguments args) {
4241
if (count != null) {

src/main/java/redis/clients/jedis/resps/StreamEntry.java

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,50 @@ public class StreamEntry implements Serializable {
1111

1212
private StreamEntryID id;
1313
private Map<String, String> fields;
14-
15-
private Long idleTime; // milliseconds since last delivery (claimed entries)
16-
private Long deliveredTimes; // delivery count (claimed entries)
14+
private Long millisElapsedFromDelivery;
15+
private Long deliveredCount;
1716

1817
public StreamEntry(StreamEntryID id, Map<String, String> fields) {
1918
this.id = id;
2019
this.fields = fields;
2120
}
22-
public StreamEntry(StreamEntryID id, Map<String, String> fields, Long idleTime, Long deliveredTimes) {
21+
22+
public StreamEntry(StreamEntryID id, Map<String, String> fields, Long millisElapsedFromDelivery, Long deliveredCount) {
2323
this.id = id;
2424
this.fields = fields;
25-
this.idleTime = idleTime;
26-
this.deliveredTimes = deliveredTimes;
25+
this.millisElapsedFromDelivery = millisElapsedFromDelivery;
26+
this.deliveredCount = deliveredCount;
2727
}
2828

29-
public Long getIdleTime() {
30-
return idleTime;
29+
/**
30+
* @return the milliseconds since the last delivery of this message when CLAIM was used.
31+
* <ul>
32+
* <li>{@code null} when not applicable</li>
33+
* <li>{@code 0} means not claimed from the pending entries list (PEL)</li>
34+
* <li>{@code > 0} means claimed from the PEL</li>
35+
* </ul>
36+
* @since 7.1
37+
*/
38+
public Long getMillisElapsedFromDelivery() {
39+
return millisElapsedFromDelivery;
3140
}
3241

33-
public Long getDeliveredTimes() {
34-
return deliveredTimes;
42+
/**
43+
* @return the number of prior deliveries of this message when CLAIM was used:
44+
* <ul>
45+
* <li>{@code null} when not applicable</li>
46+
* <li>{@code 0} means not claimed from the pending entries list (PEL)</li>
47+
* <li>{@code > 0} means claimed from the PEL</li>
48+
* </ul>
49+
* @since 7.1
50+
*/
51+
public Long getDeliveredCount() {
52+
return deliveredCount;
3553
}
3654

55+
public boolean isClaimed() {
56+
return this.deliveredCount != null && this.deliveredCount > 0;
57+
}
3758

3859
public StreamEntryID getID() {
3960
return id;

src/main/java/redis/clients/jedis/resps/StreamEntryBinary.java

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,50 @@ public class StreamEntryBinary implements Serializable {
1111

1212
private StreamEntryID id;
1313
private Map<byte[], byte[]> fields;
14-
15-
private Long idleTime; // milliseconds since last delivery (claimed entries)
16-
private Long deliveredTimes; // delivery count (claimed entries)
14+
private Long millisElapsedFromDelivery;
15+
private Long deliveredCount;
1716

1817
public StreamEntryBinary(StreamEntryID id, Map<byte[], byte[]> fields) {
1918
this.id = id;
2019
this.fields = fields;
2120
}
22-
public StreamEntryBinary(StreamEntryID id, Map<byte[], byte[]> fields, Long idleTime, Long deliveredTimes) {
21+
22+
public StreamEntryBinary(StreamEntryID id, Map<byte[], byte[]> fields, Long millisElapsedFromDelivery, Long deliveredCount) {
2323
this.id = id;
2424
this.fields = fields;
25-
this.idleTime = idleTime;
26-
this.deliveredTimes = deliveredTimes;
25+
this.millisElapsedFromDelivery = millisElapsedFromDelivery;
26+
this.deliveredCount = deliveredCount;
2727
}
2828

29-
public Long getIdleTime() {
30-
return idleTime;
29+
/**
30+
* @return the milliseconds since the last delivery of this message when CLAIM was used.
31+
* <ul>
32+
* <li>{@code null} when not applicable</li>
33+
* <li>{@code 0} means not claimed from the pending entries list (PEL)</li>
34+
* <li>{@code > 0} means claimed from the PEL</li>
35+
* </ul>
36+
* @since 7.1
37+
*/
38+
public Long getMillisElapsedFromDelivery() {
39+
return millisElapsedFromDelivery;
3140
}
3241

33-
public Long getDeliveredTimes() {
34-
return deliveredTimes;
42+
/**
43+
* @return the number of prior deliveries of this message when CLAIM was used:
44+
* <ul>
45+
* <li>{@code null} when not applicable</li>
46+
* <li>{@code 0} means not claimed from the pending entries list (PEL)</li>
47+
* <li>{@code > 0} means claimed from the PEL</li>
48+
* </ul>
49+
* @since 7.1
50+
*/
51+
public Long getDeliveredCount() {
52+
return deliveredCount;
3553
}
3654

55+
public boolean isClaimed() {
56+
return this.deliveredCount != null && this.deliveredCount > 0;
57+
}
3758

3859
public StreamEntryID getID() {
3960
return id;

0 commit comments

Comments
 (0)