use of com.sleepycat.je.Database in project timbuctoo by HuygensING.
the class BdbNonPersistentEnvironmentCreator method getDatabase.
@Override
public <KeyT, ValueT> BdbWrapper<KeyT, ValueT> getDatabase(String userId, String dataSetId, String databaseName, boolean allowDuplicates, EntryBinding<KeyT> keyBinder, EntryBinding<ValueT> valueBinder, IsCleanHandler<KeyT, ValueT> isCleanHandler) throws BdbDbCreationException {
try {
DatabaseConfig config = new DatabaseConfig();
config.setAllowCreate(true);
config.setDeferredWrite(true);
config.setSortedDuplicates(allowDuplicates);
String environmentKey = environmentKey(userId, dataSetId);
File envHome = new File(dbHome, environmentKey);
envHome.mkdirs();
Environment dataSetEnvironment = new Environment(envHome, configuration);
Database database = dataSetEnvironment.openDatabase(null, databaseName, config);
databases.put(environmentKey + "_" + databaseName, database);
environmentMap.put(environmentKey, dataSetEnvironment);
return new BdbWrapper<>(dataSetEnvironment, database, config, keyBinder, valueBinder, isCleanHandler);
} catch (DatabaseException e) {
throw new BdbDbCreationException(e);
}
}
use of com.sleepycat.je.Database in project BIMserver by opensourceBIM.
the class BerkeleyKeyValueStore method openIndexTable.
public void openIndexTable(DatabaseSession databaseSession, String tableName, boolean transactional) throws BimserverDatabaseException {
if (tables.containsKey(tableName)) {
throw new BimserverDatabaseException("Table " + tableName + " already opened");
}
DatabaseConfig databaseConfig = new DatabaseConfig();
databaseConfig.setKeyPrefixing(keyPrefixing);
databaseConfig.setAllowCreate(false);
boolean finalTransactional = transactional && useTransactions;
// if (!transactional) {
// databaseConfig.setCacheMode(CacheMode.EVICT_BIN);
// }
databaseConfig.setDeferredWrite(!finalTransactional);
databaseConfig.setTransactional(finalTransactional);
databaseConfig.setSortedDuplicates(true);
Database database = environment.openDatabase(null, tableName, databaseConfig);
if (database == null) {
throw new BimserverDatabaseException("Table " + tableName + " not found in database");
}
tables.put(tableName, new TableWrapper(database, finalTransactional));
}
use of com.sleepycat.je.Database in project BIMserver by opensourceBIM.
the class BerkeleyKeyValueStore method createIndexTable.
public boolean createIndexTable(String tableName, DatabaseSession databaseSession, boolean transactional) throws BimserverDatabaseException {
if (tables.containsKey(tableName)) {
throw new BimserverDatabaseException("Table " + tableName + " already created");
}
DatabaseConfig databaseConfig = new DatabaseConfig();
databaseConfig.setKeyPrefixing(keyPrefixing);
databaseConfig.setAllowCreate(true);
boolean finalTransactional = transactional && useTransactions;
// if (!transactional) {
// databaseConfig.setCacheMode(CacheMode.EVICT_BIN);
// }
databaseConfig.setDeferredWrite(!finalTransactional);
databaseConfig.setTransactional(finalTransactional);
databaseConfig.setSortedDuplicates(true);
Database database = environment.openDatabase(null, tableName, databaseConfig);
if (database == null) {
return false;
}
tables.put(tableName, new TableWrapper(database, finalTransactional));
return true;
}
Aggregations