Search in sources :

Example 6 with TokenWrite

use of org.neo4j.internal.kernel.api.TokenWrite in project neo4j by neo4j.

the class IndexCreateIT method shouldFailCreateIndexWithDuplicateRelationshipTypes.

@Test
void shouldFailCreateIndexWithDuplicateRelationshipTypes() throws KernelException {
    // given
    TokenWrite tokenWrite = tokenWriteInNewTransaction();
    int relTypeId = tokenWrite.relationshipTypeGetOrCreateForName("RELATIONSHIP");
    int propId = tokenWrite.propertyKeyGetOrCreateForName("property");
    commit();
    SchemaWrite schemaWrite = schemaWriteInNewTransaction();
    // when
    final FulltextSchemaDescriptor descriptor = SchemaDescriptor.fulltext(EntityType.RELATIONSHIP, new int[] { relTypeId, relTypeId }, new int[] { propId });
    // then
    assertThrows(RepeatedRelationshipTypeInSchemaException.class, () -> schemaWrite.indexCreate(descriptor, null));
}
Also used : SchemaWrite(org.neo4j.internal.kernel.api.SchemaWrite) FulltextSchemaDescriptor(org.neo4j.internal.schema.FulltextSchemaDescriptor) TokenWrite(org.neo4j.internal.kernel.api.TokenWrite) Test(org.junit.jupiter.api.Test) KernelIntegrationTest(org.neo4j.kernel.impl.api.integrationtest.KernelIntegrationTest)

Example 7 with TokenWrite

use of org.neo4j.internal.kernel.api.TokenWrite in project neo4j by neo4j.

the class IndexCreateIT method shouldFailCreateIndexWithDuplicateLabels.

@Test
void shouldFailCreateIndexWithDuplicateLabels() throws KernelException {
    // given
    TokenWrite tokenWrite = tokenWriteInNewTransaction();
    int labelId = tokenWrite.labelGetOrCreateForName("Label");
    int propId = tokenWrite.propertyKeyGetOrCreateForName("property");
    commit();
    SchemaWrite schemaWrite = schemaWriteInNewTransaction();
    // when
    final FulltextSchemaDescriptor descriptor = SchemaDescriptor.fulltext(EntityType.NODE, new int[] { labelId, labelId }, new int[] { propId });
    // then
    assertThrows(RepeatedLabelInSchemaException.class, () -> schemaWrite.indexCreate(descriptor, null));
}
Also used : SchemaWrite(org.neo4j.internal.kernel.api.SchemaWrite) FulltextSchemaDescriptor(org.neo4j.internal.schema.FulltextSchemaDescriptor) TokenWrite(org.neo4j.internal.kernel.api.TokenWrite) Test(org.junit.jupiter.api.Test) KernelIntegrationTest(org.neo4j.kernel.impl.api.integrationtest.KernelIntegrationTest)

Example 8 with TokenWrite

use of org.neo4j.internal.kernel.api.TokenWrite in project neo4j by neo4j.

the class IndexCreateIT method shouldFailWithNonExistentProviderName.

protected void shouldFailWithNonExistentProviderName(IndexCreator creator) throws KernelException {
    // given
    TokenWrite tokenWrite = tokenWriteInNewTransaction();
    int labelId = tokenWrite.labelGetOrCreateForName("Label");
    int propId = tokenWrite.propertyKeyGetOrCreateForName("property");
    commit();
    SchemaWrite schemaWrite = schemaWriteInNewTransaction();
    // when
    assertThrows(IndexProviderNotFoundException.class, () -> creator.create(schemaWrite, forLabel(labelId, propId), "something-completely-different", "index name"));
}
Also used : SchemaWrite(org.neo4j.internal.kernel.api.SchemaWrite) TokenWrite(org.neo4j.internal.kernel.api.TokenWrite)

Example 9 with TokenWrite

use of org.neo4j.internal.kernel.api.TokenWrite in project neo4j by neo4j.

the class ParallelNodeLabelScanTestBase method createTestGraph.

