本文整理汇总了Java中org.mapdb.DB类的典型用法代码示例。如果您正苦于以下问题:Java DB类的具体用法?Java DB怎么用?Java DB使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DB类属于org.mapdb包,在下文中一共展示了DB类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: DBSet
import org.mapdb.DB; //导入依赖的package包/类
public DBSet(DB database)
{
this.database = database;
this.actions = 0;
this.balanceMap = new BalanceMap(this, database);
this.blockMap = new BlockMap(this, database);
this.childMap = new ChildMap(this, database);
this.heightMap = new HeightMap(this, database);
this.referenceMap = new ReferenceMap(this, database);
this.peerMap = new PeerMap(this, database);
this.transactionMap = new TransactionMap(this, database);
this.nameMap = new NameMap(this, database);
this.transactionParentMap = new TransactionParentMap(this, database);
this.nameExchangeMap = new NameExchangeMap(this, database);
this.updateNameMap = new UpdateNameMap(this, database);
this.cancelSellNameMap = new CancelSellNameMap(this, database);
this.pollMap = new PollMap(this, database);
this.voteOnPollMap = new VoteOnPollMap(this, database);
this.assetMap = new AssetMap(this, database);
this.issueAssetMap = new IssueAssetMap(this, database);
this.orderMap = new OrderMap(this, database);
this.completedOrderMap = new CompletedOrderMap(this, database);
this.tradeMap = new TradeMap(this, database);
}
示例2: setConnectionToDB
import org.mapdb.DB; //导入依赖的package包/类
public void setConnectionToDB(DockerConnection dc, File configFile, File certFile) throws IOException {
File database = new File("./connections.db");
DB db = DBMaker
.fileDB(database)
.transactionEnable()
.closeOnJvmShutdown()
.fileChannelEnable()
.make();
ConcurrentMap mapa = db.hashMap("map").createOrOpen();
dc.getWithTls().setDockerCertPath(Paths.get("server/certs/").relativize(certFile.toPath()).toString());
dc.getWithTls().setDockerConfig(Paths.get("server/certs/").relativize(configFile.toPath()).toString());
mapa.put(dc.getName(), dc);
db.commit();
db.close();
}
示例3: getConnectionFromDB
import org.mapdb.DB; //导入依赖的package包/类
public Map<UUID, DockerConnection> getConnectionFromDB() throws IOException {
Map<UUID, DockerConnection> listOfConnections = new HashMap<>();
File database = new File("./connections.db");
DB db = DBMaker
.fileDB(database)
.transactionEnable()
.closeOnJvmShutdown()
.fileChannelEnable()
.make();
ConcurrentMap mapa = db.hashMap("map").createOrOpen();
mapa.forEach((uuid, connection) -> {
listOfConnections.put((UUID) uuid, (DockerConnection) connection);
});
db.close();
return listOfConnections;
}
示例4: addMapDataToList
import org.mapdb.DB; //导入依赖的package包/类
/**
* add data from a given map in the db to the list.
*
* @param mapName
* the map name to use.
* @param keyBa
* the key ba to use.
* @param list
* the list to add to.
* @param factory
* the factory to use.
* @param <T>
* the type of object the factory makes.
*/
private <T> void addMapDataToList(final String mapName, final byte[] keyBa, final List<T> list,
final AbstractByteBufferFactory<T> factory) {
if (LOG.isTraceEnabled()) {
LOG.trace("addMapDataToList {} keyBa:{}", mapName, ModelUtil.toHexString(keyBa));
}
final HTreeMap<byte[], byte[]> map = DB.hashMap(mapName, Serializer.BYTE_ARRAY, Serializer.BYTE_ARRAY)
.counterEnable().createOrOpen();
final byte[] listBa = map.get(keyBa);
if (LOG.isTraceEnabled()) {
LOG.trace("addMapDataToList {} listBa:{}", mapName, ModelUtil.toHexString(listBa));
}
final List<byte[]> baList = ModelUtil.toByteArrayList(listBa);
for (final byte[] ba : baList) {
final ByteBuffer bb = ByteBuffer.wrap(ba);
final T t = factory.toObject(bb);
list.add(t);
}
}
示例5: visit
import org.mapdb.DB; //导入依赖的package包/类
public synchronized boolean visit(CustomParamVisitor visitor) throws Exception {
AssertionUtils.assertNotNull(new IllegalArgumentException("visitor"), visitor);
final DB db = getReadOnlyDB();
final Iterator<String> internalIterator = getSet(db).iterator();
Iterable<String> iterable = new Iterable<String>(
) {
@Override
public Iterator<String> iterator() {
return internalIterator;
}
};
boolean next = false;
for(String param : iterable) {
next = visitor.visit(param);
if(!next) {
break;
}
}
db.close();
return next;
}
示例6: preProcess
import org.mapdb.DB; //导入依赖的package包/类
/**
* If grouping is enabled, initialize the temporary cache that will hold grouped objects.
*/
@SuppressWarnings("unchecked")
@Override
protected final boolean preProcess(Context context) {
if ( isGroupingEnabled(context) ) {
IContextGrouping ctx = context.as(IContextGrouping.class);
DB db = DBMaker.tempFileDB()
.closeOnJvmShutdown().fileDeleteAfterClose()
.fileMmapEnableIfSupported()
.make();
Map<String, List<Object>> groups = db.hashMap("groups", Serializer.STRING, Serializer.JAVA).create();
groups.clear(); // Make sure that we start with a clean cache
ctx.setGroupByExpressionsMapDB(db);
ctx.setGroupByExpressionsGroupsMap(groups);
}
return preProcessBeforeGrouping(context);
}
示例7: setupDataStore
import org.mapdb.DB; //导入依赖的package包/类
@Override
public Storage setupDataStore() {
dataStore = new VPMapDB();
System.out.println("Created VPMapDB");
DB db;
if (method.equals("encrypt")) {
db = dataStore.setupDB(outputPath);
} else {
db = dataStore.setupDB(inputPath);
}
System.out.println("Setup DB");
dataStore.setupMaps(db);
System.out.println("Setup Maps");
return dataStore;
}
示例8: setupDataStore
import org.mapdb.DB; //导入依赖的package包/类
@Override
public Storage setupDataStore() {
dataStore = new ThreeIndexMapDB();
System.out.println("Created 3IMapDB");
DB db;
if (method.equals("encrypt")) {
db = dataStore.setupDB(outputPath);
} else {
db = dataStore.setupDB(inputPath);
}
System.out.println("Setup DB");
dataStore.setupMaps(db);
System.out.println("Setup Maps");
return dataStore;
}
示例9: setupMaps
import org.mapdb.DB; //导入依赖的package包/类
@Override
public void setupMaps(DB db) {
IndexComparator ic = new IndexComparator();
// initialize map
// note that it uses KeyArray Serializer to minimise disk space
// used by Map
BTreeKeySerializer keySerializer = new BTreeKeySerializer.ArrayKeySerializer(
new Comparator[] { ic, ic, ic }, new Serializer[] {
Serializer.BYTE_ARRAY, Serializer.BYTE_ARRAY,
Serializer.BYTE_ARRAY });
spMap = db.treeMap("sp", keySerializer, Serializer.BYTE_ARRAY);
poMap = db.treeMap("po", keySerializer, Serializer.BYTE_ARRAY);
osMap = db.treeMap("os", keySerializer, Serializer.BYTE_ARRAY);
spoMap = db.hashMap("spo", Serializer.BYTE_ARRAY,
Serializer.BYTE_ARRAY);
}
示例10: setReadOnly
import org.mapdb.DB; //导入依赖的package包/类
@Override
public void setReadOnly() {
clusterContainer.close();
Path projectPath = Paths.get(Configuration.getParameters().getString("Experiment.projectPath"));
Path poolDataPath = Paths.get(projectPath.toString(), "clusterdata");
String containerFileName = "clusters.mapdb";
DB db = DBMaker
.fileDB(Paths.get(poolDataPath.toString(), containerFileName).toFile())
.fileMmapEnableIfSupported() // Only enable mmap on supported platforms
.concurrencyScale(8) // TODO: Number of threads make this a parameter?
.executorEnable()
.readOnly()
.make();
clusterContainer = db.treeMap("map")
.keySerializer(Serializer.INTEGER)
.valueSerializer(Serializer.INTEGER)
.open();
AptaLogger.log(Level.CONFIG, this.getClass(), "Reopened as read only file " + Paths.get(poolDataPath.toString(), containerFileName).toString() );
}
示例11: setReadOnly
import org.mapdb.DB; //导入依赖的package包/类
public void setReadOnly() {
poolContentCounts.close();
Path projectPath = Paths.get(Configuration.getParameters().getString("Experiment.projectPath"));
Path poolDataPath = Paths.get(projectPath.toString(), "cycledata");
String cycleFileName = round + "_" + name + ".mapdb";
DB db = DBMaker
.fileDB(Paths.get(poolDataPath.toString(), cycleFileName).toFile())
.fileMmapEnableIfSupported() // Only enable mmap on supported platforms
.concurrencyScale(8) // TODO: Number of threads make this a parameter?
.executorEnable()
.readOnly()
.make();
poolContentCounts = db.treeMap("map")
.keySerializer(Serializer.INTEGER)
.valueSerializer(Serializer.INTEGER)
.open();
AptaLogger.log(Level.CONFIG, this.getClass(), "Reopened as read only file " + Paths.get(poolDataPath.toString(), cycleFileName).toString() );
}
示例12: setReadWrite
import org.mapdb.DB; //导入依赖的package包/类
@Override
public void setReadWrite() {
poolContentCounts.close();
Path projectPath = Paths.get(Configuration.getParameters().getString("Experiment.projectPath"));
Path poolDataPath = Paths.get(projectPath.toString(), "cycledata");
String cycleFileName = round + "_" + name + ".mapdb";
DB db = DBMaker
.fileDB(Paths.get(poolDataPath.toString(), cycleFileName).toFile())
.fileMmapEnableIfSupported() // Only enable mmap on supported platforms
.concurrencyScale(8) // TODO: Number of threads make this a parameter?
.executorEnable()
.make();
poolContentCounts = db.treeMap("map")
.keySerializer(Serializer.INTEGER)
.valueSerializer(Serializer.INTEGER)
.open();
AptaLogger.log(Level.CONFIG, this.getClass(), "Reopened as read/write file " + Paths.get(poolDataPath.toString(), cycleFileName).toString() );
}
示例13: constructDB
import org.mapdb.DB; //导入依赖的package包/类
private static DB constructDB(String dbFile) {
DB db;
try{
DBMaker dbMaker = DBMaker.newFileDB(new File(dbFile));
db = dbMaker
.transactionDisable()
.mmapFileEnable()
.asyncWriteEnable()
.compressionEnable()
// .cacheSize(1024 * 1024) this bloats memory consumption
.make();
return db;
} catch (ExecutionError | IOError | Exception e) {
LOG.error("Could not construct db from file.", e);
return null;
}
}
示例14: GitConverter
import org.mapdb.DB; //导入依赖的package包/类
public GitConverter(@NotNull DB cache, @NotNull Path basePath, @NotNull String[] globs) throws IOException, InvalidPatternException {
this.basePath = basePath;
this.cache = cache;
this.globs = globs.clone();
this.matchers = convertGlobs(globs);
Arrays.sort(globs);
for (String glob : globs) {
new FileNameMatcher(glob, '/');
}
tempPath = basePath.resolve("lfs/tmp");
Files.createDirectories(tempPath);
//noinspection unchecked
cacheMeta = cache.<String, MetaData>hashMap("meta")
.keySerializer(Serializer.STRING)
.valueSerializer(new SerializerJava())
.createOrOpen();
}
示例15: subset_of_data_should_be_selected
import org.mapdb.DB; //导入依赖的package包/类
@Test
public void subset_of_data_should_be_selected(){
DB db = DBMaker.tempFileDB().transactionDisable().fileMmapCleanerHackEnable().make();
CubeDataBuilder cubeDataBuilder = CubeData.builder(db);
cubeDataBuilder.add(Lists.newArrayList(2, 2, 2), Lists.newArrayList("12002","..."));
cubeDataBuilder.add(Lists.newArrayList(3, 3, 3), Lists.newArrayList("12002","..."));
cubeDataBuilder.add(Lists.newArrayList(1, 2, 3), Lists.newArrayList("12002","..."));
cubeDataBuilder.add(Lists.newArrayList(1, 1, 1), Lists.newArrayList("12002","..."));
cubeDataBuilder.add(Lists.newArrayList(1, 1, 2), Lists.newArrayList("12002","..."));
CubeData cubeData = cubeDataBuilder.build();
Map<Integer, List<Integer>> query = ImmutableMap.<Integer, List<Integer>>builder()
.put(0, Lists.newArrayList(1))
.put(1, Lists.newArrayList(1)).build();
Iterator<CubeEntry> it = cubeData.query(query);
List<CubeEntry> result = Lists.newArrayList(it);
assertEquals(2, result.size());
assertArrayEquals(new int[]{1, 1, 1}, result.get(0).vector);
assertArrayEquals(new int[]{1, 1, 2}, result.get(1).vector);
assertArrayEquals(new int[]{3, 3, 3}, cubeData.getSizes());
}