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());
}
}
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)));
}
}
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)));
}
}
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);
}
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();
}
}
Aggregations