@Override public IndexIterator iter(final IndexToken token) { final int id = values.id(token.get()); if (id == 0) return IndexIterator.EMPTY; final int len = lenList.get(id); final int[] ids = idsList.get(id), pres; if (data.meta.updindex) { final IntList tmp = new IntList(); for (int i = 0; i < len; ++i) tmp.add(data.pre(ids[i])); pres = tmp.sort().finish(); } else { pres = ids; } return new IndexIterator() { int p; @Override public boolean more() { return p < len; } @Override public int pre() { return pres[p++]; } @Override public int size() { return len; } }; }
/** * Returns pre values. * * @param ids unique node ids * @param off start offset * @param len number of ids * @return sorted pre values */ public final int[] pre(final int[] ids, final int off, final int len) { if (meta.updindex) return idmap.pre(ids, off, len); final IntList p = new IntList(ids.length); for (int i = off; i < len; ++i) p.add(preold(ids[i])); return p.sort().toArray(); }
@Override public void add(final ValueCache cache) { for (final byte[] key : cache) { final IntList vals = cache.ids(key); if (!vals.isEmpty()) add(key, vals.sort().finish()); } finish(); }