/** * Write the map to the specified file. * * @param file file to write to * @throws IOException I/O error while writing to the file */ public void write(final IOFile file) throws IOException { try (final DataOutput out = new DataOutput(file)) { out.writeNum(baseid); out.writeNum(rows); out.writeNums(pres); out.writeNums(fids); out.writeNums(nids); out.writeNums(incs); out.writeNums(oids); } }
/** * Writes the node to the specified output stream. * * @param out output stream * @throws IOException I/O exception */ void write(final DataOutput out) throws IOException { out.writeNum(name); out.write1(kind); out.writeNum(0); out.writeNum(children.length); out.writeDouble(1); // update leaf flag boolean leaf = stats.isLeaf(); for (final PathNode child : children) { leaf &= child.kind == Data.TEXT || child.kind == Data.ATTR; } stats.setLeaf(leaf); stats.write(out); for (final PathNode child : children) child.write(out); }
/** * Writes full-text data for a single token to disk.<br> * Format: {@code score? pre1 pos1 pre2 pos2 ... (0 score)? pre...} * * @param out DataOutput for disk access * @param vpre compressed pre values * @param vpos compressed pos values * @throws IOException IOException */ final void writeFTData(final DataOutput out, final byte[] vpre, final byte[] vpos) throws IOException { int np = 4, pp = 4, lp = -1, lu = -1; final int ns = Num.size(vpre); while (np < ns) { if (scm > 0) { final int p = Num.get(vpre, np); if (lp != p) { // new pre value: find document root int u = unit.sortedIndexOf(p); if (u < 0) u = -u - 1; if (lu != u) { // new unit: store scoring final int s = Scoring.tfIDF(freq.get(fc++), maxfreq[u], unit.size(), ntoken[token]); if (max < s) max = s; if (min > s) min = s; if (np != 4) out.write(0); out.writeNum(s); lu = u; } lp = p; } } // full-text data is stored here, with -scoreU, pre1, pos1, ..., // -scoreU, preU, posU for (final int l = np + Num.length(vpre, np); np < l; ++np) out.write(vpre[np]); for (final int l = pp + Num.length(vpos, pp); pp < l; ++pp) out.write(vpos[pp]); } ++token; }
@Override public synchronized void flush() throws IOException { for (final Buffer b : bm.all()) if (b.dirty) writeBlock(b); if (!dirty) return; try (final DataOutput out = new DataOutput(meta.dbfile(DATATBL + 'i'))) { out.writeNum(blocks); out.writeNum(used); // due to legacy issues, number of blocks is written several times out.writeNum(blocks); for (int a = 0; a < blocks; a++) out.writeNum(fpres[a]); out.writeNum(blocks); for (int a = 0; a < blocks; a++) out.writeNum(pages[a]); out.writeLongs(usedPages.toArray()); } dirty = false; }
/** * Writes a single node to disk. * * @param out output stream * @throws IOException I/O exception */ void write(final DataOutput out) throws IOException { out.writeNum(pr); out.writeNums(values); out.writeNum(sz); for (int c = 0; c < sz; ++c) children[c].write(out); }
@Override protected void setSize(final int pre, final int size) throws IOException { sout.writeNum(pre); sout.writeNum(size); ++ssize; }