MCPcopy Create free account
hub / github.com/BaseXdb/basex / ddo

Method ddo

basex-core/src/main/java/org/basex/query/expr/Pos.java:137–159  ·  view source on GitHub ↗

Returns distinct ordered positions. @param value positions @return sorted positions @throws QueryException query exception

(final Value value)

Source from the content-addressed store, hash-verified

135 * @throws QueryException query exception
136 */
137 public static Value ddo(final Value value) throws QueryException {
138 if(value instanceof RangeSeq) return value;
139 boolean small = true;
140 final LongList list = new LongList();
141 for(final Item item : value) {
142 final double d = item.dbl(null);
143 final long l = (long) d;
144 if(l > 0 && d == l) {
145 list.add(l);
146 small = small && l == (int) l;
147 }
148 }
149 list.ddo();
150
151 if(small) {
152 final IntList il = new IntList(list.size());
153 for(final long l : list.finish()) il.add((int) l);
154 return IntSeq.get(il.finish());
155 }
156 final ItemList il = new ItemList(list.size());
157 for(final long l : list.finish()) il.add(Itr.get(l));
158 return il.value();
159 }
160
161 @Override
162 public Expr optimize(final CompileContext cc) throws QueryException {

Callers 2

getMethod · 0.95
positionsMethod · 0.95

Calls 10

addMethod · 0.95
ddoMethod · 0.95
finishMethod · 0.95
addMethod · 0.95
getMethod · 0.95
getMethod · 0.95
valueMethod · 0.95
sizeMethod · 0.65
dblMethod · 0.45
finishMethod · 0.45

Tested by

no test coverage detected