/** * Returns an atomized content for any node kind. The atomized value can be an attribute value or * XML content. * * @param pre pre value * @return atomized value */ public final byte[] atom(final int pre) { switch (kind(pre)) { case TEXT: case COMM: return text(pre, true); case ATTR: return text(pre, false); case PI: byte[] txt = text(pre, true); final int i = indexOf(txt, ' '); return i == -1 ? EMPTY : substring(txt, i + 1); default: // create atomized text node TokenBuilder tb = null; byte[] t = EMPTY; int p = pre; final int s = p + size(p, kind(p)); while (p != s) { final int k = kind(p); if (k == TEXT) { txt = text(p, true); if (t == EMPTY) { t = txt; } else { if (tb == null) tb = new TokenBuilder(t); tb.add(txt); } } p += attSize(p, k); } return tb == null ? t : tb.finish(); } }
@Override public byte[] info() { final TokenBuilder tb = new TokenBuilder(LI_STRUCTURE).add(SORTED_LIST).add(NL); final IndexStats stats = new IndexStats(data); for (int m = 1; m < size; ++m) { final int oc = len[m]; if (stats.adding(oc)) stats.add(key(m)); } stats.print(tb); return tb.finish(); }
@Override public synchronized byte[] info(final MainOptions options) { final TokenBuilder tb = new TokenBuilder(); final long l = inX.length() + inY.length() + inZ.length(); tb.add(LI_NAMES).add(data.meta.ftinclude).add(NL); tb.add(LI_SIZE + Performance.format(l, true) + NL); final IndexStats stats = new IndexStats(options.get(MainOptions.MAXSTAT)); addOccs(stats); stats.print(tb); return tb.finish(); }
@Override public byte[] info(final MainOptions options) { final TokenBuilder tb = new TokenBuilder(); tb.add(LI_STRUCTURE).add(HASH).add(NL); tb.add(LI_NAMES).add(data.meta.names(type)).add(NL); final IndexStats stats = new IndexStats(options.get(MainOptions.MAXSTAT)); final int s = values.size(); for (int p = 1; p <= s; p++) { final int oc = lenList.get(p); if (oc > 0 && stats.adding(oc)) stats.add(values.key(p), oc); } stats.print(tb); return tb.finish(); }
/** * Returns a string representation of the index structure. * * @param all include database contents in the representation. During updates, database lookups * must be avoided, as the data structures will be inconsistent. * @return string */ public String toString(final boolean all) { final TokenBuilder tb = new TokenBuilder(); tb.addExt(type).add(" INDEX, '").add(data.meta.name).add("':\n"); final int s = lenList.size(); for (int m = 1; m < s; m++) { final int len = lenList.get(m); if (len == 0) continue; final int[] ids = idsList.get(m); tb.add(" ").addInt(m); if (all) tb.add(", key: \"").add(data.text(data.pre(ids[0]), type == IndexType.TEXT)).add('"'); tb.add(", ids"); if (all) tb.add("/pres"); tb.add(": "); for (int n = 0; n < len; n++) { if (n != 0) tb.add(","); tb.addInt(ids[n]); if (all) tb.add('/').addInt(data.pre(ids[n])); } tb.add("\n"); } return tb.toString(); }