//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void testCreateIndexWithGivenProvider(String label, String... properties) throws org.neo4j.internal.kernel.api.exceptions.KernelException private void TestCreateIndexWithGivenProvider(string label, params string[] properties) { // given Transaction transaction = NewTransaction(AnonymousContext.writeToken()); int labelId = transaction.TokenWrite().labelGetOrCreateForName(label); int[] propertyKeyIds = CreateProperties(transaction, properties); TextValue value = stringValue("some value"); long node = CreateNodeWithPropertiesAndLabel(transaction, labelId, propertyKeyIds, value); Commit(); // when NewTransaction(AnonymousContext.full()); string pattern = IndexPattern(label, properties); string specifiedProvider = NATIVE10.providerName(); RawIterator <object[], ProcedureException> result = CallIndexProcedure(pattern, specifiedProvider); // then assertThat(Arrays.asList(result.Next()), contains(pattern, specifiedProvider, ExpectedSuccessfulCreationStatus)); Commit(); AwaitIndexOnline(); // and then transaction = NewTransaction(AnonymousContext.read()); SchemaRead schemaRead = transaction.SchemaRead(); IndexReference index = schemaRead.Index(labelId, propertyKeyIds); AssertCorrectIndex(labelId, propertyKeyIds, UniquenessConstraint, index); AssertIndexData(transaction, propertyKeyIds, value, node, index); Commit(); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private org.neo4j.internal.kernel.api.IndexReference getOrCreateUniquenessConstraintIndex(org.neo4j.internal.kernel.api.SchemaRead schemaRead, org.neo4j.internal.kernel.api.TokenRead tokenRead, org.neo4j.internal.kernel.api.schema.SchemaDescriptor schema, String provider) throws org.neo4j.internal.kernel.api.exceptions.schema.SchemaKernelException, org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException private IndexReference GetOrCreateUniquenessConstraintIndex(SchemaRead schemaRead, TokenRead tokenRead, SchemaDescriptor schema, string provider) { IndexReference descriptor = schemaRead.Index(schema); if (descriptor != IndexReference.NO_INDEX) { if (descriptor.Unique) { // OK so we found a matching constraint index. We check whether or not it has an owner // because this may have been a left-over constraint index from a previously failed // constraint creation, due to crash or similar, hence the missing owner. if (schemaRead.IndexGetOwningUniquenessConstraintId(descriptor) == null) { return(descriptor); } throw new AlreadyConstrainedException(ConstraintDescriptorFactory.uniqueForSchema(schema), SchemaKernelException.OperationContext.CONSTRAINT_CREATION, new SilentTokenNameLookup(tokenRead)); } // There's already an index for this schema descriptor, which isn't of the type we're after. throw new AlreadyIndexedException(schema, CONSTRAINT_CREATION); } IndexDescriptor indexDescriptor = CreateConstraintIndex(schema, provider); IndexProxy indexProxy = _indexingService.getIndexProxy(indexDescriptor.Schema()); return(indexProxy.Descriptor); }
//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: private static org.neo4j.internal.kernel.api.IndexReference getIndexReference(org.neo4j.internal.kernel.api.SchemaRead schemaRead, org.neo4j.internal.kernel.api.TokenRead tokenRead, IndexDefinitionImpl index) throws org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException private static IndexReference GetIndexReference(SchemaRead schemaRead, TokenRead tokenRead, IndexDefinitionImpl index) { // Use the precise embedded index reference when available. IndexReference reference = index.IndexReference; if (reference != null) { return(reference); } // Otherwise attempt to reverse engineer the schema that will let us look up the real IndexReference. int[] propertyKeyIds = ResolveAndValidatePropertyKeys(tokenRead, index.PropertyKeysArrayShared); SchemaDescriptor schema; if (index.NodeIndex) { //JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter: int[] labelIds = ResolveAndValidateTokens("Label", index.LabelArrayShared, Label::name, tokenRead.nodeLabel); if (index.MultiTokenIndex) { schema = multiToken(labelIds, EntityType.NODE, propertyKeyIds); } else { schema = forLabel(labelIds[0], propertyKeyIds); } } else if (index.RelationshipIndex) { //JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter: int[] relTypes = ResolveAndValidateTokens("Relationship type", index.RelationshipTypesArrayShared, RelationshipType::name, tokenRead.relationshipType); if (index.MultiTokenIndex) { schema = multiToken(relTypes, EntityType.RELATIONSHIP, propertyKeyIds); } else { schema = forRelType(relTypes[0], propertyKeyIds); } } else { throw new System.ArgumentException("The given index is neither a node index, nor a relationship index: " + index + "."); } reference = schemaRead.Index(schema); if (reference == IndexReference.NO_INDEX) { throw new SchemaRuleNotFoundException(Org.Neo4j.Storageengine.Api.schema.SchemaRule_Kind.IndexRule, schema); } return(reference); }
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 SchemaRead SchemaRead() { SchemaRead schemaRead = mock(typeof(SchemaRead)); when(schemaRead.Index(_descriptor)).thenReturn(IndexReference.NO_INDEX); try { when(schemaRead.IndexGetCommittedId(_indexReference)).thenReturn(INDEX_ID); } catch (SchemaKernelException e) { throw new AssertionError(e); } return(schemaRead); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void addIndexRuleInATransaction() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void AddIndexRuleInATransaction() { // GIVEN SchemaWrite schemaWriteOperations = SchemaWriteInNewTransaction(); // WHEN IndexReference expectedRule = schemaWriteOperations.IndexCreate(_descriptor); Commit(); // THEN SchemaRead schemaRead = NewTransaction().schemaRead(); assertEquals(asSet(expectedRule), asSet(schemaRead.IndexesGetForLabel(_labelId))); assertEquals(expectedRule, schemaRead.Index(_descriptor.LabelId, _descriptor.PropertyIds)); Commit(); }
private bool IndexStillExists(SchemaRead schemaRead, SchemaDescriptor descriptor, IndexReference index) { IndexReference existingIndex = schemaRead.Index(descriptor); return(existingIndex != IndexReference.NO_INDEX && existingIndex.Equals(index)); }