public void close() { // TODO: when concurrency is implemented a lot of work needs to be done // hashTablesExecutor.shutdown(); // nodesExecutor.shutdown(); records.close(); if (this.getConfiguration().isKeyed) { String[] keyFieldNames = this.getConfiguration().keyFieldNames; for (int j = 0; j < keyFieldNames.Length; j++) { String keyFieldName = keyFieldNames[j]; persistCache(keyFieldName); IStoreEngine keyStore = getKeyMap(keyFieldName); keyStore.close(); IStoreEngine dataStore = getDataMap(keyFieldName); dataStore.close(); } } else { data.close(); keys.close(); } }
//TODO: StoreEngineFactory has to go, the engine should be injected directly. public Configuration(String folder, String dbName, IStoreEngine db, bool massInsertMode) { try { this.folder = folder; this.dbName = dbName; this.db = db; //db = StoreEngineFactory.build(folder, dbName, "conf", dbEngine, massInsertMode); if (db.contains(Configuration.KEY_NAMES)) { this.keyFieldNames = (String[])db.get(Configuration.KEY_NAMES); } if (db.contains(Configuration.KEY_MODE)) { this.isKeyed = (bool)db.get(Configuration.KEY_MODE); } if (keyFieldNames != null) { for (int i = 0; i < this.keyFieldNames.Length; i++) { String keyFieldName = this.keyFieldNames[i]; keys[keyFieldName] = (Key)db.get("conf_" + keyFieldName); } } } catch (Exception ex) { throw new StoreInitException("Store init error: " + ex.Message); } }
public void init(IStoreEngineFactory dbEngine, bool massInsertMode) { try { this.dbEngine = dbEngine; pathToDB = Path.Combine(folder, storeName); records = dbEngine.createInstance(folder, storeName, RECORDS, massInsertMode); if ((this.getConfiguration() != null) && (this.getConfiguration().isKeyed)) { String[] keyFieldNames = this.getConfiguration().keyFieldNames; for (int j = 0; j < keyFieldNames.Length; j++) { String keyFieldName = keyFieldNames[j]; setKeyMap(keyFieldName, massInsertMode); setDataMap(keyFieldName, massInsertMode); } } else { keys = dbEngine.createInstance(folder, storeName, KEYS, massInsertMode); data = dbEngine.createInstance(folder, storeName, DATA, massInsertMode); keyMap[Configuration.RECORD_LEVEL] = keys; dataMap[Configuration.RECORD_LEVEL] = data; cacheMap[Configuration.RECORD_LEVEL] = new Dictionary <String, Object>(); } } catch (Exception ex) { Console.Error.WriteLine(ex.Message); throw new Exception("Something went wrong while creating the dbEngine"); } }
public HammingLSHStore(String folder, String dbName, IStoreEngineFactory dbEngine) { this.folder = folder; this.storeName = dbName; IStoreEngine db = dbEngine.createInstance(folder, dbName, "conf", massInsertMode); hConf = new HammingConfiguration(folder, dbName, db, massInsertMode); init(dbEngine, massInsertMode); hConf.saveConfiguration(); }
public Configuration(String folder, String dbName, IStoreEngine db, Key[] keysList, bool massInsertMode) { try { this.folder = folder; this.dbName = dbName; this.db = db; //db = StoreEngineFactory.build(folder, dbName, "conf", dbEngine, massInsertMode); if (db.contains(Configuration.KEY_NAMES)) { var kfn = db.get(Configuration.KEY_NAMES); this.keyFieldNames = kfn as string[];//TODO: FIX JSON STORAGE OR IMPLEMENT ANOTHER for (int i = 0; i < this.keyFieldNames.Length; i++) { String keyFieldName = this.keyFieldNames[i]; this.keys[keyFieldName] = (Key)db.get("conf_" + keyFieldName); } if (db.contains(Configuration.KEY_MODE)) { this.isKeyed = (bool)db.get(Configuration.KEY_MODE); } if (db.contains(Configuration.PRIVATE_MODE)) { this.isPrivate = true; } } else { this.keyFieldNames = new String[keysList.Length]; for (int i = 0; i < keysList.Length; i++) { this.keyFieldNames[i] = keysList[i].keyFieldName; keys[keyFieldNames[i]] = keysList[i]; db.set("conf_" + this.keyFieldNames[i], keysList[i]); if (this.keyFieldNames[0] == Configuration.RECORD_LEVEL) { this.isKeyed = false; } else { this.isKeyed = true; } } db.set(Configuration.KEY_MODE, this.isKeyed); db.set(Configuration.KEY_NAMES, this.keyFieldNames); } } catch (Exception ex) { throw new StoreInitException("Store init error: " + ex.Message); } }
public HammingLSHStore(String folder, String dbName, IStoreEngineFactory dbEngine, Configuration hc, bool massInsertMode) { this.folder = folder; this.storeName = dbName; this.massInsertMode = massInsertMode; if (hc == null) { IStoreEngine db = dbEngine.createInstance(folder, dbName, "conf", massInsertMode); hConf = new HammingConfiguration(folder, dbName, db, massInsertMode); } else { hConf = (HammingConfiguration)hc; } init(dbEngine, massInsertMode); }
protected override void OnAttached(string name, IServerPart part) { switch (name) { case PartNames.Cache: _cacheEngine = (CacheEngine)part; break; case PartNames.Store: _storeEngine = (IStoreEngine)part; break; default: throw new NotSupportedException($"Unknown part: '{name}'"); } }
public void persistCache(String keyFieldName) { bool isKeyed = this.getConfiguration().isKeyed; IStoreEngine hashKeys = keys; if (isKeyed) { hashKeys = this.getKeyMap(keyFieldName); } Dictionary <String, Object> cache = getCacheMap(keyFieldName); foreach (string key in cache.Keys) { long tt = incId(); hashKeys.set(key + "_" + tt, cache[key]); } cache.Clear(); }
public void setHashKeys(String id, Embeddable emb, String keyFieldName) { bool isKeyed = this.getConfiguration().isKeyed; String[] keyFieldNames = this.getConfiguration().keyFieldNames; IStoreEngine hashKeys = keys; if (isKeyed) { hashKeys = this.getKeyMap(keyFieldName); } Dictionary <String, Object> cache = this.getCacheMap(keyFieldName); Key key = this.getConfiguration().getKey(keyFieldName); for (int j = 0; j < key.L; j++) { String hashKey = buildHashKey(j, emb, keyFieldName); if (cache.ContainsKey(hashKey)) { List <String> arr = (List <String>)cache[hashKey]; arr.Add(id); if (arr.Count >= CACHEENTRYLIMIT) { long tt = incId(); hashKeys.set(hashKey + "_" + tt, arr); cache.Remove(hashKey); } } else { List <String> arr = new List <String>(); arr.Add(id); cache[hashKey] = arr; } if (cache.Count >= CACHENOLIMIT) { persistCache(keyFieldName); } } }
public Configuration(IStoreEngine db, Key[] keysList) { this.keyFieldNames = new String[keysList.Length]; for (int i = 0; i < keysList.Length; i++) { this.keyFieldNames[i] = keysList[i].keyFieldName; keys[keyFieldNames[i]] = keysList[i]; db.set("conf_" + this.keyFieldNames[i], keysList[i]); if (this.keyFieldNames[0] == Configuration.RECORD_LEVEL) { this.isKeyed = false; } else { this.isKeyed = true; } } db.set(Configuration.KEY_MODE, this.isKeyed); db.set(Configuration.KEY_NAMES, this.keyFieldNames); }
public Configuration create(string folder, string dbName, IStoreEngine dbEngine, bool massInsertMode) { return(new HammingConfiguration(folder, dbName, dbEngine, massInsertMode)); }
public HammingConfiguration(String folder, String dbName, IStoreEngine dbEngine, Key[] keysList, bool massInsertMode) : base(folder, dbName, dbEngine, keysList, massInsertMode) { }