internal NodeDeletingWriter(IndexPopulationJobTest outerInstance, long nodeToDelete, int propertyKeyId, object valueToDelete, int label) { this._outerInstance = outerInstance; this.NodeToDelete = nodeToDelete; this.ValueToDelete = Values.of(valueToDelete); this.Index = SchemaDescriptorFactory.forLabel(label, propertyKeyId); }
public override IndexDefinition CreateIndexDefinition(Label label, Optional <string> indexName, params string[] propertyKeys) { KernelTransaction transaction = SafeAcquireTransaction(TransactionSupplier); using (Statement ignore = transaction.AcquireStatement()) { try { TokenWrite tokenWrite = transaction.TokenWrite(); int labelId = tokenWrite.LabelGetOrCreateForName(label.Name()); int[] propertyKeyIds = getOrCreatePropertyKeyIds(tokenWrite, propertyKeys); LabelSchemaDescriptor descriptor = forLabel(labelId, propertyKeyIds); IndexReference indexReference = transaction.SchemaWrite().indexCreate(descriptor, indexName); return(new IndexDefinitionImpl(this, indexReference, new Label[] { label }, propertyKeys, false)); } catch (IllegalTokenNameException e) { throw new System.ArgumentException(e); } catch (Exception e) when(e is InvalidTransactionTypeKernelException || e is SchemaKernelException) { throw new ConstraintViolationException(e.GetUserMessage(new SilentTokenNameLookup(transaction.TokenRead())), e); } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldPopulateIndexWithASmallDataset() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldPopulateIndexWithASmallDataset() { // GIVEN string value = "Mattias"; long node1 = CreateNode(map(_name, value), _first); CreateNode(map(_name, value), _second); CreateNode(map(_age, 31), _first); long node4 = CreateNode(map(_age, 35, _name, value), _first); IndexPopulator populator = spy(IndexPopulator(false)); LabelSchemaDescriptor descriptor = SchemaDescriptorFactory.forLabel(0, 0); IndexPopulationJob job = NewIndexPopulationJob(populator, new FlippableIndexProxy(), EntityType.NODE, IndexDescriptorFactory.forSchema(descriptor)); // WHEN job.Run(); // THEN //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: org.neo4j.kernel.api.index.IndexEntryUpdate<?> update1 = add(node1, descriptor, org.neo4j.values.storable.Values.of(value)); IndexEntryUpdate <object> update1 = add(node1, descriptor, Values.of(value)); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: org.neo4j.kernel.api.index.IndexEntryUpdate<?> update2 = add(node4, descriptor, org.neo4j.values.storable.Values.of(value)); IndexEntryUpdate <object> update2 = add(node4, descriptor, Values.of(value)); verify(populator).create(); verify(populator).includeSample(update1); verify(populator).includeSample(update2); verify(populator, times(2)).add(anyCollection()); verify(populator).sampleResult(); verify(populator).close(true); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void processAllNodeProperties() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ProcessAllNodeProperties() { CopyUpdateVisitor propertyUpdateVisitor = new CopyUpdateVisitor(); StoreViewNodeStoreScan storeViewNodeStoreScan = new StoreViewNodeStoreScan(new RecordStorageReader(_neoStores), _locks, null, propertyUpdateVisitor, new int[] { _labelId }, id => true); using (StorageNodeCursor nodeCursor = _reader.allocateNodeCursor()) { nodeCursor.Single(1); nodeCursor.Next(); storeViewNodeStoreScan.process(nodeCursor); } EntityUpdates propertyUpdates = propertyUpdateVisitor.PropertyUpdates; assertNotNull("Visitor should contain container with updates.", propertyUpdates); LabelSchemaDescriptor index1 = SchemaDescriptorFactory.forLabel(0, 0); LabelSchemaDescriptor index2 = SchemaDescriptorFactory.forLabel(0, 1); LabelSchemaDescriptor index3 = SchemaDescriptorFactory.forLabel(0, 0, 1); LabelSchemaDescriptor index4 = SchemaDescriptorFactory.forLabel(1, 1); IList <LabelSchemaDescriptor> indexes = Arrays.asList(index1, index2, index3, index4); //JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter: assertThat(Iterables.map(IndexEntryUpdate::indexKey, propertyUpdates.ForIndexKeys(indexes)), containsInAnyOrder(index1, index2, index3)); }
public void processSpecific(LabelSchemaDescriptor schema) { foreach (int propertyId in Schema.PropertyIds) { RecordConstraint(Schema.LabelId, propertyId, outerInstance.nodes); } }
//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. }
internal NodeChangingWriter(IndexPopulationJobTest outerInstance, long nodeToChange, int propertyKeyId, object previousValue, object newValue, int label) { this._outerInstance = outerInstance; this.NodeToChange = nodeToChange; this.PreviousValue = Values.of(previousValue); this.NewValue = Values.of(newValue); this.Index = SchemaDescriptorFactory.forLabel(label, propertyKeyId); }
public static string[] GetPropertyKeys(TokenNameLookup tokenNameLookup, LabelSchemaDescriptor descriptor) { int[] propertyKeyIds = descriptor.PropertyIds; string[] propertyKeys = new string[propertyKeyIds.Length]; for (int i = 0; i < propertyKeyIds.Length; i++) { propertyKeys[i] = tokenNameLookup.PropertyKeyGetName(propertyKeyIds[i]); } return(propertyKeys); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldHandleMultiplePropertiesInConstructor2() public virtual void ShouldHandleMultiplePropertiesInConstructor2() { // Given LabelSchemaDescriptor descriptor = SchemaDescriptorFactory.forLabel(0, 42, 43, 44); // When IndexPopulationFailedKernelException index = new IndexPopulationFailedKernelException(descriptor.UserDescription(_tokenNameLookup), "an act of pure evil occurred"); // Then assertThat(index.GetUserMessage(_tokenNameLookup), equalTo("Failed to populate index :label[0](property[42], property[43], property[44]), due to an act of pure evil occurred")); }
internal virtual StoreIndexDescriptor FindRuleForLabel(LabelSchemaDescriptor schemaDescriptor) { foreach (StoreIndexDescriptor rule in outerInstance.rules) { if (rule.Schema().Equals(schemaDescriptor)) { return(rule); } } return(null); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private org.neo4j.internal.kernel.api.IndexReference createUniquenessConstraint(int labelId, int... propertyIds) throws Exception private IndexReference CreateUniquenessConstraint(int labelId, params int[] propertyIds) { Transaction transaction = NewTransaction(LoginContext.AUTH_DISABLED); LabelSchemaDescriptor descriptor = SchemaDescriptorFactory.forLabel(labelId, propertyIds); transaction.SchemaWrite().uniquePropertyConstraintCreate(descriptor); IndexReference result = transaction.SchemaRead().index(descriptor.LabelId, descriptor.PropertyIds); Commit(); return(result); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void setup() public virtual void Setup() { _transaction = mock(typeof(KernelTransaction)); _tokenRead = mock(typeof(TokenRead)); _schemaRead = mock(typeof(SchemaRead)); _procedure = new IndexProcedures(_transaction, null); _descriptor = SchemaDescriptorFactory.forLabel(123, 456); _anyDescriptor = SchemaDescriptorFactory.forLabel(0, 0); _anyIndex = forSchema(_anyDescriptor); when(_transaction.tokenRead()).thenReturn(_tokenRead); when(_transaction.schemaRead()).thenReturn(_schemaRead); }
// === INDEX RULES === private static StoreIndexDescriptor ReadIndexRule(long id, bool constraintIndex, int label, ByteBuffer serialized) { IndexProviderDescriptor providerDescriptor = ReadIndexProviderDescriptor(serialized); int[] propertyKeyIds = ReadIndexPropertyKeys(serialized); LabelSchemaDescriptor schema = SchemaDescriptorFactory.forLabel(label, propertyKeyIds); Optional <string> name = null; IndexDescriptor descriptor = constraintIndex ? IndexDescriptorFactory.uniqueForSchema(schema, name, providerDescriptor) : IndexDescriptorFactory.forSchema(schema, name, providerDescriptor); StoreIndexDescriptor storeIndexDescriptor = constraintIndex ? descriptor.WithIds(id, ReadOwningConstraint(serialized)) : descriptor.WithId(id); return(storeIndexDescriptor); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static void addIndex(org.neo4j.graphdb.GraphDatabaseService database) throws org.neo4j.internal.kernel.api.exceptions.schema.SchemaKernelException private static void AddIndex(GraphDatabaseService database) { using (Transaction transaction = database.BeginTx()) { DependencyResolver resolver = (( GraphDatabaseAPI )database).DependencyResolver; ThreadToStatementContextBridge statementBridge = resolver.ProvideDependency(typeof(ThreadToStatementContextBridge)).get(); KernelTransaction kernelTransaction = statementBridge.GetKernelTransactionBoundToThisThread(true); LabelSchemaDescriptor descriptor = SchemaDescriptorFactory.forLabel(0, 0); Config config = resolver.ResolveDependency(typeof(Config)); kernelTransaction.IndexUniqueCreate(descriptor, config.Get(GraphDatabaseSettings.default_schema_provider)); transaction.Success(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void listAllIndexesWithFailedIndex() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ListAllIndexesWithFailedIndex() { // Given Transaction transaction = NewTransaction(AUTH_DISABLED); int failedLabel = transaction.TokenWrite().labelGetOrCreateForName("Fail"); int propertyKeyId1 = transaction.TokenWrite().propertyKeyGetOrCreateForName("foo"); _failNextIndexPopulation.set(true); LabelSchemaDescriptor descriptor = forLabel(failedLabel, propertyKeyId1); transaction.SchemaWrite().indexCreate(descriptor); Commit(); //let indexes come online try { using (Org.Neo4j.Graphdb.Transaction ignored = Db.beginTx()) { Db.schema().awaitIndexesOnline(2, MINUTES); fail("Expected to fail when awaiting for index to come online"); } } catch (System.InvalidOperationException) { // expected } // When RawIterator <object[], ProcedureException> stream = Procs().procedureCallRead(Procs().procedureGet(procedureName("db", "indexes")).id(), new object[0], ProcedureCallContext.EMPTY); assertTrue(stream.HasNext()); object[] result = stream.Next(); assertFalse(stream.HasNext()); // Then assertEquals("INDEX ON :Fail(foo)", result[0]); assertEquals("Unnamed index", result[1]); assertEquals(Collections.singletonList("Fail"), result[2]); assertEquals(Collections.singletonList("foo"), result[3]); assertEquals("FAILED", result[4]); assertEquals("node_label_property", result[5]); assertEquals(0.0, result[6]); IDictionary <string, string> providerDescriptionMap = MapUtil.stringMap("key", GraphDatabaseSettings.SchemaIndex.NATIVE_BTREE10.providerKey(), "version", GraphDatabaseSettings.SchemaIndex.NATIVE_BTREE10.providerVersion()); assertEquals(providerDescriptionMap, result[7]); assertEquals(IndexingService.getIndexId(descriptor), result[8]); assertThat(( string )result[9], containsString("java.lang.RuntimeException: Fail on update during population")); Commit(); }
public override void Run() { foreach (EntityUpdates update in Updates) { using (Transaction transaction = outerInstance.EmbeddedDatabase.beginTx()) { Node node = outerInstance.EmbeddedDatabase.getNodeById(update.EntityId); foreach (int labelId in outerInstance.labelsNameIdMap.Values) { LabelSchemaDescriptor schema = SchemaDescriptorFactory.forLabel(labelId, outerInstance.propertyId); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: for (org.neo4j.kernel.api.index.IndexEntryUpdate<?> indexUpdate : update.forIndexKeys(java.util.Collections.singleton(schema))) foreach (IndexEntryUpdate <object> indexUpdate in update.ForIndexKeys(Collections.singleton(schema))) { switch (indexUpdate.UpdateMode()) { case CHANGED: case ADDED: node.AddLabel(Label.label(outerInstance.labelsIdNameMap[Schema.LabelId])); node.SetProperty(NAME_PROPERTY, indexUpdate.Values()[0].asObject()); break; case REMOVED: node.AddLabel(Label.label(outerInstance.labelsIdNameMap[Schema.LabelId])); node.Delete(); break; default: throw new System.ArgumentException(indexUpdate.UpdateMode().name()); } } } transaction.Success(); } } try { foreach (EntityUpdates update in Updates) { IEnumerable <IndexEntryUpdate <SchemaDescriptor> > entryUpdates = outerInstance.indexService.ConvertToIndexUpdates(update, EntityType.NODE); DirectIndexUpdates directIndexUpdates = new DirectIndexUpdates(entryUpdates); outerInstance.indexService.Apply(directIndexUpdates); } } catch (Exception e) when(e is UncheckedIOException || e is IndexEntryConflictException) { throw new Exception(e); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void createLabelAndProperty() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void CreateLabelAndProperty() { TokenWrite tokenWrites = TokenWriteInNewTransaction(); _labelId = tokenWrites.LabelGetOrCreateForName(LABEL); _labelId2 = tokenWrites.LabelGetOrCreateForName(LABEL2); _relType = tokenWrites.RelationshipTypeGetOrCreateForName(REL_TYPE); _relType2 = tokenWrites.RelationshipTypeGetOrCreateForName(REL_TYPE2); _propertyKeyId = tokenWrites.PropertyKeyGetOrCreateForName(PROPERTY_KEY); _propertyKeyId2 = tokenWrites.PropertyKeyGetOrCreateForName(PROPERTY_KEY2); _descriptor = SchemaDescriptorFactory.forLabel(_labelId, _propertyKeyId); _descriptor2 = SchemaDescriptorFactory.forLabel(_labelId, _propertyKeyId2); Commit(); _executorService = Executors.newCachedThreadPool(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void sampleIncludedUpdates() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void SampleIncludedUpdates() { LabelSchemaDescriptor schemaDescriptor = SchemaDescriptorFactory.forLabel(1, 1); _populator = NewPopulator(); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.List<org.neo4j.kernel.api.index.IndexEntryUpdate<?>> updates = java.util.Arrays.asList(add(1, schemaDescriptor, "foo"), add(2, schemaDescriptor, "bar"), add(3, schemaDescriptor, "baz"), add(4, schemaDescriptor, "qux")); IList <IndexEntryUpdate <object> > updates = Arrays.asList(add(1, schemaDescriptor, "foo"), add(2, schemaDescriptor, "bar"), add(3, schemaDescriptor, "baz"), add(4, schemaDescriptor, "qux")); updates.ForEach(_populator.includeSample); IndexSample sample = _populator.sampleResult(); assertEquals(new IndexSample(4, 4, 4), sample); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldResolveIndexDescriptor() public virtual void ShouldResolveIndexDescriptor() { // Given SchemaCache cache = NewSchemaCache(); cache.AddSchemaRule(NewIndexRule(1L, 1, 2)); cache.AddSchemaRule(NewIndexRule(2L, 1, 3)); cache.AddSchemaRule(NewIndexRule(3L, 2, 2)); // When LabelSchemaDescriptor schema = forLabel(1, 3); IndexDescriptor descriptor = cache.IndexDescriptor(schema); // Then assertThat(descriptor.Schema(), equalTo(schema)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test(timeout = 10_000) public void createIndexesForDifferentLabelsConcurrently() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void CreateIndexesForDifferentLabelsConcurrently() { TokenWrite tokenWrite = TokenWriteInNewTransaction(); int label2 = tokenWrite.LabelGetOrCreateForName("Label2"); LabelSchemaDescriptor anotherLabelDescriptor = SchemaDescriptorFactory.forLabel(label2, _propertyKeyId); SchemaWriteInNewTransaction().indexCreate(anotherLabelDescriptor); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.concurrent.Future<?> indexFuture = executorService.submit(createIndex(db, label(LABEL), PROPERTY_KEY)); Future <object> indexFuture = _executorService.submit(CreateIndex(Db, label(LABEL), PROPERTY_KEY)); indexFuture.get(); Commit(); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private org.neo4j.internal.kernel.api.IndexReference createPersonNameIndex() throws org.neo4j.internal.kernel.api.exceptions.KernelException private IndexReference CreatePersonNameIndex() { using (Transaction tx = _db.beginTx()) { IndexReference index; KernelTransaction ktx = _bridge.getKernelTransactionBoundToThisThread(true); using (Statement ignore = ktx.AcquireStatement()) { int labelId = ktx.TokenWrite().labelGetOrCreateForName(PERSON_LABEL); int propertyKeyId = ktx.TokenWrite().propertyKeyGetOrCreateForName(NAME_PROPERTY); LabelSchemaDescriptor descriptor = forLabel(labelId, propertyKeyId); index = ktx.SchemaWrite().indexCreate(descriptor); } tx.Success(); return(index); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private java.util.stream.Stream<BuiltInProcedures.SchemaIndexInfo> createIndex(String indexSpecification, String providerName, String statusMessage, IndexCreator indexCreator) throws org.neo4j.internal.kernel.api.exceptions.ProcedureException private Stream <BuiltInProcedures.SchemaIndexInfo> CreateIndex(string indexSpecification, string providerName, string statusMessage, IndexCreator indexCreator) { AssertProviderNameNotNull(providerName); IndexSpecifier index = IndexSpecifier.ByPattern(indexSpecification); int labelId = GetOrCreateLabelId(index.Label()); int[] propertyKeyIds = GetOrCreatePropertyIds(index.Properties()); try { SchemaWrite schemaWrite = _ktx.schemaWrite(); LabelSchemaDescriptor labelSchemaDescriptor = SchemaDescriptorFactory.forLabel(labelId, propertyKeyIds); indexCreator(schemaWrite, labelSchemaDescriptor, providerName); return(Stream.of(new BuiltInProcedures.SchemaIndexInfo(indexSpecification, providerName, statusMessage))); } catch (Exception e) when(e is InvalidTransactionTypeKernelException || e is SchemaKernelException) { throw new ProcedureException(e.status(), e, e.Message); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldFindConstraintsBySchema() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldFindConstraintsBySchema() { // GIVEN AddConstraints("FOO", "prop"); using (Transaction tx = beginTransaction()) { int label = tx.TokenWrite().labelGetOrCreateForName("FOO"); int prop = tx.TokenWrite().propertyKeyGetOrCreateForName("prop"); LabelSchemaDescriptor descriptor = LabelSchemaDescriptor(label, prop); //WHEN IList <ConstraintDescriptor> constraints = new IList <ConstraintDescriptor> { tx.SchemaRead().constraintsGetForSchema(descriptor) }; // THEN assertThat(constraints, hasSize(1)); assertThat(constraints[0].Schema().PropertyId, equalTo(prop)); } }
//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 TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void addingALabelToPreExistingNodeShouldGetIndexed() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void AddingALabelToPreExistingNodeShouldGetIndexed() { // GIVEN string indexProperty = "indexProperty"; GatheringIndexWriter writer = NewWriter(); createIndex(_db, _myLabel, indexProperty); // WHEN string otherProperty = "otherProperty"; int value = 12; int otherValue = 17; Node node = CreateNode(map(indexProperty, value, otherProperty, otherValue)); // THEN assertThat(writer.UpdatesCommitted.Count, equalTo(0)); // AND WHEN using (Transaction tx = _db.beginTx()) { node.AddLabel(_myLabel); tx.Success(); } // THEN 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(value))))); tx.Success(); } }
public override void ProcessSpecific(LabelSchemaDescriptor schema) { Engine.comparativeCheck(Records.label(Schema.LabelId), _validLabel); CheckProperties(Schema.PropertyIds); }
internal NodeUpdateProcessListener(MultipleIndexPopulator indexPopulator) { this.IndexPopulator = indexPopulator; this.Index = SchemaDescriptorFactory.forLabel(1, 1); }
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: private org.neo4j.kernel.api.index.IndexEntryUpdate<?> createIndexEntryUpdate(org.neo4j.internal.kernel.api.schema.LabelSchemaDescriptor schemaDescriptor) private IndexEntryUpdate <object> CreateIndexEntryUpdate(LabelSchemaDescriptor schemaDescriptor) { return(add(1, schemaDescriptor, "theValue")); }
public SchemaRule_Kind computeSpecific(LabelSchemaDescriptor schema) { return(NODE_PROPERTY_EXISTENCE_CONSTRAINT); }
public static SchemaRuleCommand CreateIndexRule(IndexProviderDescriptor provider, long id, LabelSchemaDescriptor descriptor) { SchemaRule rule = IndexDescriptorFactory.forSchema(descriptor, provider).withId(id); DynamicRecord record = new DynamicRecord(id); record.InUse = true; record.SetCreated(); record.Data = SchemaRuleSerialization.serialize(rule); return(new SchemaRuleCommand(Collections.emptyList(), singletonList(record), rule)); }