//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void testHighIds(long highMark, int minus, int requiredHeapMb) throws java.io.IOException private void TestHighIds(long highMark, int minus, int requiredHeapMb) { if (!MachineIsOkToRunThisTest(requiredHeapMb)) { return; } long idBelow = highMark - minus; HighIds = idBelow; string propertyKey = "name"; int intPropertyValue = 123; string stringPropertyValue = "Long string, longer than would fit in shortstring"; long[] arrayPropertyValue = new long[] { 1021L, 321L, 343212L }; Transaction tx = _db.beginTx(); Node nodeBelowTheLine = _db.createNode(); nodeBelowTheLine.SetProperty(propertyKey, intPropertyValue); assertEquals(idBelow, nodeBelowTheLine.Id); Node nodeAboveTheLine = _db.createNode(); nodeAboveTheLine.SetProperty(propertyKey, stringPropertyValue); Relationship relBelowTheLine = nodeBelowTheLine.CreateRelationshipTo(nodeAboveTheLine, this); relBelowTheLine.SetProperty(propertyKey, arrayPropertyValue); assertEquals(idBelow, relBelowTheLine.Id); Relationship relAboveTheLine = nodeAboveTheLine.CreateRelationshipTo(nodeBelowTheLine, this); assertEquals(highMark, relAboveTheLine.Id); assertEquals(highMark, nodeAboveTheLine.Id); assertEquals(intPropertyValue, nodeBelowTheLine.GetProperty(propertyKey)); assertEquals(stringPropertyValue, nodeAboveTheLine.GetProperty(propertyKey)); assertTrue(Arrays.Equals(arrayPropertyValue, ( long[] )relBelowTheLine.GetProperty(propertyKey))); tx.Success(); tx.Close(); for (int i = 0; i < 2; i++) { using (Transaction transaction = _db.beginTx()) { assertEquals(nodeAboveTheLine, _db.getNodeById(highMark)); assertEquals(idBelow, nodeBelowTheLine.Id); assertEquals(highMark, nodeAboveTheLine.Id); assertEquals(idBelow, relBelowTheLine.Id); assertEquals(highMark, relAboveTheLine.Id); assertEquals(relBelowTheLine, _db.getNodeById(idBelow).getSingleRelationship(this, Direction.OUTGOING)); assertEquals(relAboveTheLine, _db.getNodeById(idBelow).getSingleRelationship(this, Direction.INCOMING)); assertEquals(idBelow, relBelowTheLine.Id); assertEquals(highMark, relAboveTheLine.Id); assertEquals(AsSet(asList(relBelowTheLine, relAboveTheLine)), AsSet(Iterables.asCollection(_db.getNodeById(idBelow).Relationships))); transaction.Success(); } if (i == 0) { _db = DbRule.restartDatabase(); } } }
public override void Run() { for (int i = 0; i < OPERATIONS_COUNT; i++) { long highestId = HighestNodeId(Db); if (highestId > 0) { long id = ThreadLocalRandom.current().nextLong(highestId); try { using (Transaction tx = Db.beginTx()) { Db.getNodeById(id).delete(); tx.Success(); } } catch (NotFoundException) { // same node was removed concurrently } } MaybeRunIdMaintenance(Db, i); } }
public override void Run() { RandomValues randomValues = RandomValues.create(); awaitLatch(StartSignal); while (!EndSignal.get()) { using (Transaction transaction = DatabaseService.beginTx()) { try { int operationType = randomValues.NextIntValue(3).value(); switch (operationType) { case 0: long targetNodeId = randomValues.NextLongValue(TotalNodes).value(); DatabaseService.getNodeById(targetNodeId).delete(); break; case 1: long nodeId = randomValues.NextLongValue(TotalNodes).value(); Node node = DatabaseService.getNodeById(nodeId); IDictionary <string, object> allProperties = node.AllProperties; foreach (string key in allProperties.Keys) { node.SetProperty(key, randomValues.NextValue().asObject()); } break; case 2: Node nodeToUpdate = DatabaseService.createNode(Label.label("label10")); nodeToUpdate.SetProperty("property", randomValues.NextValue().asObject()); break; default: throw new System.NotSupportedException("Unknown type of index operation"); } transaction.Success(); } catch (Exception) { transaction.Failure(); } } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotIncludeNodesDeletedInSameTxInIndexSeek() public virtual void ShouldNotIncludeNodesDeletedInSameTxInIndexSeek() { // GIVEN CreateNodes(_db, _label, _nonMatching[0]); LongSet toDelete = CreateNodes(_db, _label, _matching[0], _nonMatching[1], _matching[1], _nonMatching[2]); MutableLongSet expected = CreateNodes(_db, _label, _matching[2]); // WHEN MutableLongSet found = new LongHashSet(); using (Transaction tx = _db.beginTx()) { LongIterator deleting = toDelete.longIterator(); while (deleting.hasNext()) { long id = deleting.next(); _db.getNodeById(id).delete(); expected.remove(id); } CollectNodes(found, _db.findNodes(_label, _key, _template, _searchMode)); } // THEN assertThat(found, equalTo(expected)); }
private DbRepresentation AddMoreData2(File path) { _db = StartGraphDatabase(path); using (Transaction tx = _db.beginTx()) { Node donald = _db.getNodeById(2); Node gladstone = _db.createNode(); gladstone.SetProperty("name", "Gladstone"); Relationship hates = donald.CreateRelationshipTo(gladstone, RelationshipType.withName("HATES")); hates.SetProperty("since", 1948); tx.Success(); } DbRepresentation result = DbRepresentation.of(_db); _db.shutdown(); return(result); }
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected: //ORIGINAL LINE: private Thread newThreadForNodeAction(final long nodeId, final System.Action<org.neo4j.graphdb.Node> nodeConsumer) private Thread NewThreadForNodeAction(long nodeId, System.Action <Node> nodeConsumer) { return(new Thread(() => { try { using (Transaction tx = _db.beginTx()) { Node node = _db.getNodeById(nodeId); _barrier.await(); nodeConsumer(node); tx.success(); } } catch (Exception e) { _ex.set(e); } })); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void createAndVerifyGraphStartingWithId(long startId, int requiredHeapMb) throws Exception private void CreateAndVerifyGraphStartingWithId(long startId, int requiredHeapMb) { assumeTrue(MachineIsOkToRunThisTest(requiredHeapMb)); /* * Will create a layout like this: * * (refNode) --> (node) --> (highNode) * ... * ... * * Each node/relationship will have a bunch of different properties on them. */ Node refNode = CreateReferenceNode(_db); HighIds = startId - 1000; sbyte[] bytes = new sbyte[45]; bytes[2] = 5; bytes[10] = 42; IDictionary <string, object> properties = map("number", 11, "short string", "test", "long string", "This is a long value, long enough", "array", bytes); Transaction tx = _db.beginTx(); int count = 10000; for (int i = 0; i < count; i++) { Node node = _db.createNode(); SetProperties(node, properties); Relationship rel1 = refNode.CreateRelationshipTo(node, this); SetProperties(rel1, properties); Node highNode = _db.createNode(); Relationship rel2 = node.CreateRelationshipTo(highNode, _otherType); SetProperties(rel2, properties); SetProperties(highNode, properties); if (i % 100 == 0 && i > 0) { tx.Success(); tx.Close(); tx = _db.beginTx(); } } tx.Success(); tx.Close(); _db = DbRule.restartDatabase(); // Verify the data int verified = 0; using (Transaction transaction = _db.beginTx()) { refNode = _db.getNodeById(refNode.Id); foreach (Relationship rel in refNode.GetRelationships(Direction.OUTGOING)) { Node node = rel.EndNode; AssertProperties(properties, node); AssertProperties(properties, rel); Node highNode = node.GetSingleRelationship(_otherType, Direction.OUTGOING).EndNode; AssertProperties(properties, highNode); verified++; } transaction.Success(); } assertEquals(count, verified); }
protected internal override Node Materialize(long id) { this.Score = Cursor.score(); this.SizeConflict = Cursor.expectedTotalNumberOfResults(); return(GraphDatabaseService.getNodeById(id)); }
public Node newInstance() { return(_db.getNodeById(id++)); }