public void test_merge_context() { var dst = new LinRead(); dst.Ids.Add(new Dictionary <uint, ulong> { { 1, 10L }, { 2, 15L }, { 3, 10L } }); var src = new LinRead(); src.Ids.Add(new Dictionary <uint, ulong> { { 2, 10L }, { 3, 15L }, { 4, 10L } }); var result = DgraphNetClient.MergeLinReads(dst, src); Assert.AreEqual(4, result.Ids.Count); Assert.AreEqual(10L, result.Ids[1]); Assert.AreEqual(15L, result.Ids[2]); Assert.AreEqual(15L, result.Ids[3]); Assert.AreEqual(10L, result.Ids[4]); }
private void MergeContext(TxnContext src) { TxnContext result = new TxnContext(_context); LinRead lr = MergeLinReads(_context.LinRead, src.LinRead); result.LinRead = lr; lock (_client._lock) { lr = MergeLinReads(_client._linRead, lr); _client._linRead = lr; } if (_context.StartTs == 0) { result.StartTs = src.StartTs; } else if (_context.StartTs != src.StartTs) { _context = result; throw new DgraphException("StartTs mismatch"); } result.Keys.Add(src.Keys); _context = result; }
private LinRead GetLinReadCopy() { lock (_lock) { LinRead lr = new LinRead(_linRead); return(lr); } }
internal LinRead GetLinRead() { LinRead lr; lock (LinReadMutex) { lr = new LinRead(linRead); } return(lr); }
internal static void MergeLinReads(LinRead dst, LinRead src) { if (src == null || src.Ids == null) { return; } foreach (var entry in src.Ids) { if (dst.Ids.TryGetValue(entry.Key, out var did) && (did >= entry.Value)) { // do nothing } else { dst.Ids[entry.Key] = entry.Value; } } }
public static LinRead MergeLinReads(LinRead dst, LinRead src) { LinRead result = new LinRead(dst); foreach (var entry in src.Ids) { if (dst.Ids.TryGetValue(entry.Key, out ulong dstValue)) { if (dstValue < entry.Value) { result.Ids[entry.Key] = entry.Value; } } else { result.Ids.Add(entry.Key, entry.Value); } } return(result); }
internal void MergeLinRead(LinRead newLinRead) { lock (LinReadMutex) { Transaction.MergeLinReads(linRead, newLinRead); } }
internal DgraphClient(IGRPCConnectionFactory connectionFactory, ITransactionFactory transactionFactory) { this.connectionFactory = connectionFactory; this.transactionFactory = transactionFactory; linRead = new LinRead(); }
private DgraphNetClient() { _linRead = new LinRead(); }