//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. }
private IndexDescriptor IndexDescriptor(Label label, string propertyKey) { int labelId = labelId(label); int propKeyId = PropertyKeyId(propertyKey); return(IndexDescriptorFactory.forSchema(SchemaDescriptorFactory.forLabel(labelId, propKeyId))); }
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 SchemaDescriptor SchemaFor(EntityType type, string[] entityTokens, Properties indexConfiguration, params string[] properties) { if (entityTokens.Length == 0) { throw new BadSchemaException("At least one " + (type == EntityType.NODE ? "label" : "relationship type") + " must be specified when creating a fulltext index."); } if (properties.Length == 0) { throw new BadSchemaException("At least one property name must be specified when creating a fulltext index."); } if (Arrays.asList(properties).contains(LuceneFulltextDocumentStructure.FIELD_ENTITY_ID)) { throw new BadSchemaException("Unable to index the property, the name is reserved for internal use " + LuceneFulltextDocumentStructure.FIELD_ENTITY_ID); } int[] entityTokenIds = new int[entityTokens.Length]; if (type == EntityType.NODE) { _tokenHolders.labelTokens().getOrCreateIds(entityTokens, entityTokenIds); } else { _tokenHolders.relationshipTypeTokens().getOrCreateIds(entityTokens, entityTokenIds); } int[] propertyIds = java.util.properties.Select(_tokenHolders.propertyKeyTokens().getOrCreateId).ToArray(); SchemaDescriptor schema = SchemaDescriptorFactory.multiToken(entityTokenIds, type, propertyIds); indexConfiguration.putIfAbsent(FulltextIndexSettings.INDEX_CONFIG_ANALYZER, _defaultAnalyzerName); indexConfiguration.putIfAbsent(FulltextIndexSettings.INDEX_CONFIG_EVENTUALLY_CONSISTENT, _defaultEventuallyConsistentSetting); return(new FulltextSchemaDescriptor(schema, indexConfiguration)); }
//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); }
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 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 processAllRelationshipProperties() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ProcessAllRelationshipProperties() { CreateAlistairAndStefanNodes(); CopyUpdateVisitor propertyUpdateVisitor = new CopyUpdateVisitor(); RelationshipStoreScan relationshipStoreScan = new RelationshipStoreScan(new RecordStorageReader(_neoStores), _locks, propertyUpdateVisitor, new int[] { _relTypeId }, id => true); using (StorageRelationshipScanCursor relationshipScanCursor = _reader.allocateRelationshipScanCursor()) { relationshipScanCursor.Single(1); relationshipScanCursor.Next(); relationshipStoreScan.process(relationshipScanCursor); } EntityUpdates propertyUpdates = propertyUpdateVisitor.PropertyUpdates; assertNotNull("Visitor should contain container with updates.", propertyUpdates); RelationTypeSchemaDescriptor index1 = SchemaDescriptorFactory.forRelType(0, 2); RelationTypeSchemaDescriptor index2 = SchemaDescriptorFactory.forRelType(0, 3); RelationTypeSchemaDescriptor index3 = SchemaDescriptorFactory.forRelType(0, 2, 3); RelationTypeSchemaDescriptor index4 = SchemaDescriptorFactory.forRelType(1, 3); IList <RelationTypeSchemaDescriptor> 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); } } }
//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)); }
private SchemaDescriptor RandomSchemaDescriptor(int highEntityKeyId, int highPropertyKeyId, int maxNumberOfEntityKeys, int maxNumberOfPropertyKeys) { int numberOfEntityKeys = _random.Next(1, maxNumberOfEntityKeys); int[] entityKeys = RandomUniqueUnsortedIntArray(highEntityKeyId, numberOfEntityKeys); int numberOfPropertyKeys = _random.Next(1, maxNumberOfPropertyKeys); int[] propertyKeys = RandomUniqueUnsortedIntArray(highPropertyKeyId, numberOfPropertyKeys); return(entityKeys.Length > 1 ? SchemaDescriptorFactory.multiToken(entityKeys, EntityType.NODE, propertyKeys) : SchemaDescriptorFactory.forLabel(entityKeys[0], propertyKeys)); }
//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 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 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 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); }
//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 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: @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))); }
// === 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 shouldListMultiTokenIndexesInTheCoreAPI() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldListMultiTokenIndexesInTheCoreAPI() { Transaction transaction = NewTransaction(AUTH_DISABLED); MultiTokenSchemaDescriptor descriptor = SchemaDescriptorFactory.multiToken(new int[] { _labelId, _labelId2 }, EntityType.NODE, _propertyKeyId); 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(); try { index.Label; fail("index.getLabel() should have thrown. "); } catch (System.InvalidOperationException) { } try { index.RelationshipType; fail("index.getRelationshipType() should have thrown. "); } catch (System.InvalidOperationException) { } try { index.RelationshipTypes; fail("index.getRelationshipTypes() should have thrown. "); } catch (System.InvalidOperationException) { } assertThat(index.Labels, containsInAnyOrder(label(LABEL), label(LABEL2))); assertFalse("should not be a constraint index", index.ConstraintIndex); assertTrue("should be a multi-token index", index.MultiTokenIndex); assertFalse("should not 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), Iterables.asSet(index.PropertyKeys)); } }
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 shouldListCompositeMultiTokenRelationshipIndexesInTheCoreAPI() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldListCompositeMultiTokenRelationshipIndexesInTheCoreAPI() { Transaction transaction = NewTransaction(AUTH_DISABLED); SchemaDescriptor descriptor = SchemaDescriptorFactory.multiToken(new int[] { _relType, _relType2 }, EntityType.RELATIONSHIP, _propertyKeyId, _propertyKeyId2); transaction.SchemaWrite().indexCreate(descriptor); Commit(); 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(); try { index.Label; fail("index.getLabel() should have thrown. "); } catch (System.InvalidOperationException) { } try { index.Labels; fail("index.getLabels() should have thrown. "); } catch (System.InvalidOperationException) { } try { index.RelationshipType; fail("index.getRelationshipType() should have thrown. "); } catch (System.InvalidOperationException) { } assertThat(index.RelationshipTypes, containsInAnyOrder(withName(REL_TYPE), withName(REL_TYPE2))); assertFalse("should not be a constraint index", index.ConstraintIndex); assertTrue("should be a multi-token index", index.MultiTokenIndex); assertTrue("should be a composite index", index.CompositeIndex); assertFalse("should not be a node index", index.NodeIndex); assertTrue("should be a relationship index", index.RelationshipIndex); assertEquals(asSet(PROPERTY_KEY, PROPERTY_KEY2), Iterables.asSet(index.PropertyKeys)); } }
//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))); }