Example #1
0
 @Override
 public synchronized void flush(final boolean all) {
   try {
     table.flush(all);
     if (all) {
       write();
       texts.flush();
       values.flush();
       if (textIndex != null) ((DiskValues) textIndex).flush();
       if (attrIndex != null) ((DiskValues) attrIndex).flush();
     }
   } catch (final IOException ex) {
     Util.stack(ex);
   }
 }
Example #2
0
  @Override
  protected void updateText(final int pre, final byte[] value, final int kind) {
    final boolean text = kind != ATTR;

    if (meta.updindex) {
      // update indexes
      final int id = id(pre);
      final byte[] oldval = text(pre, text);
      final DiskValues index = (DiskValues) (text ? textIndex : attrIndex);
      // don't index document names
      if (index != null && kind != DOC) index.replace(oldval, value, id);
    }

    // reference to text store
    final DataAccess store = text ? texts : values;
    // file length
    final long len = store.length();

    // new entry (offset or value)
    final long v = toSimpleInt(value);
    if (v != Integer.MIN_VALUE) {
      // inline integer value
      textOff(pre, v | IO.OFFNUM);
    } else {
      // text to be stored (possibly packed)
      final byte[] val = COMP.get().pack(value);
      // old entry (offset or value)
      final long old = textOff(pre);

      // find text store offset
      final long off;
      if (number(old)) {
        // numeric entry: append new entry at the end
        off = len;
      } else {
        // text size (0 if value will be inlined)
        final int vl = val.length;
        off = store.free(old & IO.OFFCOMP - 1, vl + Num.length(vl));
      }

      store.writeToken(off, val);
      textOff(pre, val == value ? off : off | IO.OFFCOMP);
    }
  }
Example #3
0
 @Override
 void indexDelete() {
   if (!txtBuffer.isEmpty()) ((DiskValues) textIndex).delete(txtBuffer);
   if (!atvBuffer.isEmpty()) ((DiskValues) attrIndex).delete(atvBuffer);
 }
Example #4
0
 @Override
 protected void indexAdd() {
   if (!txtBuffer.isEmpty()) ((DiskValues) textIndex).add(txtBuffer);
   if (!atvBuffer.isEmpty()) ((DiskValues) attrIndex).add(atvBuffer);
 }