Пример #1
0
  /*
   * (non-Javadoc)
   *
   * @see com.tinkerpop.blueprints.Graph#shutdown()
   */
  @Override
  public void shutdown() {
    commit();

    db.close();
    dex.close();
  }
Пример #2
0
  /**
   * Creates a new instance.
   *
   * @param fileName Database persistent file.
   * @param config Dex configuration file.
   */
  public DexGraph(final String fileName, final String config) {
    try {
      this.dbFile = new File(fileName);
      final File dbPath = dbFile.getParentFile();

      if (!dbPath.exists()) {
        if (!dbPath.mkdirs()) {
          throw new RuntimeException("Could not create directory");
        }
      }

      final boolean create = !dbFile.exists();

      if (config != null) com.sparsity.dex.gdb.DexProperties.load(config);
      dex = new com.sparsity.dex.gdb.Dex(new com.sparsity.dex.gdb.DexConfig());
      db =
          (create
              ? dex.create(dbFile.getPath(), dbFile.getName())
              : dex.open(dbFile.getPath(), false));
    } catch (Exception e) {
      throw new RuntimeException(e.getMessage(), e);
    }
  }