use of org.neo4j.values.storable.ValueCategory in project neo4j by neo4j.
the class IndexConfigurationCompletionCompatibility method mustNotOverwriteExistingCapabilities.
@Test
public void mustNotOverwriteExistingCapabilities() {
IndexCapability capability = new IndexCapability() {
@Override
public IndexOrderCapability orderCapability(ValueCategory... valueCategories) {
return IndexOrderCapability.NONE;
}
@Override
public IndexValueCapability valueCapability(ValueCategory... valueCategories) {
return IndexValueCapability.NO;
}
};
IndexDescriptor index = descriptor.withIndexCapability(capability);
IndexDescriptor completed = indexProvider.completeConfiguration(index);
assertSame(capability, completed.getCapability());
}
use of org.neo4j.values.storable.ValueCategory in project neo4j by neo4j.
the class SchemaCacheTest method shouldCompleteConfigurationOfIndexesAddedToCache.
@Test
void shouldCompleteConfigurationOfIndexesAddedToCache() {
IndexCapability capability = new IndexCapability() {
@Override
public IndexOrderCapability orderCapability(ValueCategory... valueCategories) {
return IndexOrderCapability.NONE;
}
@Override
public IndexValueCapability valueCapability(ValueCategory... valueCategories) {
return IndexValueCapability.NO;
}
};
List<IndexDescriptor> completed = new ArrayList<>();
IndexConfigCompleter completer = index -> {
completed.add(index);
return index.withIndexCapability(capability);
};
SchemaCache cache = new SchemaCache(new ConstraintSemantics(), completer);
IndexDescriptor index1 = newIndexRule(1, 2, 3);
ConstraintDescriptor constraint1 = uniquenessConstraint(2, 2, 3, 1);
IndexDescriptor index2 = newIndexRule(3, 4, 5);
ConstraintDescriptor constraint2 = uniquenessConstraint(4, 4, 5, 3);
IndexDescriptor index3 = newIndexRule(5, 5, 5);
cache.load(asList(index1, constraint1));
cache.addSchemaRule(index2);
cache.addSchemaRule(constraint2);
cache.addSchemaRule(index3);
assertEquals(List.of(index1, index2, index3), completed);
assertEquals(capability, cache.getIndex(index1.getId()).getCapability());
assertEquals(capability, cache.getIndex(index2.getId()).getCapability());
assertEquals(capability, cache.getIndex(index3.getId()).getCapability());
}
use of org.neo4j.values.storable.ValueCategory in project neo4j by neo4j.
the class IndexSizes method hasValues.
static boolean hasValues(IndexDescriptor index) {
IndexCapability capabilities = index.getCapability();
ValueCategory[] categories = new ValueCategory[index.schema().getPropertyIds().length];
Arrays.fill(categories, ValueCategory.UNKNOWN);
return capabilities.valueCapability(categories) == IndexValueCapability.YES && !index.schema().isFulltextSchemaDescriptor();
}
use of org.neo4j.values.storable.ValueCategory in project neo4j by neo4j.
the class LuceneFulltextIndexTest method mustNotOverwriteExistingCapabilities.
@Test
void mustNotOverwriteExistingCapabilities() {
IndexCapability capability = new IndexCapability() {
@Override
public IndexOrderCapability orderCapability(ValueCategory... valueCategories) {
return IndexOrderCapability.NONE;
}
@Override
public IndexValueCapability valueCapability(ValueCategory... valueCategories) {
return IndexValueCapability.NO;
}
};
FulltextSchemaDescriptor schema = SchemaDescriptor.fulltext(NODE, new int[] { 1 }, new int[] { 1 });
IndexProviderDescriptor providerDescriptor = indexProvider.getProviderDescriptor();
IndexDescriptor index = IndexPrototype.forSchema(schema, providerDescriptor).withName("index_1").materialise(1).withIndexCapability(capability);
IndexDescriptor completed = indexProvider.completeConfiguration(index);
assertSame(capability, completed.getCapability());
}
use of org.neo4j.values.storable.ValueCategory in project neo4j by neo4j.
the class QueryValidator method validateOrder.
static void validateOrder(IndexCapability capability, IndexOrder indexOrder, PropertyIndexQuery[] predicates) {
if (indexOrder != IndexOrder.NONE) {
ValueCategory valueCategory = predicates[0].valueGroup().category();
IndexOrderCapability orderCapability = capability.orderCapability(valueCategory);
if (indexOrder == IndexOrder.ASCENDING && !orderCapability.supportsAsc() || indexOrder == IndexOrder.DESCENDING && !orderCapability.supportsDesc()) {
throw new UnsupportedOperationException(format("Tried to query index with unsupported order %s. For query %s supports ascending: %b, supports descending: %b.", indexOrder, Arrays.toString(predicates), orderCapability.supportsAsc(), orderCapability.supportsDesc()));
}
}
}
Aggregations