@Override public GraphExtension create(long byteCount) { final File file = new File(dir.getLocation() + "/transit_schedule"); try { Files.deleteIfExists(file.toPath()); } catch (IOException e) { throw new RuntimeException(e); } this.data = DBMaker.newFileDB(file).transactionDisable().mmapFileEnable().asyncWriteEnable().make(); init(); return this; }
@Override public boolean loadExisting() { this.data = DBMaker.newFileDB(new File(dir.getLocation() + "/transit_schedule")).transactionDisable().mmapFileEnable().readOnly().make(); init(); for (String gtfsFeedId : this.gtfsFeedIds) { GTFSFeed feed = new GTFSFeed(new File(dir.getLocation() + "/" + gtfsFeedId)); this.gtfsFeeds.put(gtfsFeedId, feed); this.transfers.put(gtfsFeedId, new Transfers(feed)); } return true; }
.newFileDB(tmpFile) .closeOnJvmShutdown() .transactionDisable() .deleteFilesAfterClose() .strictDBGet()
private static DB constructDB(File file) { return DBMaker.newFileDB(file) .transactionDisable() .mmapFileEnable() .asyncWriteEnable() .compressionEnable() .make(); }
/** Create a GTFS feed in a temp file */ public GTFSFeed () { // calls to this must be first operation in constructor - why, Java? this(DBMaker.newTempFileDB() .transactionDisable() .mmapFileEnable() .asyncWriteEnable() .deleteFilesAfterClose() .compressionEnable() // .cacheSize(1024 * 1024) this bloats memory consumption .make()); // TODO db.close(); }
db = DBMaker.newFileDB(dbFile) .closeOnJvmShutdown() .transactionDisable() .syncOnCommitDisable() .deleteFilesAfterClose()
comparisonDb = DBMaker.newFileDB(new File(args[1])) .readOnly() .transactionDisable() .closeOnJvmShutdown() .cacheSize(24) .transactionDisable() .cacheSize(48) .closeOnJvmShutdown()
private void init() { DBMaker maker; if (file == null) maker = DBMaker.newMemoryDB(); else { if (overwrite) wipe(file); maker = DBMaker.newFileDB(new File(file)); maker = maker.cacheSize(cache_size); if (async) { maker = maker.asyncWriteEnable(); maker = maker.asyncWriteFlushDelay(10000); } if (mmap) maker = maker.mmapFileEnableIfSupported(); if (compression) maker = maker.compressionEnable(); if (snapshot) maker = maker.snapshotEnable(); if (notxn) maker = maker.transactionDisable(); } db = maker.make(); if (!db.exists("idmap")) idmap = db.createHashMap("idmap") .valueSerializer(new RecordSerializer()) .make(); else idmap = db.getHashMap("idmap"); }
@Override public V put(K key, V value) { if (hashMap.size() == THRESHOLD) { File dbFile; try { dbFile = File.createTempFile("mapdb", "temp"); } catch (IOException e) { throw new UncheckedIOException(e); } mapDB = DBMaker.newFileDB(dbFile).deleteFilesAfterClose().transactionDisable().make(); map = mapDB.createHashMap("map").make(); map.putAll(hashMap); hashMap.clear(); } if (map == null) { return hashMap.put(key, value); } return map.put(key, value); }
@Override public boolean add(E obj) { if (hashSet.size() == THRESHOLD) { File dbFile; try { dbFile = File.createTempFile("mapdb", "temp"); } catch (IOException e) { throw new UncheckedIOException(e); } mapDB = DBMaker.newFileDB(dbFile).deleteFilesAfterClose().transactionDisable().make(); set = mapDB.createHashSet("set").make(); set.addAll(hashSet); hashSet.clear(); } if (set == null) { return hashSet.add(obj); } return set.add(obj); }
@Provides @Singleton DB getMaker() { File dbLocation = new File(configuration.getLocation(), "SciGraphIdMap"); return DBMaker.newFileDB(dbLocation).closeOnJvmShutdown().transactionDisable().mmapFileEnable() .make(); }
/** * Moderate space saving; * mmap file; * LRU instance cache; * close on shutdown; * write-through; * @param loc * @param name * @return */ public static synchronized DBMaker<?> newDefaultDb(String loc,String name){ File dbFile = new File(loc); if (!dbFile.exists()) dbFile.mkdirs(); dbFile = new File(dbFile, "mapdb"); logger.info("Opening DB "+name+" at " + dbFile); // Storing gigantic maps in this temporary DB return DBMaker.newFileDB(dbFile).freeSpaceReclaimQ(3) .mmapFileEnablePartial() .transactionDisable() .cacheLRUEnable() .closeOnJvmShutdown(); }
private MapDb() { try { File file = File.createTempFile("geo-analyzer", ".db"); db = DBMaker.newFileDB(file).asyncWriteEnable().cacheSize(100000) .closeOnJvmShutdown().transactionDisable().make(); } catch (IOException e) { throw new RuntimeException(e); } }
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; } }
public DB initDb(String cacheName) throws PropertyEnricherException { File mapdbCacheDir = new File(getCacheDir(), "mapdb"); createCacheDir(mapdbCacheDir, isTemporary()); DBMaker dbMaker = DBMaker .newFileDB(new File(mapdbCacheDir, cacheName)) .mmapFileEnableIfSupported() .closeOnJvmShutdown() .transactionDisable(); if (isTemporary()) { dbMaker.deleteFilesAfterClose(); } return dbMaker .make(); }
/** Create a GTFS feed in a temp file */ public GTFSFeed () { // calls to this must be first operation in constructor - why, Java? this(DBMaker.newTempFileDB() .transactionDisable() .mmapFileEnable() .asyncWriteEnable() .deleteFilesAfterClose() .compressionEnable() // .cacheSize(1024 * 1024) this bloats memory consumption .make()); // TODO db.close(); }
/** * Constructs Sorter with optional limit and optional distinct filtering * @param limit long limit, where Long.MAXLONG means no limit * @param distinct optional boolean switch to do not preserve multiple equal elements */ public Sorter(long limit, boolean distinct) { this.db = DBMaker.newTempFileDB().deleteFilesAfterClose().closeOnJvmShutdown().transactionDisable().make(); this.map = db.createTreeMap(MAP_NAME).make(); this.limit = limit; this.distinct = distinct; }
public MapDbByteStore(File dir, String dbname, boolean readonly) { this.dir = dir; LessFiles.initDirectory(dir); this.dbFile = new File(dir, "mapdb"); DBMaker dbMaker = DBMaker.newFileDB(dbFile) .transactionDisable() .cacheDisable() .mmapFileEnableIfSupported(); if (readonly) { dbMaker = dbMaker.readOnly(); } this.db = dbMaker.make(); this.btree = db.createTreeMap(dbname) .valuesOutsideNodesEnable() .comparator(UnsignedBytes.lexicographicalComparator()) .makeOrGet(); log.info("MapDB ByteStore started up for {}", dir); }
public void indexInteractions() { DB db = DBMaker .newMemoryDirectDB() .compressionEnable() .transactionDisable() .make(); final Map<Fun.Tuple3<Long, String, Long>, Long> taxonInteractions = db .createTreeMap("ottIdMap") .make(); collectTaxonInteractions(taxonInteractions); createTaxonInteractions(taxonInteractions); db.close(); }