Beispiel #1
0
  /**
   * Creates query plans.
   *
   * @param comp compiled flag
   */
  private void plan(final boolean comp) {
    if (comp != options.get(MainOptions.COMPPLAN)) return;

    // show dot plan
    try {
      if (options.get(MainOptions.DOTPLAN)) {
        final String path = options.get(MainOptions.QUERYPATH);
        final String dot =
            path.isEmpty() ? "plan.dot" : new IOFile(path).name().replaceAll("\\..*?$", ".dot");

        try (final BufferOutput bo = new BufferOutput(dot)) {
          try (final DOTSerializer d = new DOTSerializer(bo, options.get(MainOptions.DOTCOMPACT))) {
            d.serialize(qp.plan());
          }
        }
      }

      // show XML plan
      if (options.get(MainOptions.XMLPLAN)) {
        info(NL + QUERY_PLAN + COL);
        info(qp.plan().serialize().toString());
      }
    } catch (final Exception ex) {
      Util.stack(ex);
    }
  }
Beispiel #2
0
 /**
  * Returns the image url.
  *
  * @param name name of image
  * @return url
  */
 private static URL url(final String name) {
   final String path = "/img/" + name + ".png";
   URL url = BaseXImages.class.getResource(path);
   if (url == null) {
     Util.stack("Image not found: " + path);
     url = BaseXImages.class.getResource("/img/warn.png");
   }
   return url;
 }
Beispiel #3
0
 @Override
 public boolean lock(final boolean lock) {
   try {
     if (lock) {
       if (exclusiveLock()) return true;
       if (sharedLock()) return false;
     } else {
       if (sharedLock()) return true;
     }
   } catch (final IOException ex) {
     Util.stack(ex);
   }
   throw Util.notExpected((lock ? "Exclusive" : "Shared") + " lock could not be acquired.");
 }
Beispiel #4
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);
   }
 }
Beispiel #5
0
 @Override
 public synchronized void close() {
   if (closed) return;
   closed = true;
   try {
     write();
     table.close();
     texts.close();
     values.close();
     close(IndexType.TEXT);
     close(IndexType.ATTRIBUTE);
     close(IndexType.FULLTEXT);
   } catch (final IOException ex) {
     Util.stack(ex);
   }
 }
Beispiel #6
0
  /**
   * Reads a block from disk.
   *
   * @param b block to fetch
   */
  private void readBlock(final int b) {
    if (!bm.cursor(b)) return;

    final Buffer bf = bm.current();
    try {
      if (bf.dirty) writeBlock(bf);
      bf.pos = b;
      if (b >= blocks) {
        blocks = b + 1;
      } else {
        file.seek(bf.pos * IO.BLOCKSIZE);
        file.readFully(bf.data);
      }
    } catch (final IOException ex) {
      Util.stack(ex);
    }
  }