本文整理汇总了Java中org.mapdb.Atomic类的典型用法代码示例。如果您正苦于以下问题:Java Atomic类的具体用法?Java Atomic怎么用?Java Atomic使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Atomic类属于org.mapdb包,在下文中一共展示了Atomic类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveReferenceNetwork
import org.mapdb.Atomic; //导入依赖的package包/类
public void saveReferenceNetwork(Network network) throws IOException {
Objects.requireNonNull(network);
if (!config.getMapDb().isPersistent()) {
this.referenceNetwork = network;
} else if (this.referenceNetwork == null || !this.referenceNetwork.getId().equals(network.getId())) {
DataSource dataSource = new FileDataSource(storeDir, network.getId());
Properties parameters = new Properties();
parameters.setProperty("iidm.export.xml.indent", "true");
Exporters.export("XIIDM", network, parameters, dataSource);
Atomic.String reference = db.atomicString("referenceNetwotk").createOrOpen();
String oldNet = reference.get();
reference.set(network.getId() + ".xiidm");
this.referenceNetwork = network;
if (oldNet != null) {
Files.delete(Paths.get(storeDir.toString(), oldNet));
}
}
}
示例2: loadDataFromFile
import org.mapdb.Atomic; //导入依赖的package包/类
/**
* Reads all Metadata internal datastructure from file to the instance of this class
*/
public void loadDataFromFile() {
AptaLogger.log(Level.CONFIG, this.getClass(), "Reading metadata file from '" + this.metadataPath.toFile());
// Open a connection to disk
DB db = DBMaker
.fileDB(this.metadataPath.toFile())
.readOnly()
.fileMmapEnableIfSupported()
.closeOnJvmShutdown()
.make();
// Load all class members from db
Atomic.Var<Object> variable;
variable = db.atomicVar("qualityScoresForward").createOrOpen();
qualityScoresForward = (HashMap<String, ConcurrentHashMap<Integer, Accumulator>>) variable.get();
variable = db.atomicVar("qualityScoresReverse").createOrOpen();
qualityScoresReverse = (HashMap<String, ConcurrentHashMap<Integer, Accumulator>>) variable.get();
variable = db.atomicVar("nucleotideDistributionForward").createOrOpen();
nucleotideDistributionForward = (HashMap<String, ConcurrentHashMap<Integer, ConcurrentHashMap<Byte, Integer>>>) variable.get();
variable = db.atomicVar("nucleotideDistributionReverse").createOrOpen();
nucleotideDistributionReverse = (HashMap<String, ConcurrentHashMap<Integer, ConcurrentHashMap<Byte, Integer>>>) variable.get();
variable = db.atomicVar("nucleotideDistributionAccepted").createOrOpen();
nucleotideDistributionAccepted = (HashMap<String, ConcurrentHashMap<Integer, ConcurrentHashMap<Integer, ConcurrentHashMap<Byte, Integer>>>>) variable.get();
variable = db.atomicVar("parserStatistics").createOrOpen();
parserStatistics = (HashMap<String, Integer>) variable.get();
// Close database connection
db.close();
}
示例3: saveDataToFile
import org.mapdb.Atomic; //导入依赖的package包/类
/**
* Takes the current state of all class members of Metadata and dumps them on disk
*/
public void saveDataToFile() {
// Open a connection to disk
DB db = DBMaker
.fileDB(this.metadataPath.toFile())
.fileMmapEnableIfSupported()
.closeOnJvmShutdown()
.make();
// Load all class members from db
Atomic.Var<Object> variable;
variable = db.atomicVar("qualityScoresForward").createOrOpen();
variable.set(qualityScoresForward);
variable = db.atomicVar("qualityScoresReverse").createOrOpen();
variable.set(qualityScoresReverse);
variable = db.atomicVar("nucleotideDistributionForward").createOrOpen();
variable.set(nucleotideDistributionForward);
variable = db.atomicVar("nucleotideDistributionReverse").createOrOpen();
variable.set(nucleotideDistributionReverse);
variable = db.atomicVar("nucleotideDistributionAccepted").createOrOpen();
variable.set(nucleotideDistributionAccepted);
variable = db.atomicVar("parserStatistics").createOrOpen();
variable.set(parserStatistics);
// Close database connection
db.close();
AptaLogger.log(Level.CONFIG, this.getClass(), "Saved metadata to file '" + this.metadataPath.toFile());
}
示例4: createPrefixedURI
import org.mapdb.Atomic; //导入依赖的package包/类
public static String createPrefixedURI(final String fullURI, final Map<String, String> uriPrefixedURIMap,
final Map<String, String> tempNamespacePrefixes, final Map<String, String> inMemoryNamespacePrefixes,
final Tuple<Atomic.Long, DB> prefixCounterTuple, final GraphDatabaseService database,
final TransactionHandler tx)
throws DMPGraphException {
if (fullURI == null) {
throw new DMPGraphException("full URI shouldn't be null");
}
if (uriPrefixedURIMap != null) {
if (!uriPrefixedURIMap.containsKey(fullURI)) {
final String prefixedURI = determinePrefixedURI(fullURI, tempNamespacePrefixes, inMemoryNamespacePrefixes, prefixCounterTuple,
database, tx);
uriPrefixedURIMap.put(fullURI, prefixedURI);
}
return uriPrefixedURIMap.get(fullURI);
} else {
return determinePrefixedURI(fullURI, tempNamespacePrefixes, inMemoryNamespacePrefixes, prefixCounterTuple, database, tx);
}
}
示例5: determinePrefixedURI
import org.mapdb.Atomic; //导入依赖的package包/类
public static String determinePrefixedURI(final String fullURI, final Map<String, String> tempNamespacePrefixes,
final Map<String, String> inMemoryNamespacePrefixes, final Tuple<Atomic.Long, DB> prefixCounterTuple, final GraphDatabaseService database,
final TransactionHandler tx)
throws DMPGraphException {
final Tuple<String, String> uriParts = URI.determineParts(fullURI);
final String namespaceURI = uriParts.v1();
final String localName = uriParts.v2();
final String prefix = NamespaceUtils
.getPrefix(namespaceURI, tempNamespacePrefixes, inMemoryNamespacePrefixes, prefixCounterTuple, database, tx);
return prefix + NamespaceUtils.PREFIX_DELIMITER + localName;
}
示例6: createOrGetLongIndex
import org.mapdb.Atomic; //导入依赖的package包/类
public static Atomic.Long createOrGetLongIndex(final DB db, final String indexName, final long initValue) {
final Atomic.Long longIndex;
if (db.getCatalog().containsKey(indexName)) {
final Atomic.Long atomicLong = db.getAtomicLong(indexName);
atomicLong.getAndSet(initValue);
longIndex = atomicLong;
db.commit();
} else {
longIndex = db.createAtomicLong(indexName, initValue);
}
return longIndex;
}
示例7: getNewPrefixCount
import org.mapdb.Atomic; //导入依赖的package包/类
private static long getNewPrefixCount(final Tuple<Atomic.Long, DB> prefixCounterTuple) {
final Atomic.Long prefixCounter = prefixCounterTuple.v1();
final DB prefixCounterDB = prefixCounterTuple.v2();
final long prefixCount = prefixCounter.getAndIncrement();
prefixCounterDB.commit();
return prefixCount;
}
示例8: createOrGetPersistentLongIndexGlobalTransactional
import org.mapdb.Atomic; //导入依赖的package包/类
public static Tuple<Atomic.Long, DB> createOrGetPersistentLongIndexGlobalTransactional(final String indexFileName, final String indexName,
final long initValue) {
final DB db = createGlobalTransactionalPermanentMapDB(indexFileName);
return Tuple.tuple(createOrGetLongIndex(db, indexName, initValue), db);
}
示例9: createLongIndex
import org.mapdb.Atomic; //导入依赖的package包/类
public static Atomic.Long createLongIndex(final DB db, final String indexName) {
return db.getAtomicLong(indexName);
}