.keySerializer(getBTreeKeySerializerFromClass(keyClass)) .valueSerializer(getSerializerFromClass(valueClass)) .makeOrGet();
@Override public void addUser(String username, String password, String givenName, String familyName, Collection<String> roles) { ClassLoader old = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); synchronized (db) { Map<String, Object> m = db.createTreeMap(username).makeOrGet(); m.put("user", username); m.put("password", DigestUtils.sha256Hex(password)); m.put("givenName", givenName); m.put("familyName", familyName); m.put("roles", new ArrayList<>(roles)); db.commit(); } } finally { Thread.currentThread().setContextClassLoader(old); } }
.keySerializer(BTreeKeySerializer.ZERO_OR_POSITIVE_LONG) .counterEnable() .makeOrGet(); Atomic.String journalAtomic = this.journalDB.getAtomicString(JOURNAL_ID_FIELD);
this.options = db.createHashMap(name + "/options").makeOrGet(); this.keysByValue = db.createTreeMap(name).counterEnable().comparator(valueSerializer.getComparator()) .keySerializer(valueSerializer).makeOrGet();
this.options = db.createHashMap(name + "/options").makeOrGet(); this.keysByValue = db.createTreeMap(name).counterEnable().comparator(valueSerializer.getComparator()) .keySerializer(valueSerializer).makeOrGet();
.keySerializer(BTreeKeySerializer.ZERO_OR_POSITIVE_LONG) .counterEnable() .makeOrGet(); Atomic.String journalAtomic = this.journalDB.getAtomicString(JOURNAL_ID_FIELD);
/** * Create a new DataStore. * @param directory Where should it be created? */ public JumperDataStore(File directory) { if(!directory.exists()) directory.mkdirs(); DBMaker dbm = DBMaker.newFileDB(new File(directory, "jumpers.db")) .mmapFileEnableIfSupported() .cacheLRUEnable() .cacheSize(100000) .asyncWriteEnable() .asyncWriteFlushDelay(1000) .closeOnJvmShutdown(); db = dbm.make(); jumperMap = db.createTreeMap("jumperMap") .valueSerializer(new JumperSerializer()) .makeOrGet(); jumperStartIndex = db.createTreeSet("startIndex") .serializer(BTreeKeySerializer.TUPLE2) .makeOrGet(); jumperEndIndex = db.createTreeSet("endIndex") .serializer(BTreeKeySerializer.TUPLE2) .makeOrGet(); }
public void setFile(File file) { ClassLoader old = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); db = DBMaker.newFileDB(file) .closeOnJvmShutdown() .make(); synchronized (db) { Map<String, Object> m = db.createTreeMap("admin").makeOrGet(); if (!m.containsKey("password")) { m.put("user", DEFAULT_USER); m.put("password", DigestUtils.sha256Hex("password")); m.put("givenName", "Administrator"); m.put("familyName", "User"); m.put("roles", Collections.singletonList("administrator")); db.commit(); } } } finally { Thread.currentThread().setContextClassLoader(old); } }
/** * Create a new DataStore. * @param directory Where should it be created? * @param dataFile What should it be called? */ public SpatialDataStore(File directory, String dataFile, Serializer serializer, Integer cacheSize) { this.dataFile = dataFile; if(!directory.exists()) directory.mkdirs(); spatialId = new IdStore(directory, dataFile); DBMaker dbm = DBMaker.newFileDB(new File(directory, dataFile + ".db")) .mmapFileEnableIfSupported() .cacheLRUEnable() .cacheSize(cacheSize) .closeOnJvmShutdown(); db = dbm.make(); BTreeMapMaker maker = db.createTreeMap(dataFile) .valueSerializer(serializer) .keySerializer(BTreeKeySerializer.ZERO_OR_POSITIVE_LONG); map = maker.makeOrGet(); tileIndex = db.createTreeSet(dataFile + "_tileIndex") .serializer(BTreeKeySerializer.TUPLE3).makeOrGet(); }
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 MapDbStorage(DB db, String name, @Nullable ClassLoader classLoader) { this.name = name; this.db = db; this.classLoader = classLoader; this.map = db.createTreeMap(name).makeOrGet(); this.mapper = new GsonBuilder().registerTypeAdapterFactory(new PropertiesTypeAdapterFactory()).create(); }
protected NavigableMap<BindingSet, Integer> makeOrderedMap() { if (db == null) { // no disk-syncing - we use a simple in-memory TreeMap instead. return new TreeMap<BindingSet, Integer>(comparator); } else { return db.createTreeMap("iteration").comparator(comparator).makeOrGet(); } }
public StreetDataStore(File directory, String dataFile, Serializer serializer, Integer cacheSize) { super(directory, dataFile, serializer, cacheSize); BTreeMapMaker idMapMaker = db.createTreeMap(dataFile + "_segmentIndex") .valueSerializer(Serializer.LONG) .keySerializer(BTreeKeySerializer.TUPLE3); segmentIndex = idMapMaker.makeOrGet(); BTreeMapMaker segmentTypeMapMaker = db.createTreeMap(dataFile + "_segmentTypeIndex") .valueSerializer(Serializer.INTEGER) .keySerializer(BTreeKeySerializer.ZERO_OR_POSITIVE_LONG); segmentTypeMap = segmentTypeMapMaker.makeOrGet(); }