Esempio n. 1
0
 protected internal override bool FetchNext()
 {
     while (_source.MoveNext())
     {
         Document doc = _source.Current;
         long     id  = IdFromDoc(doc);
         bool     documentIsFromStore = doc.getField(FullTxData.TX_STATE_KEY) == null;
         bool     idWillBeReturnedByTransactionStateInstead = documentIsFromStore && _idsModifiedInTransactionState.contains(id);
         if (_removedInTransactionState.Contains(_idCostume.setId(id)) || idWillBeReturnedByTransactionStateInstead)
         {
             // Skip this one, continue to the next
             continue;
         }
         return(Next(id));
     }
     return(EndReached());
 }
 private Node Highest(string key, IndexHits <Node> query)
 {
     using (IndexHits <Node> hits = query)
     {
         long highestValue = long.MinValue;
         Node highestNode  = null;
         while (hits.MoveNext())
         {
             Node node  = hits.Current;
             long value = (( Number )node.GetProperty(key)).longValue();
             if (value > highestValue)
             {
                 highestValue = value;
                 highestNode  = node;
             }
         }
         return(highestNode);
     }
 }
Esempio n. 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void getSingleMustNotCloseStatementTwice()
        public virtual void getSingleMustNotCloseStatementTwice()
        {
            // given
            string indexName = "index";
            long   expected1;
            long   expected2;

            using (Transaction tx = Db.beginTx())
            {
                Node         node1     = Db.createNode();
                Node         node2     = Db.createNode();
                Index <Node> nodeIndex = Db.index().forNodes(indexName);
                nodeIndex.Add(node1, "key", "hej");
                nodeIndex.Add(node2, "key", "hejhej");

                expected1 = node1.Id;
                expected2 = node2.Id;
                tx.Success();
            }

            using (Transaction tx = Db.beginTx())
            {
                Index <Node> nodeIndex = Db.index().forNodes(indexName);

                // when using getSingle this should not close statement for outer loop
                IndexHits <Node> hits = nodeIndex.query("key", "hej");
                while (hits.MoveNext())
                {
                    Node actual1 = hits.Current;
                    assertEquals(expected1, actual1.Id);

                    IndexHits <Node> hits2   = nodeIndex.query("key", "hejhej");
                    Node             actual2 = hits2.Single;
                    assertEquals(expected2, actual2.Id);
                }
                tx.Success();
            }
        }