@@ -97,6 +97,20 @@ public enum KeyRangeType {
9797 * would be 4 and 6. With a range of 2 - 6, the keys would be 2, 4 and 6.
9898 */
9999 FORWARD_CLOSED (true , true , true ),
100+ /**
101+ * Iterate forward between the passed keys, matching on the first keys
102+ * directly equal to the passed key (or immediately following it in the case
103+ * of the "start" key, or immediately preceding it in the case of the "stop"
104+ * key). Do not return the "stop" key.
105+ *
106+ * <p>
107+ * The "start" and "stop" values are both required.
108+ *
109+ * <p>
110+ * In our example and with a passed search range of 3 - 8, the returned keys
111+ * would be 4 and 6. With a range of 2 - 6, the keys would be 2 and 4.
112+ */
113+ FORWARD_CLOSED_OPEN (true , true , true ),
100114 /**
101115 * Start after the passed key (but not equal to it) and iterate forward until
102116 * no keys remain.
@@ -180,6 +194,20 @@ public enum KeyRangeType {
180194 * would be 6 and 4. With a range of 6 - 2, the keys would be 6, 4 and 2.
181195 */
182196 BACKWARD_CLOSED (false , true , true ),
197+ /**
198+ * Iterate backward between the passed keys, matching on the first keys
199+ * directly equal to the passed key (or immediately preceding it in the case
200+ * of the "start" key, or immediately following it in the case of the "stop"
201+ * key). Do not return the "stop" key.
202+ *
203+ * <p>
204+ * The "start" and "stop" values are both required.
205+ *
206+ * <p>
207+ * In our example and with a passed search range of 8 - 3, the returned keys
208+ * would be 8, 6 and 4. With a range of 7 - 2, the keys would be 6 and 4.
209+ */
210+ BACKWARD_CLOSED_OPEN (false , true , true ),
183211 /**
184212 * Start immediate prior to the passed key (but not equal to it) and iterate
185213 * backward until no keys remain.
@@ -275,6 +303,8 @@ CursorOp initialOp() {
275303 return FIRST ;
276304 case FORWARD_CLOSED :
277305 return GET_START_KEY ;
306+ case FORWARD_CLOSED_OPEN :
307+ return GET_START_KEY ;
278308 case FORWARD_GREATER_THAN :
279309 return GET_START_KEY ;
280310 case FORWARD_LESS_THAN :
@@ -289,6 +319,8 @@ CursorOp initialOp() {
289319 return LAST ;
290320 case BACKWARD_CLOSED :
291321 return GET_START_KEY ;
322+ case BACKWARD_CLOSED_OPEN :
323+ return GET_START_KEY ;
292324 case BACKWARD_GREATER_THAN :
293325 return GET_START_KEY ;
294326 case BACKWARD_LESS_THAN :
@@ -327,6 +359,8 @@ <T, C extends Comparator<T>> IteratorOp iteratorOp(final T start, final T stop,
327359 return c .compare (buffer , stop ) > 0 ? TERMINATE : RELEASE ;
328360 case FORWARD_CLOSED :
329361 return c .compare (buffer , stop ) > 0 ? TERMINATE : RELEASE ;
362+ case FORWARD_CLOSED_OPEN :
363+ return c .compare (buffer , stop ) >= 0 ? TERMINATE : RELEASE ;
330364 case FORWARD_GREATER_THAN :
331365 return c .compare (buffer , start ) == 0 ? CALL_NEXT_OP : RELEASE ;
332366 case FORWARD_LESS_THAN :
@@ -347,6 +381,11 @@ <T, C extends Comparator<T>> IteratorOp iteratorOp(final T start, final T stop,
347381 return CALL_NEXT_OP ; // rewind
348382 }
349383 return c .compare (buffer , stop ) >= 0 ? RELEASE : TERMINATE ;
384+ case BACKWARD_CLOSED_OPEN :
385+ if (c .compare (buffer , start ) > 0 ) {
386+ return CALL_NEXT_OP ; // rewind
387+ }
388+ return c .compare (buffer , stop ) > 0 ? RELEASE : TERMINATE ;
350389 case BACKWARD_GREATER_THAN :
351390 return c .compare (buffer , start ) >= 0 ? CALL_NEXT_OP : RELEASE ;
352391 case BACKWARD_LESS_THAN :
0 commit comments