@Override
public void createTestGraph(GraphDatabaseService graphDb) {
    MutableLongSet fooNodes = LongSets.mutable.empty();
    MutableLongSet barNodes = LongSets.mutable.empty();
    try (KernelTransaction tx = beginTransaction()) {
        TokenWrite tokenWrite = tx.tokenWrite();
        FOO_LABEL = tokenWrite.labelGetOrCreateForName("foo");
        BAR_LABEL = tokenWrite.labelGetOrCreateForName("bar");
        Write write = tx.dataWrite();
        for (int i = 0; i < NUMBER_OF_NODES; i++) {
            long node = write.nodeCreate();
            if (i % 2 == 0) {
                write.nodeAddLabel(node, FOO_LABEL);
                fooNodes.add(node);
            } else {
                write.nodeAddLabel(node, BAR_LABEL);
                barNodes.add(node);
            }
        }
        FOO_NODES = fooNodes;
        BAR_NODES = barNodes;
        tx.commit();
    } catch (KernelException e) {
        throw new AssertionError(e);
    }
}
Also used : TokenWrite(org.neo4j.internal.kernel.api.TokenWrite) Write(org.neo4j.internal.kernel.api.Write) KernelTransaction(org.neo4j.kernel.api.KernelTransaction) MutableLongSet(org.eclipse.collections.api.set.primitive.MutableLongSet) TokenWrite(org.neo4j.internal.kernel.api.TokenWrite) KernelException(org.neo4j.exceptions.KernelException)

Example 10 with TokenWrite

use of org.neo4j.internal.kernel.api.TokenWrite in project neo4j by neo4j.

the class NodeIndexOrderTest method entityWithTwoProps.

@Override
protected Pair<Long, Value[]> entityWithTwoProps(KernelTransaction tx, Object value1, Object value2) throws Exception {
    Write write = tx.dataWrite();
    long node = write.nodeCreate();
    TokenWrite tokenWrite = tx.tokenWrite();
    write.nodeAddLabel(node, tokenWrite.labelGetOrCreateForName(DEFAULT_LABEL));
    Value val1 = Values.of(value1);
    Value val2 = Values.of(value2);
    write.nodeSetProperty(node, tokenWrite.propertyKeyGetOrCreateForName(COMPOSITE_PROPERTY_1), val1);
    write.nodeSetProperty(node, tokenWrite.propertyKeyGetOrCreateForName(COMPOSITE_PROPERTY_2), val2);
    return Pair.of(node, new Value[] { val1, val2 });
}
Also used : TokenWrite(org.neo4j.internal.kernel.api.TokenWrite) Write(org.neo4j.internal.kernel.api.Write) Value(org.neo4j.values.storable.Value) TokenWrite(org.neo4j.internal.kernel.api.TokenWrite)

Aggregations

TokenWrite (org.neo4j.internal.kernel.api.TokenWrite)34 Test (org.junit.jupiter.api.Test)12 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)11 SchemaWrite (org.neo4j.internal.kernel.api.SchemaWrite)10 Write (org.neo4j.internal.kernel.api.Write)8 BeforeEach (org.junit.jupiter.api.BeforeEach)6 InternalTransaction (org.neo4j.kernel.impl.coreapi.InternalTransaction)6 KernelException (org.neo4j.exceptions.KernelException)5 KernelIntegrationTest (org.neo4j.kernel.impl.api.integrationtest.KernelIntegrationTest)5 NodeCursor (org.neo4j.internal.kernel.api.NodeCursor)4 Transaction (org.neo4j.graphdb.Transaction)3 RelationshipTraversalCursor (org.neo4j.internal.kernel.api.RelationshipTraversalCursor)3 FulltextSchemaDescriptor (org.neo4j.internal.schema.FulltextSchemaDescriptor)3 LabelSchemaDescriptor (org.neo4j.internal.schema.LabelSchemaDescriptor)3 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)2 SchemaKernelException (org.neo4j.internal.kernel.api.exceptions.schema.SchemaKernelException)2 ConstraintDescriptor (org.neo4j.internal.schema.ConstraintDescriptor)2 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)2 ExecutionException (java.util.concurrent.ExecutionException)1 MutableLongSet (org.eclipse.collections.api.set.primitive.MutableLongSet)1