Search in sources :

Example 1 with ValueCategory

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());
}
Also used : ValueCategory(org.neo4j.values.storable.ValueCategory) IndexCapability(org.neo4j.internal.schema.IndexCapability) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) Test(org.junit.Test)

Example 2 with ValueCategory

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());
}
Also used : IndexConfigCompleter(org.neo4j.internal.schema.IndexConfigCompleter) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) IndexCapability(org.neo4j.internal.schema.IndexCapability) MutableInt(org.apache.commons.lang3.mutable.MutableInt) SchemaRule(org.neo4j.internal.schema.SchemaRule) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) ConstraintDescriptor(org.neo4j.internal.schema.ConstraintDescriptor) ConstraintDescriptorFactory.uniqueForLabel(org.neo4j.internal.schema.constraints.ConstraintDescriptorFactory.uniqueForLabel) ConstraintDescriptorFactory(org.neo4j.internal.schema.constraints.ConstraintDescriptorFactory) ArrayList(java.util.ArrayList) StandardConstraintRuleAccessor(org.neo4j.storageengine.api.StandardConstraintRuleAccessor) IndexConfigCompleter(org.neo4j.internal.schema.IndexConfigCompleter) Collections.singleton(java.util.Collections.singleton) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) SchemaDescriptor.forLabel(org.neo4j.internal.schema.SchemaDescriptor.forLabel) Iterables(org.neo4j.internal.helpers.collection.Iterables) Arrays.asList(java.util.Arrays.asList) SchemaDescriptor.forRelType(org.neo4j.internal.schema.SchemaDescriptor.forRelType) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) SchemaDescriptor.fulltext(org.neo4j.internal.schema.SchemaDescriptor.fulltext) Iterator(java.util.Iterator) Iterators(org.neo4j.internal.helpers.collection.Iterators) ConstraintType(org.neo4j.internal.schema.ConstraintType) IndexOrderCapability(org.neo4j.internal.schema.IndexOrderCapability) Set(java.util.Set) ValueCategory(org.neo4j.values.storable.ValueCategory) Iterators.single(org.neo4j.internal.helpers.collection.Iterators.single) RELATIONSHIP(org.neo4j.common.EntityType.RELATIONSHIP) Test(org.junit.jupiter.api.Test) IndexValueCapability(org.neo4j.internal.schema.IndexValueCapability) List(java.util.List) SchemaDescriptor(org.neo4j.internal.schema.SchemaDescriptor) Iterators.asSet(org.neo4j.internal.helpers.collection.Iterators.asSet) FulltextSchemaDescriptor(org.neo4j.internal.schema.FulltextSchemaDescriptor) IndexPrototype(org.neo4j.internal.schema.IndexPrototype) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) Collections(java.util.Collections) NODE(org.neo4j.common.EntityType.NODE) Race(org.neo4j.test.Race) ValueCategory(org.neo4j.values.storable.ValueCategory) ConstraintDescriptor(org.neo4j.internal.schema.ConstraintDescriptor) IndexCapability(org.neo4j.internal.schema.IndexCapability) ArrayList(java.util.ArrayList) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) Test(org.junit.jupiter.api.Test)

Example 3 with ValueCategory

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();
}
Also used : ValueCategory(org.neo4j.values.storable.ValueCategory) IndexCapability(org.neo4j.internal.schema.IndexCapability)

Example 4 with ValueCategory

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());
}
Also used : ValueCategory(org.neo4j.values.storable.ValueCategory) IndexCapability(org.neo4j.internal.schema.IndexCapability) IndexProviderDescriptor(org.neo4j.internal.schema.IndexProviderDescriptor) FulltextSchemaDescriptor(org.neo4j.internal.schema.FulltextSchemaDescriptor) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) Test(org.junit.jupiter.api.Test)

Example 5 with ValueCategory

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()));
        }
    }
}
Also used : ValueCategory(org.neo4j.values.storable.ValueCategory) IndexOrderCapability(org.neo4j.internal.schema.IndexOrderCapability)

Aggregations

ValueCategory (org.neo4j.values.storable.ValueCategory)5 IndexCapability (org.neo4j.internal.schema.IndexCapability)4 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)3 Test (org.junit.jupiter.api.Test)2 FulltextSchemaDescriptor (org.neo4j.internal.schema.FulltextSchemaDescriptor)2 IndexOrderCapability (org.neo4j.internal.schema.IndexOrderCapability)2 ArrayList (java.util.ArrayList)1 Arrays.asList (java.util.Arrays.asList)1 Collections (java.util.Collections)1 Collections.singleton (java.util.Collections.singleton)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Set (java.util.Set)1 MutableInt (org.apache.commons.lang3.mutable.MutableInt)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Test (org.junit.Test)1 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)1 Assertions.assertFalse (org.junit.jupiter.api.Assertions.assertFalse)1 Assertions.assertNull (org.junit.jupiter.api.Assertions.assertNull)1 Assertions.assertThrows (org.junit.jupiter.api.Assertions.assertThrows)1