use of org.neo4j.internal.schema.IndexCapability 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.internal.schema.IndexCapability 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.internal.schema.IndexCapability in project neo4j by neo4j.
the class FusionIndexProvider method completeConfiguration.
@Override
public IndexDescriptor completeConfiguration(IndexDescriptor index) {
EnumMap<IndexSlot, IndexDescriptor> descriptors = new EnumMap<>(IndexSlot.class);
EnumMap<IndexSlot, IndexCapability> capabilities = new EnumMap<>(IndexSlot.class);
for (IndexSlot slot : IndexSlot.values()) {
IndexDescriptor result = providers.select(slot).completeConfiguration(index);
descriptors.put(slot, result);
capabilities.put(slot, result.getCapability());
}
IndexConfig config = index.getIndexConfig();
for (IndexDescriptor result : descriptors.values()) {
IndexConfig resultConfig = result.getIndexConfig();
for (Pair<String, Value> entry : resultConfig.entries()) {
config = config.withIfAbsent(entry.getOne(), entry.getTwo());
}
}
index = index.withIndexConfig(config);
if (index.getCapability().equals(IndexCapability.NO_CAPABILITY)) {
index = index.withIndexCapability(new FusionIndexCapability(slotSelector, new InstanceSelector<>(capabilities)));
}
return index;
}
use of org.neo4j.internal.schema.IndexCapability in project neo4j by neo4j.
the class IndexSizesTest method createIndexes.
private void createIndexes(int numSmall, int numLarge) {
IndexCapability capabilityWithValue = mock(IndexCapability.class);
when(capabilityWithValue.valueCapability(any())).thenReturn(IndexValueCapability.YES);
IndexPrototype prototype = prototype();
for (int i = 0; i < numLarge; i++) {
// using id as "size"
indexes.add(prototype.materialise(highNodeId / 2 + i).withIndexCapability(capabilityWithValue));
}
for (int i = 0; i < numSmall; i++) {
// using id as "size"
indexes.add(prototype.materialise(i).withIndexCapability(capabilityWithValue));
}
try {
sizes.initialize();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of org.neo4j.internal.schema.IndexCapability 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();
}
Aggregations