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); }
private IndexDescriptor IndexDescriptor(Label label, string propertyKey) { int labelId = labelId(label); int propKeyId = PropertyKeyId(propertyKey); return(IndexDescriptorFactory.forSchema(SchemaDescriptorFactory.forLabel(labelId, propKeyId))); }
//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 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)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldListConstraintIndexesInTheCoreAPI() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldListConstraintIndexesInTheCoreAPI() { // given Transaction transaction = NewTransaction(AUTH_DISABLED); transaction.SchemaWrite().uniquePropertyConstraintCreate(SchemaDescriptorFactory.forLabel(transaction.TokenWrite().labelGetOrCreateForName("Label1"), transaction.TokenWrite().propertyKeyGetOrCreateForName("property1"))); Commit(); // when using (Org.Neo4j.Graphdb.Transaction ignore = Db.beginTx()) { ISet <IndexDefinition> indexes = Iterables.asSet(Db.schema().Indexes); // then assertEquals(1, indexes.Count); IndexDefinition index = indexes.GetEnumerator().next(); assertEquals("Label1", single(index.Labels).name()); assertEquals(asSet("property1"), Iterables.asSet(index.PropertyKeys)); assertTrue("index should be a constraint index", index.ConstraintIndex); // when try { index.Drop(); fail("expected exception"); } // then catch (System.InvalidOperationException e) { assertEquals("Constraint indexes cannot be dropped directly, " + "instead drop the owning uniqueness constraint.", e.Message); } } }
public override void Run() { Org.Neo4j.Kernel.api.schema.LabelSchemaDescriptor descriptor = SchemaDescriptorFactory.forLabel(LabelIdToDropIndexFor, outerInstance.propertyId); StoreIndexDescriptor rule = FindRuleForLabel(descriptor); outerInstance.indexService.DropIndex(rule); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCreateUniqueIndexDescriptors() public virtual void ShouldCreateUniqueIndexDescriptors() { IndexDescriptor desc; desc = TestIndexDescriptorFactory.UniqueForLabel(LABEL_ID, 1); assertThat(desc.Type(), equalTo(IndexDescriptor.Type.UNIQUE)); assertThat(desc.Schema(), equalTo(SchemaDescriptorFactory.forLabel(LABEL_ID, 1))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCreateNodeKeyConstraintDescriptors() public virtual void ShouldCreateNodeKeyConstraintDescriptors() { ConstraintDescriptor desc; desc = ConstraintDescriptorFactory.NodeKeyForLabel(LABEL_ID, 1); assertThat(desc.Type(), equalTo(ConstraintDescriptor.Type.UNIQUE_EXISTS)); assertThat(desc.Schema(), equalTo(SchemaDescriptorFactory.forLabel(LABEL_ID, 1))); }
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 double indexUniqueValueSelectivity(int labelId, params int[] propertyKeyIds) { SchemaDescriptor descriptor = SchemaDescriptorFactory.forLabel(labelId, propertyKeyIds); IndexStatistics result1 = _outerInstance.regularIndices.getIndex(descriptor); IndexStatistics result2 = result1 == null?_outerInstance.uniqueIndices.getIndex(descriptor) : result1; return(result2 == null ? Double.NaN : result2.UniqueValuesPercentage); }
public double indexPropertyExistsSelectivity(int labelId, params int[] propertyKeyIds) { SchemaDescriptor descriptor = SchemaDescriptorFactory.forLabel(labelId, propertyKeyIds); IndexStatistics result1 = _outerInstance.regularIndices.getIndex(descriptor); IndexStatistics result2 = result1 == null?_outerInstance.uniqueIndices.getIndex(descriptor) : result1; double indexSize = result2 == null ? Double.NaN : result2.Size; return(indexSize / nodesWithLabelCardinality(labelId)); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void waitIndexOnline(org.neo4j.kernel.impl.api.index.IndexingService indexService, int propertyId, int labelId) throws org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException, org.neo4j.kernel.api.exceptions.index.IndexPopulationFailedKernelException, InterruptedException, org.neo4j.kernel.api.exceptions.index.IndexActivationFailedKernelException private void WaitIndexOnline(IndexingService indexService, int propertyId, int labelId) { IndexProxy indexProxy = indexService.getIndexProxy(SchemaDescriptorFactory.forLabel(labelId, propertyId)); indexProxy.AwaitStoreScanCompleted(0, TimeUnit.MILLISECONDS); while (indexProxy.State != InternalIndexState.ONLINE) { Thread.Sleep(10); } indexProxy.Activate(); }
//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: @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")); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private org.neo4j.storageengine.api.schema.IndexDescriptor indexDescriptor(org.neo4j.graphdb.Label label, String propertyKey, boolean constraint) throws org.neo4j.internal.kernel.api.exceptions.TransactionFailureException, org.neo4j.internal.kernel.api.exceptions.schema.IllegalTokenNameException, org.neo4j.internal.kernel.api.exceptions.schema.TooManyLabelsException private IndexDescriptor IndexDescriptor(Label label, string propertyKey, bool constraint) { using (Transaction tx = _kernel.beginTransaction(@implicit, AUTH_DISABLED)) { int labelId = tx.TokenWrite().labelGetOrCreateForName(label.Name()); int propertyKeyId = tx.TokenWrite().propertyKeyGetOrCreateForName(propertyKey); SchemaDescriptor schema = SchemaDescriptorFactory.forLabel(labelId, propertyKeyId); IndexDescriptor descriptor = constraint ? IndexDescriptorFactory.uniqueForSchema(schema, PROVIDER_DESCRIPTOR) : IndexDescriptorFactory.forSchema(schema, PROVIDER_DESCRIPTOR); tx.Success(); return(descriptor); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCreateIndexDescriptorsFromSchema() public virtual void ShouldCreateIndexDescriptorsFromSchema() { IndexDescriptor desc; desc = IndexDescriptorFactory.forSchema(SchemaDescriptorFactory.forLabel(LABEL_ID, 1)); assertThat(desc.Type(), equalTo(IndexDescriptor.Type.GENERAL)); assertThat(desc.Schema(), equalTo(SchemaDescriptorFactory.forLabel(LABEL_ID, 1))); desc = IndexDescriptorFactory.uniqueForSchema(SchemaDescriptorFactory.forLabel(LABEL_ID, 1)); assertThat(desc.Type(), equalTo(IndexDescriptor.Type.UNIQUE)); assertThat(desc.Schema(), equalTo(SchemaDescriptorFactory.forLabel(LABEL_ID, 1))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCreateExistsConstraintDescriptors() public virtual void ShouldCreateExistsConstraintDescriptors() { ConstraintDescriptor desc; desc = ConstraintDescriptorFactory.ExistsForLabel(LABEL_ID, 1); assertThat(desc.Type(), equalTo(ConstraintDescriptor.Type.EXISTS)); assertThat(desc.Schema(), equalTo(SchemaDescriptorFactory.forLabel(LABEL_ID, 1))); desc = ConstraintDescriptorFactory.ExistsForRelType(REL_TYPE_ID, 1); assertThat(desc.Type(), equalTo(ConstraintDescriptor.Type.EXISTS)); assertThat(desc.Schema(), equalTo(SchemaDescriptorFactory.forRelType(REL_TYPE_ID, 1))); }
//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(); } }
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 shouldCreateConstraintDescriptorsFromSchema() public virtual void ShouldCreateConstraintDescriptorsFromSchema() { ConstraintDescriptor desc; desc = ConstraintDescriptorFactory.UniqueForSchema(SchemaDescriptorFactory.forLabel(LABEL_ID, 1)); assertThat(desc.Type(), equalTo(ConstraintDescriptor.Type.UNIQUE)); assertThat(desc.Schema(), equalTo(SchemaDescriptorFactory.forLabel(LABEL_ID, 1))); desc = ConstraintDescriptorFactory.NodeKeyForSchema(SchemaDescriptorFactory.forLabel(LABEL_ID, 1)); assertThat(desc.Type(), equalTo(ConstraintDescriptor.Type.UNIQUE_EXISTS)); assertThat(desc.Schema(), equalTo(SchemaDescriptorFactory.forLabel(LABEL_ID, 1))); desc = ConstraintDescriptorFactory.ExistsForSchema(SchemaDescriptorFactory.forRelType(REL_TYPE_ID, 1)); assertThat(desc.Type(), equalTo(ConstraintDescriptor.Type.EXISTS)); assertThat(desc.Schema(), equalTo(SchemaDescriptorFactory.forRelType(REL_TYPE_ID, 1))); }
//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 TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void indexDroppedDuringPopulationDoesNotExist() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void IndexDroppedDuringPopulationDoesNotExist() { int?labelToDropId = _labelsNameIdMap[COLOR_LABEL]; LaunchCustomIndexPopulation(_labelsNameIdMap, _propertyId, new IndexDropAction(this, labelToDropId.Value)); _labelsNameIdMap.Remove(COLOR_LABEL); WaitAndActivateIndexes(_labelsNameIdMap, _propertyId); try { _indexService.getIndexProxy(SchemaDescriptorFactory.forLabel(labelToDropId.Value, _propertyId)); fail("Index does not exist, we should fail to find it."); } catch (IndexNotFoundKernelException) { // expected } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldAbortConstraintCreationWhenDuplicatesExist() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldAbortConstraintCreationWhenDuplicatesExist() { // given Transaction transaction = newTransaction(AnonymousContext.writeToken()); // name is not unique for Foo in the existing data int foo = transaction.TokenWrite().labelGetOrCreateForName("Foo"); int name = transaction.TokenWrite().propertyKeyGetOrCreateForName("name"); long node1 = transaction.DataWrite().nodeCreate(); transaction.DataWrite().nodeAddLabel(node1, foo); transaction.DataWrite().nodeSetProperty(node1, name, Values.of("foo")); long node2 = transaction.DataWrite().nodeCreate(); transaction.DataWrite().nodeAddLabel(node2, foo); transaction.DataWrite().nodeSetProperty(node2, name, Values.of("foo")); commit(); // when LabelSchemaDescriptor descriptor = SchemaDescriptorFactory.forLabel(foo, name); try { SchemaWrite schemaWriteOperations = schemaWriteInNewTransaction(); schemaWriteOperations.UniquePropertyConstraintCreate(descriptor); fail("expected exception"); } // then catch (CreateConstraintFailureException ex) { assertEquals(ConstraintDescriptorFactory.uniqueForSchema(descriptor), ex.Constraint()); Exception cause = ex.InnerException; assertThat(cause, instanceOf(typeof(ConstraintValidationException))); string expectedMessage = string.Format("Both Node({0:D}) and Node({1:D}) have the label `Foo` and property `name` = 'foo'", node1, node2); string actualMessage = UserMessage(( ConstraintValidationException )cause); assertEquals(expectedMessage, actualMessage); } }
//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 shouldListCompositeIndexesInTheCoreAPI() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldListCompositeIndexesInTheCoreAPI() { Transaction transaction = NewTransaction(AUTH_DISABLED); SchemaDescriptor descriptor = SchemaDescriptorFactory.forLabel(_labelId, _propertyKeyId, _propertyKeyId2); transaction.SchemaWrite().indexCreate(descriptor); Commit(); //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: try (@SuppressWarnings("unused") org.neo4j.graphdb.Transaction tx = db.beginTx()) using (Org.Neo4j.Graphdb.Transaction tx = Db.beginTx()) { ISet <IndexDefinition> indexes = Iterables.asSet(Db.schema().Indexes); // then assertEquals(1, indexes.Count); IndexDefinition index = indexes.GetEnumerator().next(); assertEquals(LABEL, single(index.Labels).name()); assertThat(index.Labels, containsInAnyOrder(label(LABEL))); try { index.RelationshipType; fail("index.getRelationshipType() should have thrown. "); } catch (System.InvalidOperationException) { } try { index.RelationshipTypes; fail("index.getRelationshipTypes() should have thrown. "); } catch (System.InvalidOperationException) { } assertFalse("should not be a constraint index", index.ConstraintIndex); assertFalse("should not be a multi-token index", index.MultiTokenIndex); assertTrue("should be a composite index", index.CompositeIndex); assertTrue("should be a node index", index.NodeIndex); assertFalse("should not be a relationship index", index.RelationshipIndex); assertEquals(asSet(PROPERTY_KEY, PROPERTY_KEY2), Iterables.asSet(index.PropertyKeys)); } }