use of org.neo4j.internal.schema.SchemaDescriptor in project neo4j by neo4j.
the class TxStateTest method shouldAddAndGetByLabel.
@Test
void shouldAddAndGetByLabel() {
// WHEN
state.indexDoAdd(indexOn_1_1);
state.indexDoAdd(indexOn_2_1);
// THEN
SchemaDescriptor schema = indexOn_1_1.schema();
int[] labels = schema.getEntityTokenIds();
assertEquals(schema.entityType(), EntityType.NODE);
assertEquals(1, labels.length);
assertEquals(asSet(indexOn_1_1), state.indexDiffSetsByLabel(labels[0]).getAdded());
}
use of org.neo4j.internal.schema.SchemaDescriptor in project neo4j by neo4j.
the class BuiltInProcedures method asIndexResult.
private static IndexResult asIndexResult(TokenNameLookup tokenLookup, SchemaReadCore schemaRead, IndexDescriptor index) {
SchemaDescriptor schema = index.schema();
long id = index.getId();
String name = index.getName();
IndexStatus status = getIndexStatus(schemaRead, index);
String uniqueness = IndexUniqueness.getUniquenessOf(index);
String type = index.getIndexType().name();
String entityType = index.schema().entityType().name();
List<String> labelsOrTypes = Arrays.asList(tokenLookup.entityTokensGetNames(schema.entityType(), schema.getEntityTokenIds()));
List<String> properties = propertyNames(tokenLookup, index);
String provider = index.getIndexProvider().name();
return new IndexResult(id, name, status.state, status.populationProgress, uniqueness, type, entityType, labelsOrTypes, properties, provider);
}
use of org.neo4j.internal.schema.SchemaDescriptor in project neo4j by neo4j.
the class RandomSchema method nextIndex.
public IndexDescriptor nextIndex() {
int choice = rng.nextInt(4);
SchemaDescriptor schema;
switch(choice) {
case 0:
schema = nextNodeSchema();
break;
case 1:
schema = nextNodeFulltextSchema();
break;
case 2:
schema = nextRelationshipSchema();
break;
case 3:
schema = nextRelationshipFulltextSchema();
break;
default:
throw new RuntimeException("Bad index choice: " + choice);
}
boolean isUnique = rng.nextBoolean() && !schema.isFulltextSchemaDescriptor();
IndexPrototype prototype = isUnique ? IndexPrototype.uniqueForSchema(schema) : IndexPrototype.forSchema(schema);
IndexProviderDescriptor providerDescriptor = new IndexProviderDescriptor(nextName(), nextName());
prototype = prototype.withIndexProvider(providerDescriptor);
prototype = prototype.withName(nextName());
if (schema.isFulltextSchemaDescriptor()) {
prototype = prototype.withIndexType(IndexType.FULLTEXT);
}
long ruleId = nextRuleIdForIndex();
IndexDescriptor index = prototype.materialise(ruleId);
if (isUnique && rng.nextBoolean()) {
index = index.withOwningConstraintId(existingConstraintId());
}
return index;
}
Aggregations