@@ -1066,6 +1066,69 @@ def quad_slice(self, sub, pred, obj, low, high, graph):
10661066 self ._cursor ["graph" ] = self ._clean_graph (graph )
10671067 return self
10681068
1069+ def triple_slice_rev (self , sub , pred , obj , low , high ):
1070+ """Creates a triple pattern matching rule for [S, P, O] with a half-open
1071+ value range [low, high) on the object, returning results in reverse
1072+ (descending) object order. Same semantics as triple_slice but iterates
1073+ from highest to lowest value.
1074+
1075+ Parameters
1076+ ----------
1077+ sub : str
1078+ Subject, has to be a node (URI) or variable
1079+ pred : str
1080+ Predicate, can be variable (prefix with "v:") or node
1081+ obj : str
1082+ Object, can be variable or node or value
1083+ low : object
1084+ The inclusive lower bound as a typed value
1085+ high : object
1086+ The exclusive upper bound as a typed value
1087+
1088+ Returns
1089+ -------
1090+ WOQLQuery object
1091+ query object that can be chained and/or execute
1092+ """
1093+ if self ._cursor .get ("@type" ):
1094+ self ._wrap_cursor_with_and ()
1095+ self ._cursor ["@type" ] = "TripleSliceRev"
1096+ self ._cursor ["subject" ] = self ._clean_subject (sub )
1097+ self ._cursor ["predicate" ] = self ._clean_predicate (pred )
1098+ self ._cursor ["object" ] = self ._clean_object (obj )
1099+ self ._cursor ["low" ] = self ._clean_object (low )
1100+ self ._cursor ["high" ] = self ._clean_object (high )
1101+ return self
1102+
1103+ def quad_slice_rev (self , sub , pred , obj , low , high , graph ):
1104+ """Creates a triple pattern matching rule for [S, P, O, G] with a half-open
1105+ value range [low, high) on the object in reverse order, with an explicit
1106+ graph selector.
1107+
1108+ Parameters
1109+ ----------
1110+ sub : str
1111+ Subject, has to be a node (URI) or variable
1112+ pred : str
1113+ Predicate, can be variable (prefix with "v:") or node
1114+ obj : str
1115+ Object, can be variable or node or value
1116+ low : object
1117+ The inclusive lower bound as a typed value
1118+ high : object
1119+ The exclusive upper bound as a typed value
1120+ graph : str
1121+ Graph resource identifier (e.g. 'instance' or 'schema')
1122+
1123+ Returns
1124+ -------
1125+ WOQLQuery object
1126+ query object that can be chained and/or execute
1127+ """
1128+ self .triple_slice_rev (sub , pred , obj , low , high )
1129+ self ._cursor ["graph" ] = self ._clean_graph (graph )
1130+ return self
1131+
10691132 def triple_next (self , sub , pred , obj , next_val ):
10701133 """Finds the next object value after a reference for a given subject-predicate pair.
10711134 When object is bound and next is free, finds the smallest next > object.
0 commit comments