use of org.neo4j.internal.schema.LabelSchemaDescriptor in project neo4j by neo4j.
the class SchemaProcessorTest method shouldHandleCorrectDescriptorVersions.
@Test
void shouldHandleCorrectDescriptorVersions() {
List<String> callHistory = new ArrayList<>();
SchemaProcessor processor = new SchemaProcessor() {
@Override
public void processSpecific(LabelSchemaDescriptor schema) {
callHistory.add("LabelSchemaDescriptor");
}
@Override
public void processSpecific(RelationTypeSchemaDescriptor schema) {
callHistory.add("RelationTypeSchemaDescriptor");
}
@Override
public void processSpecific(SchemaDescriptor schemaDescriptor) {
callHistory.add("SchemaDescriptor");
}
};
disguisedLabel().processWith(processor);
disguisedLabel().processWith(processor);
disguisedRelType().processWith(processor);
disguisedLabel().processWith(processor);
disguisedRelType().processWith(processor);
disguisedRelType().processWith(processor);
assertThat(callHistory).containsExactly("LabelSchemaDescriptor", "LabelSchemaDescriptor", "RelationTypeSchemaDescriptor", "LabelSchemaDescriptor", "RelationTypeSchemaDescriptor", "RelationTypeSchemaDescriptor");
}
use of org.neo4j.internal.schema.LabelSchemaDescriptor in project neo4j by neo4j.
the class SchemaDescriptorTest method shouldCreateEqualLabels.
@Test
void shouldCreateEqualLabels() {
LabelSchemaDescriptor desc1 = SchemaDescriptor.forLabel(LABEL_ID, 1);
LabelSchemaDescriptor desc2 = SchemaDescriptor.forLabel(LABEL_ID, 1);
SchemaTestUtil.assertEquality(desc1, desc2);
}
use of org.neo4j.internal.schema.LabelSchemaDescriptor in project neo4j by neo4j.
the class SchemaRuleDeserializer2_0to3_1 method readIndexRule.
// === INDEX RULES ===
private static IndexDescriptor readIndexRule(long id, boolean constraintIndex, int label, ByteBuffer serialized) {
String providerKey = getDecodedStringFrom(serialized);
String providerVersion = getDecodedStringFrom(serialized);
IndexProviderDescriptor providerDescriptor = new IndexProviderDescriptor(providerKey, providerVersion);
int[] propertyKeyIds = readIndexPropertyKeys(serialized);
LabelSchemaDescriptor schema = SchemaDescriptor.forLabel(label, propertyKeyIds);
String name = defaultIndexName(id);
if (constraintIndex) {
return IndexPrototype.uniqueForSchema(schema, providerDescriptor).withName(name).materialise(id).withOwningConstraintId(readOwningConstraint(serialized));
} else {
return IndexPrototype.forSchema(schema, providerDescriptor).withName(name).materialise(id);
}
}
use of org.neo4j.internal.schema.LabelSchemaDescriptor in project neo4j by neo4j.
the class IndexRecoveryIT method createSomeBananas.
private Set<IndexEntryUpdate<?>> createSomeBananas(Label label) {
Set<IndexEntryUpdate<?>> updates = new HashSet<>();
try (Transaction tx = db.beginTx()) {
KernelTransaction ktx = ((InternalTransaction) tx).kernelTransaction();
int labelId = ktx.tokenRead().nodeLabel(label.name());
int propertyKeyId = ktx.tokenRead().propertyKey(key);
LabelSchemaDescriptor schemaDescriptor = SchemaDescriptor.forLabel(labelId, propertyKeyId);
for (int number : new int[] { 4, 10 }) {
Node node = tx.createNode(label);
node.setProperty(key, number);
updates.add(IndexEntryUpdate.add(node.getId(), schemaDescriptor, Values.of(number)));
}
tx.commit();
return updates;
}
}
use of org.neo4j.internal.schema.LabelSchemaDescriptor in project neo4j by neo4j.
the class IndexIT method createIndexesForDifferentLabelsConcurrently.
@Test
@Timeout(10)
void createIndexesForDifferentLabelsConcurrently() throws Throwable {
TokenWrite tokenWrite = tokenWriteInNewTransaction();
int label2 = tokenWrite.labelGetOrCreateForName("Label2");
commit();
LabelSchemaDescriptor anotherLabelDescriptor = SchemaDescriptor.forLabel(label2, propertyKeyId);
schemaWriteInNewTransaction().indexCreate(anotherLabelDescriptor, "my index");
Future<?> indexFuture = executorService.submit(createIndex(db, label(LABEL), PROPERTY_KEY));
indexFuture.get();
commit();
}
Aggregations