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));
}
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));
}
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"));
}
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);
}
}
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 });
}
Aggregations