Search in sources :

Example 1 with ValueType

use of org.neo4j.values.storable.ValueType in project neo4j by neo4j.

the class SimpleIndexAccessorCompatibility method shouldRemoveEntries.

@Test
public void shouldRemoveEntries() throws Exception {
    ValueType[] valueTypes = testSuite.supportedValueTypes();
    long entityId = random.nextLong(1_000_000_000);
    for (ValueType valueType : valueTypes) {
        // given
        Value value = random.nextValue(valueType);
        updateAndCommit(singletonList(IndexEntryUpdate.add(entityId, descriptor.schema(), value)));
        assertEquals(singletonList(entityId), query(PropertyIndexQuery.exact(0, value)));
        // when
        updateAndCommit(singletonList(IndexEntryUpdate.remove(entityId, descriptor.schema(), value)));
        // then
        assertTrue(query(PropertyIndexQuery.exact(0, value)).isEmpty());
    }
}
Also used : ValueType(org.neo4j.values.storable.ValueType) ArrayValue(org.neo4j.values.storable.ArrayValue) Value(org.neo4j.values.storable.Value) PointValue(org.neo4j.values.storable.PointValue) LocalDateTimeValue(org.neo4j.values.storable.LocalDateTimeValue) TimeValue(org.neo4j.values.storable.TimeValue) DateTimeValue(org.neo4j.values.storable.DateTimeValue) LocalTimeValue(org.neo4j.values.storable.LocalTimeValue) Values.stringValue(org.neo4j.values.storable.Values.stringValue) DateValue(org.neo4j.values.storable.DateValue) Test(org.junit.Test)

Example 2 with ValueType

use of org.neo4j.values.storable.ValueType in project neo4j by neo4j.

the class CompositeIndexAccessorCompatibility method shouldUpdateEntries.

@Test
public void shouldUpdateEntries() throws Exception {
    ValueType[] valueTypes = testSuite.supportedValueTypes();
    long entityId = random.nextLong(1_000_000_000);
    for (ValueType valueType : valueTypes) {
        // given
        Value[] value = new Value[] { random.nextValue(valueType), random.nextValue(valueType) };
        updateAndCommit(singletonList(IndexEntryUpdate.add(entityId, descriptor.schema(), value)));
        assertEquals(singletonList(entityId), query(exactQuery(value)));
        // when
        Value[] newValue;
        do {
            newValue = new Value[] { random.nextValue(valueType), random.nextValue(valueType) };
        } while (ValueTuple.of(value).equals(ValueTuple.of(newValue)));
        updateAndCommit(singletonList(IndexEntryUpdate.change(entityId, descriptor.schema(), value, newValue)));
        // then
        assertEquals(emptyList(), query(exactQuery(value)));
        assertEquals(singletonList(entityId), query(exactQuery(newValue)));
    }
}
Also used : ValueType(org.neo4j.values.storable.ValueType) ArrayValue(org.neo4j.values.storable.ArrayValue) Value(org.neo4j.values.storable.Value) TextValue(org.neo4j.values.storable.TextValue) PointValue(org.neo4j.values.storable.PointValue) LocalDateTimeValue(org.neo4j.values.storable.LocalDateTimeValue) TimeValue(org.neo4j.values.storable.TimeValue) DateTimeValue(org.neo4j.values.storable.DateTimeValue) Values.intValue(org.neo4j.values.storable.Values.intValue) Values.pointValue(org.neo4j.values.storable.Values.pointValue) LocalTimeValue(org.neo4j.values.storable.LocalTimeValue) BooleanValue(org.neo4j.values.storable.BooleanValue) Values.stringValue(org.neo4j.values.storable.Values.stringValue) DateValue(org.neo4j.values.storable.DateValue) Test(org.junit.Test)

Example 3 with ValueType

use of org.neo4j.values.storable.ValueType in project neo4j by neo4j.

the class SimpleIndexAccessorCompatibility method shouldUpdateEntries.

@Test
public void shouldUpdateEntries() throws Exception {
    ValueType[] valueTypes = testSuite.supportedValueTypes();
    long entityId = random.nextLong(1_000_000_000);
    for (ValueType valueType : valueTypes) {
        // given
        Value value = random.nextValue(valueType);
        updateAndCommit(singletonList(IndexEntryUpdate.add(entityId, descriptor.schema(), value)));
        assertEquals(singletonList(entityId), query(PropertyIndexQuery.exact(0, value)));
        // when
        Value newValue;
        do {
            newValue = random.nextValue(valueType);
        } while (value.equals(newValue));
        updateAndCommit(singletonList(IndexEntryUpdate.change(entityId, descriptor.schema(), value, newValue)));
        // then
        assertEquals(emptyList(), query(PropertyIndexQuery.exact(0, value)));
        assertEquals(singletonList(entityId), query(PropertyIndexQuery.exact(0, newValue)));
    }
}
Also used : ValueType(org.neo4j.values.storable.ValueType) ArrayValue(org.neo4j.values.storable.ArrayValue) Value(org.neo4j.values.storable.Value) PointValue(org.neo4j.values.storable.PointValue) LocalDateTimeValue(org.neo4j.values.storable.LocalDateTimeValue) TimeValue(org.neo4j.values.storable.TimeValue) DateTimeValue(org.neo4j.values.storable.DateTimeValue) LocalTimeValue(org.neo4j.values.storable.LocalTimeValue) Values.stringValue(org.neo4j.values.storable.Values.stringValue) DateValue(org.neo4j.values.storable.DateValue) Test(org.junit.Test)

Example 4 with ValueType

