Beispiel #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void createIndexWithProviderThatUsesNeoAsDataSource()
        internal virtual void CreateIndexWithProviderThatUsesNeoAsDataSource()
        {
            string indexName = "inneo";

            assertFalse(IndexExists(indexName));
            IDictionary <string, string> config = stringMap(PROVIDER, "test-dummy-neo-index", "config1", "A value", "another config", "Another value");

            Index <Node> index;

            using (Transaction transaction = _db.beginTx())
            {
                index = _db.index().forNodes(indexName, config);
                transaction.Success();
            }

            using (Transaction tx = _db.beginTx())
            {
                assertTrue(IndexExists(indexName));
                assertEquals(config, _db.index().getConfiguration(index));
                using (IndexHits <Node> indexHits = index.get("key", "something else"))
                {
                    assertEquals(0, Iterables.count(indexHits));
                }
                tx.Success();
            }

            RestartDb();

            using (Transaction tx = _db.beginTx())
            {
                assertTrue(IndexExists(indexName));
                assertEquals(config, _db.index().getConfiguration(index));
                tx.Success();
            }
        }
Beispiel #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotMakeIndexWritesVisibleUntilCommit() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotMakeIndexWritesVisibleUntilCommit()
        {
            Node commonNode;

            using (Transaction tx = _graphDatabaseService.beginTx())
            {
                commonNode = _graphDatabaseService.createNode();
                tx.Success();
            }

            using (Transaction transaction = _graphDatabaseService.beginTx())
            {
                // index write first so that that datastore is added first
                _graphDatabaseService.index().forNodes(INDEX_NAME).add(commonNode, INDEX_KEY, INDEX_VALUE);
                commonNode.SetProperty(PROPERTY_NAME, PROPERTY_VALUE);

                AssertNodeIsNotIndexedOutsideThisTransaction();
                AssertNodeIsUnchangedOutsideThisTransaction(commonNode);

                transaction.Success();

                AssertNodeIsNotIndexedOutsideThisTransaction();
                AssertNodeIsUnchangedOutsideThisTransaction(commonNode);
            }

            AssertNodeIsIndexed(commonNode);
            AssertNodeHasBeenUpdated(commonNode);
        }
Beispiel #3
0
 private TimelineIndex <PropertyContainer> NodeTimeline()
 {
     using (Transaction tx = _db.beginTx())
     {
         Index <Node> nodeIndex = _db.index().forNodes("timeline");
         tx.Success();
         return(new LuceneTimeline(_db, nodeIndex));
     }
 }
Beispiel #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void createInitialData()
        public virtual void CreateInitialData()
        {
            BeginTx();
            _index = _graphDb.index().forNodes(INDEX_NAME);
            _index.delete();
            RestartTx();

            _index = _graphDb.index().forNodes(INDEX_NAME);
            _key   = "key";

            _value = "my own value";
            _node  = _graphDb.createNode();
            _index.add(_node, _key, _value);
            _workers = new List <WorkThread>();
        }
Beispiel #5
0
 public override void Run()
 {
     using (Transaction tx = Db.beginTx())
     {
         Index <Node> index = Db.index().forNodes("myIndex");
         index.Add(Db.createNode(), "one", "two");
         tx.Success();
     }
 }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testMultipleCreate() throws InterruptedException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void TestMultipleCreate()
        {
            const int numThreads = 25;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final String uuid = java.util.UUID.randomUUID().toString();
            string uuid = System.Guid.randomUUID().ToString();

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.graphdb.Node commonNode;
            Node commonNode;

            using (Transaction tx = _graphDb.beginTx())
            {
                commonNode = _graphDb.createNode();
                tx.Success();
            }

            ExecutorCompletionService <Node> ecs = new ExecutorCompletionService <Node>(Executors.newFixedThreadPool(numThreads));

            for (int i = 0; i < numThreads; i++)
            {
                ecs.submit(() =>
                {
                    using (Transaction tx = _graphDb.beginTx())
                    {
                        Node node = _graphDb.createNode();
                        // Acquire lock
                        tx.AcquireWriteLock(commonNode);
                        Index <Node> index = _graphDb.index().forNodes("uuids");
                        Node existing      = index.get("uuid", uuid).Single;
                        if (existing != null)
                        {
                            throw new Exception("Node already exists");
                        }
                        node.setProperty("uuid", uuid);
                        index.add(node, "uuid", uuid);
                        tx.Success();
                        return(node);
                    }
                });
            }
            int numSucceeded = 0;

            for (int i = 0; i < numThreads; i++)
            {
                try
                {
                    ecs.take().get();
                    ++numSucceeded;
                }
                catch (ExecutionException)
                {
                }
            }
            assertEquals(1, numSucceeded);
        }
 public override void Run()
 {
     while (!Start.get())
     {
         // spin
     }
     using (Transaction tx = Db.beginTx())
     {
         Node node = Db.createNode();
         node.SetProperty(PropertyKey, PropertyValue);
         Db.index().forNodes(INDEX_NAME).add(node, PropertyKey, PropertyValue);
         tx.Success();
     }
 }
 public override void Run()
 {
     while (!Start.get())
     {
         // spin
     }
     Sleep();
     using (Transaction tx = Db.beginTx())
     {
         // it is acceptable to either see a node with correct property or not see it at all
         Node node = Db.index().forNodes(INDEX_NAME).get(PropertyKey, PropertyValue).Single;
         if (node != null)
         {
             assertEquals(PropertyValue, node.GetProperty(PropertyKey));
         }
         tx.Success();
     }
 }
 protected internal virtual Index <Node> NodeIndex(string name, IDictionary <string, string> config)
 {
     return(GraphDb.index().forNodes(name, config));
 }