Example #1
0
  @Override
  public synchronized void finishUpdate(final MainOptions opts) {
    // remove updating file
    final boolean auto = opts.get(MainOptions.AUTOFLUSH);
    if (auto) {
      final IOFile uf = meta.updateFile();
      if (!uf.exists()) throw Util.notExpected("%: lock file does not exist.", meta.name);
      if (!uf.delete()) throw Util.notExpected("%: could not delete lock file.", meta.name);
    }

    // db:optimize(..., true) will close the database before this function is called
    if (!closed) {
      flush(auto);
      if (!table.lock(false)) throw Util.notExpected("Database '%': could not unlock.", meta.name);
    }
  }
Example #2
0
 @Override
 public void startUpdate(final MainOptions opts) throws IOException {
   if (!table.lock(true)) throw new BaseXException(Text.DB_PINNED_X, meta.name);
   if (opts.get(MainOptions.AUTOFLUSH)) {
     final IOFile uf = meta.updateFile();
     if (uf.exists()) throw new BaseXException(Text.DB_UPDATED_X, meta.name);
     if (!uf.touch()) throw Util.notExpected("%: could not create lock file.", meta.name);
   }
 }
Example #3
0
 @Override
 public Iter iter(final QueryContext qc) throws QueryException {
   final Value seq = qc.value(ts);
   for (final TypeCase tc : cases) {
     final Iter iter = tc.iter(qc, seq);
     if (iter != null) return iter;
   }
   // will never happen
   throw Util.notExpected();
 }
Example #4
0
  @Override
  public void createIndex(final IndexType type, final MainOptions options, final Command cmd)
      throws IOException {

    // close existing index
    close(type);
    final IndexBuilder ib;
    switch (type) {
      case TEXT:
        ib = new DiskValuesBuilder(this, options, true);
        break;
      case ATTRIBUTE:
        ib = new DiskValuesBuilder(this, options, false);
        break;
      case FULLTEXT:
        ib = new FTBuilder(this, options);
        break;
      default:
        throw Util.notExpected();
    }
    if (cmd != null) cmd.proc(ib);
    set(type, ib.build());
  }
Example #5
0
 @Override
 public void delete(final TokenObjMap<IntList> map) {
   throw Util.notExpected();
 }