コード例 #1
0
        public void NumDeletionsIsCorrect()
        {
            Mutation mut = new DgraphDotNet.Mutation();

            Edge     edge     = new Edge(new NamedNode(1, "N1"), "AnEdge", new NamedNode(2, "N2"));
            Property property = new Property(new NamedNode(1, "N1"), "AProperty", GraphValue.BuildBoolValue(true));

            mut.DeleteEdge(edge);
            mut.DeleteProperty(property);

            Assert.AreEqual(2, mut.NumDeletions);
        }
コード例 #2
0
        public void NumAdditonsIsCorrect()
        {
            Mutation mut = new DgraphDotNet.Mutation();

            var      n1       = new UIDNode(1);
            var      n2       = new UIDNode(2);
            Edge     edge     = new Edge(n1, "AnEdge", n2);
            Property property = new Property(n1, "AProperty", GraphValue.BuildBoolValue(true));

            mut.AddEdge(edge);
            mut.AddProperty(property);

            Assert.AreEqual(2, mut.NumAdditions);
        }
コード例 #3
0
        private async Task BatchUpdate(Action <IMutation> updateFN)
        {
            // doesn't really matter if threads compete here and end up getting
            // the same batch.  We just need it to roll around.
            var batch = addToBatch;

            addToBatch = (batch + 1) % batches.Count;
            await batchesMutexes[batch].WaitAsync();

            try {
                updateFN(batches[batch]);
                if (batches[batch].NumAdditions + batches[batch].NumDeletions >= batchSize)
                {
                    await SubmittBatch(batch);

                    batches[batch] = new Mutation();
                }
            } finally {
                batchesMutexes[batch].Release();
            }
        }