//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldHandleCompositeSizesCloseToTheLimit() throws org.neo4j.internal.kernel.api.exceptions.KernelException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldHandleCompositeSizesCloseToTheLimit() { // given CreateIndex(KEY, KEY2); // when a string longer than native string limit, but within lucene limit int length = 20_000; string string1 = Random.nextAlphaNumericString(length, length); string string2 = Random.nextAlphaNumericString(length, length); Node node; using (Transaction tx = Db.beginTx()) { node = Db.createNode(LABEL); node.SetProperty(KEY, string1); node.SetProperty(KEY2, string2); tx.Success(); } using (Transaction tx = Db.beginTx()) { KernelTransaction ktx = Db.DependencyResolver.resolveDependency(typeof(ThreadToStatementContextBridge)).getKernelTransactionBoundToThisThread(true); int labelId = ktx.TokenRead().nodeLabel(LABEL.Name()); int propertyKeyId1 = ktx.TokenRead().propertyKey(KEY); int propertyKeyId2 = ktx.TokenRead().propertyKey(KEY2); using (NodeValueIndexCursor cursor = ktx.Cursors().allocateNodeValueIndexCursor()) { ktx.DataRead().nodeIndexSeek(TestIndexDescriptorFactory.forLabel(labelId, propertyKeyId1, propertyKeyId2), cursor, IndexOrder.NONE, false, IndexQuery.exact(propertyKeyId1, string1), IndexQuery.exact(propertyKeyId2, string2)); assertTrue(cursor.Next()); assertEquals(node.Id, cursor.NodeReference()); assertFalse(cursor.Next()); } tx.Success(); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void assertIndexedNodesMatchesStoreNodes() throws Exception private void AssertIndexedNodesMatchesStoreNodes() { int nodesInStore = 0; Label label = Label.label(PERSON_LABEL); using (Transaction tx = _db.beginTx()) { KernelTransaction ktx = (( GraphDatabaseAPI )_db).DependencyResolver.resolveDependency(typeof(ThreadToStatementContextBridge)).getKernelTransactionBoundToThisThread(true); IList <string> mismatches = new List <string>(); int labelId = ktx.TokenRead().nodeLabel(PERSON_LABEL); int propertyKeyId = ktx.TokenRead().propertyKey(NAME_PROPERTY); IndexReference index = ktx.SchemaRead().index(labelId, propertyKeyId); using (NodeValueIndexCursor cursor = ktx.Cursors().allocateNodeValueIndexCursor()) { // Node --> Index foreach (Node node in filter(n => n.hasLabel(label) && n.hasProperty(NAME_PROPERTY), _db.AllNodes)) { nodesInStore++; string name = ( string )node.GetProperty(NAME_PROPERTY); ktx.DataRead().nodeIndexSeek(index, cursor, IndexOrder.NONE, false, IndexQuery.exact(propertyKeyId, name)); bool found = false; while (cursor.Next()) { long indexedNode = cursor.NodeReference(); if (indexedNode == node.Id) { if (found) { mismatches.Add("Index has multiple entries for " + name + " and " + indexedNode); } found = true; } } if (!found) { mismatches.Add("Index is missing entry for " + name + " " + node); } } if (mismatches.Count > 0) { fail(join(mismatches.ToArray(), format("%n"))); } // Node count == indexed node count ktx.DataRead().nodeIndexSeek(index, cursor, IndexOrder.NONE, false, IndexQuery.exists(propertyKeyId)); int nodesInIndex = 0; while (cursor.Next()) { nodesInIndex++; } assertEquals(nodesInStore, nodesInIndex); } } }
public override bool HasProperty(string key) { if (null == key) { return(false); } KernelTransaction transaction = _spi.kernelTransaction(); int propertyKey = transaction.TokenRead().propertyKey(key); if (propertyKey == [email protected]_Fields.NO_TOKEN) { return(false); } RelationshipScanCursor relationships = transaction.AmbientRelationshipCursor(); PropertyCursor properties = transaction.AmbientPropertyCursor(); SingleRelationship(transaction, relationships); relationships.Properties(properties); while (properties.Next()) { if (propertyKey == properties.PropertyKey()) { return(true); } } return(false); }
public override object GetProperty(string key, object defaultValue) { if (null == key) { throw new System.ArgumentException("(null) property key is not allowed"); } KernelTransaction transaction = _spi.kernelTransaction(); RelationshipScanCursor relationships = transaction.AmbientRelationshipCursor(); PropertyCursor properties = transaction.AmbientPropertyCursor(); int propertyKey = transaction.TokenRead().propertyKey(key); if (propertyKey == [email protected]_Fields.NO_TOKEN) { return(defaultValue); } SingleRelationship(transaction, relationships); relationships.Properties(properties); while (properties.Next()) { if (propertyKey == properties.PropertyKey()) { Value value = properties.PropertyValue(); return(value == Values.NO_VALUE ? defaultValue : value.AsObjectCopy()); } } return(defaultValue); }
public override bool HasRelationship(Direction direction, params RelationshipType[] types) { KernelTransaction transaction = SafeAcquireTransaction(); int[] typeIds = RelTypeIds(types, transaction.TokenRead()); return(InnerHasRelationships(transaction, direction, typeIds)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void batchInserterShouldUseConfiguredIndexProvider() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void BatchInserterShouldUseConfiguredIndexProvider() { Config config = Config.defaults(stringMap(default_schema_provider.name(), _schemaIndex.providerName())); BatchInserter inserter = NewBatchInserter(config); inserter.CreateDeferredSchemaIndex(TestLabels.LABEL_ONE).on("key").create(); inserter.Shutdown(); GraphDatabaseService db = GraphDatabaseService(config); AwaitIndexesOnline(db); try { using (Transaction tx = Db.beginTx()) { DependencyResolver dependencyResolver = (( GraphDatabaseAPI )db).DependencyResolver; ThreadToStatementContextBridge threadToStatementContextBridge = dependencyResolver.ResolveDependency(typeof(ThreadToStatementContextBridge)); KernelTransaction kernelTransaction = threadToStatementContextBridge.GetKernelTransactionBoundToThisThread(true); TokenRead tokenRead = kernelTransaction.TokenRead(); SchemaRead schemaRead = kernelTransaction.SchemaRead(); int labelId = tokenRead.NodeLabel(TestLabels.LABEL_ONE.name()); int propertyId = tokenRead.PropertyKey("key"); IndexReference index = schemaRead.Index(labelId, propertyId); assertTrue(UnexpectedIndexProviderMessage(index), _schemaIndex.providerName().contains(index.ProviderKey())); assertTrue(UnexpectedIndexProviderMessage(index), _schemaIndex.providerName().contains(index.ProviderVersion())); tx.Success(); } } finally { Db.shutdown(); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public Object getProperty(String key) throws org.neo4j.graphdb.NotFoundException public override object GetProperty(string key) { if (null == key) { throw new System.ArgumentException("(null) property key is not allowed"); } KernelTransaction transaction = SafeAcquireTransaction(); int propertyKey = transaction.TokenRead().propertyKey(key); if (propertyKey == [email protected]_Fields.NO_TOKEN) { throw new NotFoundException(format("No such property, '%s'.", key)); } NodeCursor nodes = transaction.AmbientNodeCursor(); PropertyCursor properties = transaction.AmbientPropertyCursor(); SingleNode(transaction, nodes); nodes.Properties(properties); while (properties.Next()) { if (propertyKey == properties.PropertyKey()) { Value value = properties.PropertyValue(); if (value == Values.NO_VALUE) { throw new NotFoundException(format("No such property, '%s'.", key)); } return(value.AsObjectCopy()); } } throw new NotFoundException(format("No such property, '%s'.", key)); }
public virtual int getDegree(RelationshipType type, Direction direction) { KernelTransaction transaction = SafeAcquireTransaction(); int typeId = transaction.TokenRead().relationshipType(type.Name()); if (typeId == NO_TOKEN) { // This type doesn't even exist. Return 0 return(0); } using (Statement ignore = transaction.AcquireStatement()) { NodeCursor nodes = transaction.AmbientNodeCursor(); SingleNode(transaction, nodes); switch (direction.innerEnumValue) { case Direction.InnerEnum.OUTGOING: return(Nodes.countOutgoing(nodes, transaction.Cursors(), typeId)); case Direction.InnerEnum.INCOMING: return(Nodes.countIncoming(nodes, transaction.Cursors(), typeId)); case Direction.InnerEnum.BOTH: return(Nodes.countAll(nodes, transaction.Cursors(), typeId)); default: throw new System.InvalidOperationException("Unknown direction " + direction); } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void addingANodeWithPropertyShouldGetIndexed() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void AddingANodeWithPropertyShouldGetIndexed() { // Given string indexProperty = "indexProperty"; GatheringIndexWriter writer = NewWriter(); createIndex(_db, _myLabel, indexProperty); // When int value1 = 12; string otherProperty = "otherProperty"; int otherValue = 17; Node node = CreateNode(map(indexProperty, value1, otherProperty, otherValue), _myLabel); // Then, for now, this should trigger two NodePropertyUpdates using (Transaction tx = _db.beginTx()) { KernelTransaction ktx = _ctxSupplier.getKernelTransactionBoundToThisThread(true); TokenRead tokenRead = ktx.TokenRead(); int propertyKey1 = tokenRead.PropertyKey(indexProperty); int label = tokenRead.NodeLabel(_myLabel.name()); LabelSchemaDescriptor descriptor = SchemaDescriptorFactory.forLabel(label, propertyKey1); assertThat(writer.UpdatesCommitted, equalTo(asSet(IndexEntryUpdate.add(node.Id, descriptor, Values.of(value1))))); tx.Success(); } // We get two updates because we both add a label and a property to be indexed // in the same transaction, in the future, we should optimize this down to // one NodePropertyUpdate. }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void showSchema(DbStructureVisitor visitor, org.neo4j.kernel.api.KernelTransaction ktx) throws org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException private void ShowSchema(DbStructureVisitor visitor, KernelTransaction ktx) { TokenNameLookup nameLookup = new SilentTokenNameLookup(ktx.TokenRead()); ShowIndices(visitor, ktx, nameLookup); ShowUniqueConstraints(visitor, ktx, nameLookup); }
private void ShowRelCounts(KernelTransaction ktx, DbStructureVisitor visitor) { // all wildcards NoSide(ktx, visitor, _wildcardRelType, ANY_RELATIONSHIP_TYPE); TokenRead tokenRead = ktx.TokenRead(); // one label only foreach (Label label in _db.AllLabels) { int labelId = tokenRead.NodeLabel(label.Name()); LeftSide(ktx, visitor, label, labelId, _wildcardRelType, ANY_RELATIONSHIP_TYPE); RightSide(ktx, visitor, label, labelId, _wildcardRelType, ANY_RELATIONSHIP_TYPE); } // fixed rel type foreach (RelationshipType relType in _db.AllRelationshipTypes) { int relTypeId = tokenRead.RelationshipType(relType.Name()); NoSide(ktx, visitor, relType, relTypeId); foreach (Label label in _db.AllLabels) { int labelId = tokenRead.NodeLabel(label.Name()); // wildcard on right LeftSide(ktx, visitor, label, labelId, relType, relTypeId); // wildcard on left RightSide(ktx, visitor, label, labelId, relType, relTypeId); } } }
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected: //ORIGINAL LINE: public org.neo4j.graphdb.schema.Schema_IndexState getIndexState(final org.neo4j.graphdb.schema.IndexDefinition index) public override Org.Neo4j.Graphdb.schema.Schema_IndexState GetIndexState(IndexDefinition index) { KernelTransaction transaction = SafeAcquireTransaction(_transactionSupplier); try { using (Statement ignore = transaction.AcquireStatement()) { SchemaRead schemaRead = transaction.SchemaRead(); IndexReference reference = GetIndexReference(schemaRead, transaction.TokenRead(), (IndexDefinitionImpl)index); InternalIndexState indexState = schemaRead.IndexGetState(reference); switch (indexState) { case InternalIndexState.POPULATING: return(POPULATING); case InternalIndexState.ONLINE: return(ONLINE); case InternalIndexState.FAILED: return(FAILED); default: throw new System.ArgumentException(string.Format("Illegal index state {0}", indexState)); } } } catch (Exception e) when(e is SchemaRuleNotFoundException || e is IndexNotFoundKernelException) { throw NewIndexNotFoundException(index, e); } }
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected: //ORIGINAL LINE: public org.neo4j.graphdb.ResourceIterable<org.neo4j.graphdb.Relationship> getRelationships(final org.neo4j.graphdb.Direction direction, org.neo4j.graphdb.RelationshipType... types) public virtual ResourceIterable <Relationship> getRelationships(Direction direction, params RelationshipType[] types) { KernelTransaction transaction = SafeAcquireTransaction(); int[] typeIds = RelTypeIds(types, transaction.TokenRead()); return(InnerGetRelationships(transaction, direction, typeIds)); }
public override bool HasProperty(string key) { if (null == key) { return(false); } KernelTransaction transaction = SafeAcquireTransaction(); int propertyKey = transaction.TokenRead().propertyKey(key); if (propertyKey == [email protected]_Fields.NO_TOKEN) { return(false); } NodeCursor nodes = transaction.AmbientNodeCursor(); PropertyCursor properties = transaction.AmbientPropertyCursor(); SingleNode(transaction, nodes); nodes.Properties(properties); while (properties.Next()) { if (propertyKey == properties.PropertyKey()) { return(true); } } return(false); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldRotateCountsStoreWhenRotatingLog() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldRotateCountsStoreWhenRotatingLog() { // GIVEN GraphDatabaseAPI db = ( GraphDatabaseAPI )_dbBuilder.newGraphDatabase(); // WHEN doing a transaction (actually two, the label-mini-tx also counts) using (Transaction tx = Db.beginTx()) { Db.createNode(_b); tx.Success(); } // and rotating the log (which implies flushing) CheckPoint(db); // and creating another node after it using (Transaction tx = Db.beginTx()) { Db.createNode(_c); tx.Success(); } // THEN assertTrue(_fs.fileExists(AlphaStoreFile())); assertTrue(_fs.fileExists(BetaStoreFile())); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.io.pagecache.PageCache pageCache = db.getDependencyResolver().resolveDependency(org.neo4j.io.pagecache.PageCache.class); PageCache pageCache = Db.DependencyResolver.resolveDependency(typeof(PageCache)); using (Lifespan life = new Lifespan()) { CountsTracker store = life.Add(CreateCountsTracker(pageCache)); // NOTE since the rotation happens before the second transaction is committed we do not see those changes // in the stats // a transaction for creating the label and a transaction for the node assertEquals(BASE_TX_ID + 1 + 1, store.TxId()); assertEquals(INITIAL_MINOR_VERSION, store.MinorVersion()); // one for all nodes and one for the created "B" label assertEquals(1 + 1, store.TotalEntriesStored()); assertEquals(1 + 1, AllRecords(store).Count); } // on the other hand the tracker should read the correct value by merging data on disk and data in memory //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final CountsTracker tracker = db.getDependencyResolver().resolveDependency(org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageEngine.class).testAccessNeoStores().getCounts(); CountsTracker tracker = Db.DependencyResolver.resolveDependency(typeof(RecordStorageEngine)).testAccessNeoStores().Counts; assertEquals(1 + 1, tracker.NodeCount(-1, newDoubleLongRegister()).readSecond()); int labelId; using (Transaction tx = Db.beginTx()) { KernelTransaction transaction = Db.DependencyResolver.resolveDependency(typeof(ThreadToStatementContextBridge)).getKernelTransactionBoundToThisThread(true); labelId = transaction.TokenRead().nodeLabel(_c.name()); } assertEquals(1, tracker.NodeCount(labelId, newDoubleLongRegister()).readSecond()); Db.shutdown(); }
private void ShowRelTypes(KernelTransaction ktx, DbStructureVisitor visitor) { foreach (RelationshipType relType in _db.AllRelationshipTypes) { int relTypeId = ktx.TokenRead().relationshipType(relType.Name()); visitor.VisitRelationshipType(relTypeId, relType.Name()); } }
private void ShowLabels(KernelTransaction ktx, DbStructureVisitor visitor) { foreach (Label label in _db.AllLabels) { int labelId = ktx.TokenRead().nodeLabel(label.Name()); visitor.VisitLabel(labelId, label.Name()); } }
private void ShowPropertyKeys(KernelTransaction ktx, DbStructureVisitor visitor) { foreach (string propertyKeyName in _db.AllPropertyKeys) { int propertyKeyId = ktx.TokenRead().propertyKey(propertyKeyName); visitor.VisitPropertyKey(propertyKeyId, propertyKeyName); } }
private int GetLabelId(string name) { using (Transaction tx = _database.beginTx()) { KernelTransaction transaction = (( GraphDatabaseAPI )_database).DependencyResolver.resolveDependency(typeof(ThreadToStatementContextBridge)).getKernelTransactionBoundToThisThread(true); return(transaction.TokenRead().nodeLabel(name)); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static int propertyKeyCount(org.neo4j.kernel.internal.GraphDatabaseAPI db) throws org.neo4j.internal.kernel.api.exceptions.TransactionFailureException private static int PropertyKeyCount(GraphDatabaseAPI db) { InwardKernel kernelAPI = Db.DependencyResolver.resolveDependency(typeof(InwardKernel)); using (KernelTransaction tx = kernelAPI.BeginTransaction(KernelTransaction.Type.@implicit, AnonymousContext.read())) { return(tx.TokenRead().propertyKeyCount()); } }
public override string GetUserMessage(KernelException e) { KernelTransaction transaction = SafeAcquireTransaction(TransactionSupplier); using (Statement ignore = transaction.AcquireStatement()) { return(e.GetUserMessage(new SilentTokenNameLookup(transaction.TokenRead()))); } }
private int GetPropertyIdByName(string name) { ThreadToStatementContextBridge transactionStatementContextBridge = TransactionStatementContextBridge; KernelTransaction ktx = transactionStatementContextBridge.GetKernelTransactionBoundToThisThread(true); using (Statement ignore = ktx.AcquireStatement()) { return(ktx.TokenRead().propertyKey(name)); } }
private void ShowNodeCounts(KernelTransaction ktx, DbStructureVisitor visitor) { Read read = ktx.DataRead(); visitor.VisitAllNodesCount(read.CountsForNode(ANY_LABEL)); foreach (Label label in _db.AllLabels) { int labelId = ktx.TokenRead().nodeLabel(label.Name()); visitor.VisitNodeCount(labelId, label.Name(), read.CountsForNode(labelId)); } }
private void AssertCorrectProvider(GraphDatabaseAPI db, Label label, string property) { KernelTransaction kernelTransaction = Db.DependencyResolver.resolveDependency(typeof(ThreadToStatementContextBridge)).getKernelTransactionBoundToThisThread(false); TokenRead tokenRead = kernelTransaction.TokenRead(); int labelId = tokenRead.NodeLabel(label.Name()); int propId = tokenRead.PropertyKey(property); SchemaRead schemaRead = kernelTransaction.SchemaRead(); IndexReference index = schemaRead.Index(labelId, propId); assertEquals("correct provider key", "lucene+native", index.ProviderKey()); assertEquals("correct provider version", "1.0", index.ProviderVersion()); }
private Node CreateTestNode() { Node node; using (Transaction transaction = DbRule.beginTx()) { node = DbRule.createNode(_label); KernelTransaction ktx = DbRule.DependencyResolver.resolveDependency(typeof(ThreadToStatementContextBridge)).getKernelTransactionBoundToThisThread(true); _labelId = ktx.TokenRead().nodeLabel(_label.name()); transaction.Success(); } return(node); }
public override IDictionary <string, object> GetProperties(params string[] keys) { Objects.requireNonNull(keys, "Properties keys should be not null array."); if (keys.Length == 0) { return(Collections.emptyMap()); } KernelTransaction transaction = SafeAcquireTransaction(); int itemsToReturn = keys.Length; IDictionary <string, object> properties = new Dictionary <string, object>(itemsToReturn); TokenRead token = transaction.TokenRead(); //Find ids, note we are betting on that the number of keys //is small enough not to use a set here. int[] propertyIds = new int[itemsToReturn]; for (int i = 0; i < itemsToReturn; i++) { string key = keys[i]; if (string.ReferenceEquals(key, null)) { throw new System.NullReferenceException(string.Format("Key {0:D} was null", i)); } propertyIds[i] = token.PropertyKey(key); } NodeCursor nodes = transaction.AmbientNodeCursor(); PropertyCursor propertyCursor = transaction.AmbientPropertyCursor(); SingleNode(transaction, nodes); nodes.Properties(propertyCursor); int propertiesToFind = itemsToReturn; while (propertiesToFind > 0 && propertyCursor.Next()) { //Do a linear check if this is a property we are interested in. int currentKey = propertyCursor.PropertyKey(); for (int i = 0; i < itemsToReturn; i++) { if (propertyIds[i] == currentKey) { properties[keys[i]] = propertyCursor.PropertyValue().asObjectCopy(); propertiesToFind--; break; } } } return(properties); }
public override IEnumerable <IndexDefinition> GetIndexes() { KernelTransaction transaction = _transactionSupplier.get(); SchemaRead schemaRead = transaction.SchemaRead(); using (Statement ignore = transaction.AcquireStatement()) { IList <IndexDefinition> definitions = new List <IndexDefinition>(); IEnumerator <IndexReference> indexes = schemaRead.IndexesGetAll(); AddDefinitions(definitions, transaction.TokenRead(), IndexReference.sortByType(indexes)); return(definitions); } }
internal TokenIterator(KernelTransaction transaction, TokenAccess <T> access) { this.Access = access; this.Statement = transaction.AcquireStatement(); try { this.Tokens = access.Tokens(transaction.TokenRead()); } catch (Exception e) { Close(); throw e; } }
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: private java.util.Set<org.neo4j.kernel.api.index.IndexEntryUpdate<?>> createSomeBananas(org.neo4j.graphdb.Label label) private ISet <IndexEntryUpdate <object> > CreateSomeBananas(Label label) { //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.Set<org.neo4j.kernel.api.index.IndexEntryUpdate<?>> updates = new java.util.HashSet<>(); ISet <IndexEntryUpdate <object> > updates = new HashSet <IndexEntryUpdate <object> >(); using (Transaction tx = _db.beginTx()) { ThreadToStatementContextBridge ctxSupplier = _db.DependencyResolver.resolveDependency(typeof(ThreadToStatementContextBridge)); KernelTransaction ktx = ctxSupplier.GetKernelTransactionBoundToThisThread(true); int labelId = ktx.TokenRead().nodeLabel(label.Name()); int propertyKeyId = ktx.TokenRead().propertyKey(_key); LabelSchemaDescriptor schemaDescriptor = SchemaDescriptorFactory.forLabel(labelId, propertyKeyId); foreach (int number in new int[] { 4, 10 }) { Node node = _db.createNode(label); node.SetProperty(_key, number); updates.Add(IndexEntryUpdate.add(node.Id, schemaDescriptor, Values.of(number))); } tx.Success(); return(updates); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static org.neo4j.kernel.api.KernelTransaction mockKernelTransaction() throws org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException private static KernelTransaction MockKernelTransaction() { SchemaRead schemaRead = mock(typeof(SchemaRead)); when(schemaRead.IndexGetState(any(typeof(IndexReference)))).thenReturn(InternalIndexState.FAILED); when(schemaRead.IndexGetFailure(any(typeof(IndexReference)))).thenReturn(Exceptions.stringify(_cause)); KernelTransaction kt = mock(typeof(KernelTransaction)); when(kt.TokenRead()).thenReturn(mock(typeof(TokenRead))); when(kt.SchemaRead()).thenReturn(schemaRead); when(kt.Terminated).thenReturn(false); when(kt.AcquireStatement()).thenReturn(mock(typeof(Statement))); return(kt); }