use of org.neo4j.values.storable.ValueType in project neo4j by neo4j.

the class IndexProvidedValuesNativeBTree10Test method createTestGraph.

@Override
public void createTestGraph(GraphDatabaseService graphDb) {
    try (Transaction tx = graphDb.beginTx()) {
        getEntityControl().createIndex(tx, TOKEN, PROP, PROP_INDEX);
        getEntityControl().createIndex(tx, TOKEN, PROP, PRIP, PROP_PRIP_INDEX);
        tx.commit();
    }
    try (Transaction tx = graphDb.beginTx()) {
        tx.schema().awaitIndexesOnline(5, MINUTES);
        tx.commit();
    }
    try (Transaction tx = graphDb.beginTx()) {
        RandomValues randomValues = randomRule.randomValues();
        ValueType[] allExceptNonSortable = RandomValues.excluding(ValueType.STRING, ValueType.STRING_ARRAY);
        for (int i = 0; i < N_ENTITIES; i++) {
            var node = getEntityControl().createEntity(tx, TOKEN);
            Value propValue = randomValues.nextValueOfTypes(allExceptNonSortable);
            node.setProperty(PROP, propValue.asObject());
            Value pripValue = randomValues.nextValueOfTypes(allExceptNonSortable);
            node.setProperty(PRIP, pripValue.asObject());
            singlePropValues.add(propValue);
            doublePropValues.add(ValueTuple.of(propValue, pripValue));
        }
        tx.commit();
    }
    singlePropValues.sort(Values.COMPARATOR);
    doublePropValues.sort(ValueTuple.COMPARATOR);
}
Also used : Transaction(org.neo4j.graphdb.Transaction) KernelTransaction(org.neo4j.kernel.api.KernelTransaction) ValueType(org.neo4j.values.storable.ValueType) Value(org.neo4j.values.storable.Value) RandomValues(org.neo4j.values.storable.RandomValues)

Example 5 with ValueType

use of org.neo4j.values.storable.ValueType in project neo4j by neo4j.

the class AbstractIndexProvidedOrderTest method createTestGraph.

@Override
public void createTestGraph(GraphDatabaseService graphDb) {
    try (Transaction tx = graphDb.beginTx()) {
        getEntityControl().createIndex(tx, TOKEN, PROPERTY_KEY, INDEX_NAME);
        tx.commit();
    }
    try (Transaction tx = graphDb.beginTx()) {
        tx.schema().awaitIndexesOnline(5, MINUTES);
        tx.commit();
    }
    RandomValues randomValues = randomRule.randomValues();
    ValueType[] allExceptNonOrderable = RandomValues.excluding(ValueType.STRING, ValueType.STRING_ARRAY, ValueType.GEOGRAPHIC_POINT, ValueType.GEOGRAPHIC_POINT_ARRAY, ValueType.GEOGRAPHIC_POINT_3D, ValueType.GEOGRAPHIC_POINT_3D_ARRAY, ValueType.CARTESIAN_POINT, ValueType.CARTESIAN_POINT_ARRAY, ValueType.CARTESIAN_POINT_3D, ValueType.CARTESIAN_POINT_3D_ARRAY);
    targetedTypes = randomValues.selection(allExceptNonOrderable, 1, allExceptNonOrderable.length, false);
    targetedTypes = ensureHighEnoughCardinality(targetedTypes);
    try (Transaction tx = graphDb.beginTx()) {
        for (int i = 0; i < N_ENTITIES; i++) {
            var node = getEntityControl().createEntity(tx, TOKEN);
            Value propValue;
            EntityValueTuple singleValue;
            do {
                propValue = randomValues.nextValueOfTypes(targetedTypes);
                singleValue = new EntityValueTuple(node.getId(), propValue);
            } while (singlePropValues.contains(singleValue));
            singlePropValues.add(singleValue);
            node.setProperty(PROPERTY_KEY, propValue.asObject());
        }
        tx.commit();
    }
}
Also used : Transaction(org.neo4j.graphdb.Transaction) KernelTransaction(org.neo4j.kernel.api.KernelTransaction) ValueType(org.neo4j.values.storable.ValueType) Value(org.neo4j.values.storable.Value) RandomValues(org.neo4j.values.storable.RandomValues)

Aggregations

ValueType (org.neo4j.values.storable.ValueType)13 Value (org.neo4j.values.storable.Value)10 Test (org.junit.Test)7 PointValue (org.neo4j.values.storable.PointValue)5 ValueIndexEntryUpdate (org.neo4j.storageengine.api.ValueIndexEntryUpdate)4 ArrayValue (org.neo4j.values.storable.ArrayValue)4 DateTimeValue (org.neo4j.values.storable.DateTimeValue)4 DateValue (org.neo4j.values.storable.DateValue)4 LocalDateTimeValue (org.neo4j.values.storable.LocalDateTimeValue)4 LocalTimeValue (org.neo4j.values.storable.LocalTimeValue)4 TimeValue (org.neo4j.values.storable.TimeValue)4 Values.stringValue (org.neo4j.values.storable.Values.stringValue)4 ArrayList (java.util.ArrayList)3 MutableLong (org.apache.commons.lang3.mutable.MutableLong)3 IndexOrderCapability (org.neo4j.internal.schema.IndexOrderCapability)3 RandomValues (org.neo4j.values.storable.RandomValues)3 HashSet (java.util.HashSet)2 Test (org.junit.jupiter.api.Test)2 Transaction (org.neo4j.graphdb.Transaction)2 PropertyIndexQuery (org.neo4j.internal.kernel.api.PropertyIndexQuery)2