use of org.aion.db.impl.ByteArrayKeyValueDatabase in project aion by aionnetwork.
the class RocksDBDriverTest method testDriverReturnNull.
// It should return null if given bad vendor
@Test
public void testDriverReturnNull() {
Properties props = new Properties();
props.setProperty(Props.DB_TYPE, "BAD VENDOR");
props.setProperty(Props.DB_NAME, dbName);
props.setProperty(Props.DB_PATH, dbPath);
ByteArrayKeyValueDatabase db = DatabaseFactory.connect(props, log);
assertNull(db);
}
use of org.aion.db.impl.ByteArrayKeyValueDatabase in project aion by aionnetwork.
the class H2MVMapDriverTest method testDriverReturnNull.
// It should return null if given bad vendor
@Test
public void testDriverReturnNull() {
Properties props = new Properties();
props.setProperty(Props.DB_TYPE, "BAD VENDOR");
props.setProperty(Props.DB_NAME, dbName);
props.setProperty(Props.DB_PATH, dbPath);
ByteArrayKeyValueDatabase db = DatabaseFactory.connect(props, log);
assertNull(db);
}
use of org.aion.db.impl.ByteArrayKeyValueDatabase in project aion by aionnetwork.
the class H2MVMapDriverTest method testDriverReturnDatabase.
// It should return an instance of the DB given the correct properties
@Test
public void testDriverReturnDatabase() {
Properties props = new Properties();
props.setProperty(Props.DB_TYPE, dbVendor);
props.setProperty(Props.DB_NAME, dbName);
props.setProperty(Props.DB_PATH, dbPath);
ByteArrayKeyValueDatabase db = DatabaseFactory.connect(props, log);
assertNotNull(db);
}
use of org.aion.db.impl.ByteArrayKeyValueDatabase in project aion by aionnetwork.
the class AionRepositoryImpl method getReferencedTrieNodes.
/**
* Retrieves nodes referenced by a trie node value, where the size of the result is bounded by
* the given limit.
*
* @param value a trie node value which may be referencing other nodes
* @param limit the maximum number of key-value pairs to be retrieved by this method, which
* limits the search in the trie; zero and negative values for the limit will result in no
* search and an empty map will be returned
* @param dbType the database where the value was stored and further keys should be searched for
* @return an empty map when the value does not reference other trie nodes or the given limit is
* invalid, or a map containing all the referenced nodes reached while keeping within the
* limit on the result size
*/
public Map<ByteArrayWrapper, byte[]> getReferencedTrieNodes(byte[] value, int limit, DatabaseType dbType) {
if (limit <= 0) {
return Collections.emptyMap();
} else {
ByteArrayKeyValueDatabase db = selectDatabase(dbType);
Trie trie = new TrieImpl(db);
return trie.getReferencedTrieNodes(value, limit);
}
}
use of org.aion.db.impl.ByteArrayKeyValueDatabase in project aion by aionnetwork.
the class AionRepositoryImpl method dropDatabasesExcept.
/**
* Calls {@link ByteArrayKeyValueDatabase#drop()} on all the current databases except for the
* ones given in the list by name.
*
* @param names the names of the databases that should not be dropped
*/
public void dropDatabasesExcept(List<String> names) {
for (ByteArrayKeyValueDatabase db : databaseGroup) {
if (!names.contains(db.getName().get())) {
LOG.warn("Dropping database " + db.toString() + " ...");
db.drop();
LOG.warn(db.toString() + " successfully dropped and reopened.");
}
}
}
Aggregations