use of org.exist.storage.btree.DBException in project exist by eXist-db.
the class NativeStructuralIndex method open.
@Override
public void open() throws DatabaseConfigurationException {
final Path file = getDataDir().resolve(FILE_NAME);
LOG.debug("Creating '{}'...", FileUtils.fileName(file));
try {
btree = new BTreeStore(pool, STRUCTURAL_INDEX_ID, FILE_FORMAT_VERSION_ID, false, file, pool.getCacheManager());
} catch (final DBException e) {
LOG.error("Failed to initialize structural index: {}", e.getMessage(), e);
throw new DatabaseConfigurationException(e.getMessage(), e);
}
}
use of org.exist.storage.btree.DBException in project exist by eXist-db.
the class RangeIndexWorker method removeCollection.
@Override
public void removeCollection(Collection collection, DBBroker broker, boolean reindex) throws PermissionDeniedException {
if (LOG.isDebugEnabled())
LOG.debug("Removing collection {}", collection.getURI());
IndexWriter writer = null;
try {
writer = index.getWriter();
for (Iterator<DocumentImpl> i = collection.iterator(broker); i.hasNext(); ) {
DocumentImpl doc = i.next();
final BytesRefBuilder bytes = new BytesRefBuilder();
NumericUtils.intToPrefixCoded(doc.getDocId(), 0, bytes);
Term dt = new Term(FIELD_DOC_ID, bytes.toBytesRef());
writer.deleteDocuments(dt);
}
} catch (IOException | PermissionDeniedException | LockException e) {
LOG.error("Error while removing lucene index: {}", e.getMessage(), e);
} finally {
index.releaseWriter(writer);
if (reindex) {
try {
index.sync();
} catch (DBException e) {
LOG.warn("Exception during reindex: {}", e.getMessage(), e);
}
}
mode = ReindexMode.STORE;
}
if (LOG.isDebugEnabled())
LOG.debug("Collection removed.");
}
use of org.exist.storage.btree.DBException in project exist by eXist-db.
the class SortIndex method open.
@Override
public void open() throws DatabaseConfigurationException {
final Path file = getDataDir().resolve(FILE_NAME);
LOG.debug("Creating '{}'...", FileUtils.fileName(file));
try {
btree = new BTreeStore(pool, SORT_INDEX_ID, FILE_FORMAT_VERSION_ID, false, file, pool.getCacheManager());
} catch (final DBException e) {
LOG.error("Failed to initialize structural index: {}", e.getMessage(), e);
throw new DatabaseConfigurationException(e.getMessage(), e);
}
}
use of org.exist.storage.btree.DBException in project exist by eXist-db.
the class GMLHSQLIndex method removeIndexContent.
@Override
protected void removeIndexContent() throws DBException {
try {
// deleteDatabase() should be far more efficient ;-)
if (conn != null) {
Statement stmt = conn.createStatement();
int nodeCount = stmt.executeUpdate("DELETE FROM " + GMLHSQLIndex.TABLE_NAME + ";");
stmt.close();
if (LOG.isDebugEnabled())
LOG.debug("GML index: {}/{}. {} nodes removed", getDataDir(), db_file_name_prefix, nodeCount);
}
} catch (SQLException e) {
throw new DBException(e.getMessage());
}
}
use of org.exist.storage.btree.DBException in project exist by eXist-db.
the class GMLHSQLIndex method deleteDatabase.
@Override
protected void deleteDatabase() throws DBException {
final Path directory = getDataDir();
try {
final List<Path> files = FileUtils.list(directory, path -> FileUtils.fileName(path).startsWith(db_file_name_prefix));
boolean deleted = true;
for (final Path file : files) {
deleted &= FileUtils.deleteQuietly(file);
}
} catch (final IOException e) {
LOG.error(e);
throw new DBException(e.getMessage());
}
// TODO : raise an error if deleted == false ?
}
Aggregations