示例#1
0
 /**
  * Writes all meta data to disk.
  *
  * @throws IOException I/O exception
  */
 private void write() throws IOException {
   if (meta.dirty) {
     try (final DataOutput out = new DataOutput(meta.dbfile(DATAINF))) {
       meta.write(out);
       out.writeToken(token(DBTAGS));
       elemNames.write(out);
       out.writeToken(token(DBATTS));
       attrNames.write(out);
       out.writeToken(token(DBPATH));
       paths.write(out);
       out.writeToken(token(DBNS));
       nspaces.write(out);
       out.writeToken(token(DBDOCS));
       resources.write(out);
       out.write(0);
     }
     if (idmap != null) idmap.write(meta.dbfile(DATAIDP));
     meta.dirty = false;
   }
 }
示例#2
0
  /**
   * Calculates the text offset and writes the text value.
   *
   * @param value value to be inlined
   * @param text text/attribute flag
   * @return inline value or text position
   * @throws IOException I/O exception
   */
  private long textOff(final byte[] value, final boolean text) throws IOException {
    // inline integer values...
    final long v = Token.toSimpleInt(value);
    if (v != Integer.MIN_VALUE) return v | IO.OFFNUM;

    // store text
    final DataOutput store = text ? xout : vout;
    final long off = store.size();
    final byte[] val = COMP.get().pack(value);
    store.writeToken(val);
    return val == value ? off : off | IO.OFFCOMP;
  }