use of org.neo4j.kernel.impl.util.diffsets.DiffSets in project neo4j by neo4j.
the class TxState method getIndexUpdatesForRangeSeekByString.
private ReadableDiffSets<Long> getIndexUpdatesForRangeSeekByString(NewIndexDescriptor descriptor, String lower, boolean includeLower, String upper, boolean includeUpper) {
TreeMap<OrderedPropertyValues, DiffSets<Long>> sortedUpdates = getSortedIndexUpdates(descriptor.schema());
if (sortedUpdates == null) {
return null;
}
OrderedPropertyValues selectedLower;
boolean selectedIncludeLower;
OrderedPropertyValues selectedUpper;
boolean selectedIncludeUpper;
//TODO: Get working with composite indexes
if (lower == null) {
selectedLower = OrderedPropertyValues.ofUndefined(STRING.lowLimit.castValue(String.class));
selectedIncludeLower = STRING.lowLimit.isInclusive;
} else {
selectedLower = OrderedPropertyValues.ofUndefined(lower);
selectedIncludeLower = includeLower;
}
if (upper == null) {
selectedUpper = OrderedPropertyValues.ofUndefined(STRING.highLimit.castValue(Boolean.class).booleanValue());
selectedIncludeUpper = STRING.highLimit.isInclusive;
} else {
selectedUpper = OrderedPropertyValues.ofUndefined(upper);
selectedIncludeUpper = includeUpper;
}
DiffSets<Long> diffs = new DiffSets<>();
Collection<DiffSets<Long>> inRange = sortedUpdates.subMap(selectedLower, selectedIncludeLower, selectedUpper, selectedIncludeUpper).values();
for (DiffSets<Long> diffForSpecificValue : inRange) {
diffs.addAll(diffForSpecificValue.getAdded().iterator());
diffs.removeAll(diffForSpecificValue.getRemoved().iterator());
}
return diffs;
}
use of org.neo4j.kernel.impl.util.diffsets.DiffSets in project neo4j by neo4j.
the class TxState method getIndexUpdatesForRangeSeekByPrefix.
private ReadableDiffSets<Long> getIndexUpdatesForRangeSeekByPrefix(NewIndexDescriptor descriptor, String prefix) {
TreeMap<OrderedPropertyValues, DiffSets<Long>> sortedUpdates = getSortedIndexUpdates(descriptor.schema());
if (sortedUpdates == null) {
return null;
}
//TODO: get working with composite indexes
OrderedPropertyValues floor = OrderedPropertyValues.ofUndefined(prefix);
DiffSets<Long> diffs = new DiffSets<>();
for (Map.Entry<OrderedPropertyValues, DiffSets<Long>> entry : sortedUpdates.tailMap(floor).entrySet()) {
OrderedPropertyValues key = entry.getKey();
if (key.getSinglePropertyValue().toString().startsWith(prefix)) {
DiffSets<Long> diffSets = entry.getValue();
diffs.addAll(diffSets.getAdded().iterator());
diffs.removeAll(diffSets.getRemoved().iterator());
} else {
break;
}
}
return diffs;
}
use of org.neo4j.kernel.impl.util.diffsets.DiffSets in project neo4j by neo4j.
the class TxState method getIndexUpdatesForRangeSeekByNumber.
private ReadableDiffSets<Long> getIndexUpdatesForRangeSeekByNumber(NewIndexDescriptor descriptor, Number lower, boolean includeLower, Number upper, boolean includeUpper) {
TreeMap<OrderedPropertyValues, DiffSets<Long>> sortedUpdates = getSortedIndexUpdates(descriptor.schema());
if (sortedUpdates == null) {
return null;
}
OrderedPropertyValues selectedLower;
boolean selectedIncludeLower;
OrderedPropertyValues selectedUpper;
boolean selectedIncludeUpper;
//TODO: Get working with composite indexes
if (lower == null) {
selectedLower = OrderedPropertyValues.ofUndefined(NUMBER.lowLimit.castValue(Number.class));
selectedIncludeLower = NUMBER.lowLimit.isInclusive;
} else {
selectedLower = OrderedPropertyValues.ofUndefined(lower);
selectedIncludeLower = includeLower;
}
if (upper == null) {
selectedUpper = OrderedPropertyValues.ofUndefined(NUMBER.highLimit.castValue(Number.class));
selectedIncludeUpper = NUMBER.highLimit.isInclusive;
} else {
selectedUpper = OrderedPropertyValues.ofUndefined(upper);
selectedIncludeUpper = includeUpper;
}
DiffSets<Long> diffs = new DiffSets<>();
Collection<DiffSets<Long>> inRange = sortedUpdates.subMap(selectedLower, selectedIncludeLower, selectedUpper, selectedIncludeUpper).values();
for (DiffSets<Long> diffForSpecificValue : inRange) {
diffs.addAll(diffForSpecificValue.getAdded().iterator());
diffs.removeAll(diffForSpecificValue.getRemoved().iterator());
}
return diffs;
}
use of org.neo4j.kernel.impl.util.diffsets.DiffSets in project neo4j by neo4j.
the class LongDiffSetsTest method shouldContainSourceForEmptyDiffSets.
// TODO empty diffset EMPTY
// TODO null/isEmpty elements
@Test
public void shouldContainSourceForEmptyDiffSets() throws Exception {
// given
DiffSets<Long> diffSets = new DiffSets<>();
Iterator<Long> expected = diffSets.apply(iteratorSource(1L, 2L));
// when
PrimitiveLongIterator actual = diffSets.augment(iterator(1L, 2L));
// then
assertThat(expected, hasSamePrimitiveItems(actual));
}
use of org.neo4j.kernel.impl.util.diffsets.DiffSets in project neo4j by neo4j.
the class LongDiffSetsTest method shouldContainFilteredSourceForDiffSetsWithAddedElements.
@Test
public void shouldContainFilteredSourceForDiffSetsWithAddedElements() throws Exception {
// given
DiffSets<Long> diffSets = new DiffSets<>();
diffSets.add(17L);
diffSets.add(18L);
Iterator<Long> expected = diffSets.apply(iteratorSource(1L, 17L, 3L));
// when
PrimitiveLongIterator actual = diffSets.augment(iterator(1L, 17L, 3L));
// then
assertThat(expected, hasSamePrimitiveItems(actual));
}
Aggregations