/// <summary> /// LTrie makes in case of InsertTable call /// </summary> /// <param name="nestedTable"></param> internal void AddNestedTable(ref byte[] key, ulong fullValueStart, long rootStart, NestedTableInternal nestedTable) { Sync_NestedTables.EnterWriteLock(); try { string hash = key.ToBase64String(); ulong ptr = 0; _nestedTblsViaKeys.TryGetValue(hash, out ptr); if (ptr == 0) { _nestedTblsViaKeys.Add(hash, fullValueStart); } Dictionary <long, NestedTableInternal> dict = null; _nestedTables.TryGetValue(fullValueStart, out dict); if (dict == null) { Dictionary <long, NestedTableInternal> d = new Dictionary <long, NestedTableInternal>(); d.Add(rootStart, nestedTable); _nestedTables.Add(fullValueStart, d); countNested++; } else { NestedTableInternal dit = null; dict.TryGetValue(rootStart, out dit); if (dit == null) { _nestedTables[fullValueStart].Add(rootStart, nestedTable); } //else all ok, skip } } catch (System.Exception ex) { //CASCADE throw ex; } finally { Sync_NestedTables.ExitWriteLock(); } }
/// <summary> /// Returns null if table is not in the coordinator, otherwise returns reference to the table /// </summary> /// <param name="fullValueStart"></param> /// <param name="rootStart"></param> /// <returns></returns> internal NestedTableInternal GetTable(ref byte[] key, long rootStart) { Sync_NestedTables.EnterReadLock(); try { string hash = key.ToBase64String(); ulong ptr = 0; _nestedTblsViaKeys.TryGetValue(hash, out ptr); if (ptr == 0) { return(null); } Dictionary <long, NestedTableInternal> dict = null; _nestedTables.TryGetValue(ptr, out dict); if (dict == null) { return(null); } NestedTableInternal dit = null; dict.TryGetValue(rootStart, out dit); return(dit); } catch (Exception ex) { //CASCADE throw ex; } finally { Sync_NestedTables.ExitReadLock(); } }
/// <summary> /// LTrie makes in case of InsertTable call /// </summary> /// <param name="nestedTable"></param> internal void AddNestedTable(ref byte[] key, ulong fullValueStart, long rootStart, NestedTableInternal nestedTable) { Sync_NestedTables.EnterWriteLock(); try { string hash = key.ToBase64String(); ulong ptr = 0; _nestedTblsViaKeys.TryGetValue(hash, out ptr); if (ptr == 0) _nestedTblsViaKeys.Add(hash, fullValueStart); Dictionary<long, NestedTableInternal> dict = null; _nestedTables.TryGetValue(fullValueStart, out dict); if (dict == null) { Dictionary<long, NestedTableInternal> d = new Dictionary<long, NestedTableInternal>(); d.Add(rootStart, nestedTable); _nestedTables.Add(fullValueStart, d); countNested++; } else { NestedTableInternal dit = null; dict.TryGetValue(rootStart, out dit); if (dit == null) { _nestedTables[fullValueStart].Add(rootStart, nestedTable); } //else all ok, skip } } catch (System.Exception ex) { //CASCADE throw ex; } finally { Sync_NestedTables.ExitWriteLock(); } }