use of org.neo4j.values.storable.TextValue in project neo4j by neo4j.
the class TxStateIndexChanges method indexUpdatesForRangeSeekByPrefix.
// PREFIX
static AddedAndRemoved indexUpdatesForRangeSeekByPrefix(ReadableTransactionState txState, IndexDescriptor descriptor, Value[] equalityPrefix, TextValue prefix, IndexOrder indexOrder) {
NavigableMap<ValueTuple, ? extends LongDiffSets> sortedUpdates = txState.getSortedIndexUpdates(descriptor.schema());
if (sortedUpdates == null) {
return EMPTY_ADDED_AND_REMOVED;
}
int size = descriptor.schema().getPropertyIds().length;
ValueTuple floor = getCompositeValueTuple(size, equalityPrefix, prefix, true);
ValueTuple maxString = getCompositeValueTuple(size, equalityPrefix, Values.MAX_STRING, false);
MutableLongList added = LongLists.mutable.empty();
MutableLongSet removed = LongSets.mutable.empty();
for (Map.Entry<ValueTuple, ? extends LongDiffSets> entry : sortedUpdates.subMap(floor, maxString).entrySet()) {
Value key = entry.getKey().valueAt(equalityPrefix.length);
// Needs to check type since the subMap might include non-TextValue for composite index
if (key.valueGroup() == ValueGroup.TEXT && ((TextValue) key).startsWith(prefix)) {
LongDiffSets diffSets = entry.getValue();
added.addAll(diffSets.getAdded());
removed.addAll(diffSets.getRemoved());
} else {
break;
}
}
return new AddedAndRemoved(indexOrder == IndexOrder.DESCENDING ? added.asReversed() : added, removed);
}
use of org.neo4j.values.storable.TextValue in project neo4j by neo4j.
the class FulltextConfigExtractor method indexConfigFromFulltextDirectory.
static IndexConfig indexConfigFromFulltextDirectory(FileSystemAbstraction fs, Path fulltextIndexDirectory) {
Path settingsFile = fulltextIndexDirectory.resolve(INDEX_CONFIG_FILE);
Properties settings = new Properties();
if (fs.fileExists(settingsFile)) {
try (Reader reader = fs.openAsReader(settingsFile, UTF_8)) {
settings.load(reader);
} catch (IOException e) {
throw new UncheckedIOException("Failed to read persisted fulltext index properties: " + settingsFile, e);
}
}
Map<String, Value> indexConfig = new HashMap<>();
TextValue analyser = extractSetting(settings, INDEX_CONFIG_ANALYZER);
BooleanValue eventuallyConsistent = extractBooleanSetting(settings, INDEX_CONFIG_EVENTUALLY_CONSISTENT);
if (analyser != null) {
indexConfig.put(FulltextIndexSettingsKeys.ANALYZER, analyser);
}
if (eventuallyConsistent != null) {
indexConfig.put(FulltextIndexSettingsKeys.EVENTUALLY_CONSISTENT, eventuallyConsistent);
}
return IndexConfig.with(indexConfig);
}
use of org.neo4j.values.storable.TextValue in project neo4j by neo4j.
the class GenericBlockBasedIndexPopulatorTest method shouldSeeExternalUpdateBothBeforeAndAfterScanCompleted.
@Test
void shouldSeeExternalUpdateBothBeforeAndAfterScanCompleted() throws IndexEntryConflictException, IOException {
// given
BlockBasedIndexPopulator<GenericKey, NativeIndexValue> populator = instantiatePopulator(INDEX_DESCRIPTOR);
try {
// when
TextValue hakuna = stringValue("hakuna");
TextValue matata = stringValue("matata");
int hakunaId = 1;
int matataId = 2;
externalUpdate(populator, hakuna, hakunaId);
populator.scanCompleted(nullInstance, populationWorkScheduler, NULL);
externalUpdate(populator, matata, matataId);
// then
assertMatch(populator, hakuna, hakunaId);
assertMatch(populator, matata, matataId);
} finally {
populator.close(true, NULL);
}
}
use of org.neo4j.values.storable.TextValue in project neo4j by neo4j.
the class BuiltInDbmsProceduresIT method listAllCapabilitiesShouldNotReturnBlocked.
@Test
void listAllCapabilitiesShouldNotReturnBlocked() throws KernelException {
// set blocked capabilities
Config config = dependencyResolver.resolveDependency(Config.class);
config.set(CapabilitiesSettings.dbms_capabilities_blocked, List.of("my.custom.**"));
QualifiedName procedureName = procedureName("dbms", "listAllCapabilities");
int procedureId = procs().procedureGet(procedureName).id();
RawIterator<AnyValue[], ProcedureException> callResult = procs().procedureCallDbms(procedureId, new AnyValue[] {}, ProcedureCallContext.EMPTY);
List<AnyValue[]> capabilities = asList(callResult);
List<String> capabilityNames = capabilities.stream().map(c -> ((TextValue) c[0]).stringValue()).collect(Collectors.toList());
assertThat(capabilityNames).containsExactlyInAnyOrder(DBMSCapabilities.dbms_instance_version.name().fullName(), DBMSCapabilities.dbms_instance_kernel_version.name().fullName(), DBMSCapabilities.dbms_instance_edition.name().fullName(), DBMSCapabilities.dbms_instance_operational_mode.name().fullName(), TestCapabilities.my_dynamic_capability.name().fullName(), TestCapabilities.my_internal_capability.name().fullName());
}
use of org.neo4j.values.storable.TextValue in project neo4j by neo4j.
the class BuiltInDbmsProceduresIT method listAllCapabilities.
@Test
void listAllCapabilities() throws KernelException {
QualifiedName procedureName = procedureName("dbms", "listAllCapabilities");
int procedureId = procs().procedureGet(procedureName).id();
RawIterator<AnyValue[], ProcedureException> callResult = procs().procedureCallDbms(procedureId, new AnyValue[] {}, ProcedureCallContext.EMPTY);
List<AnyValue[]> capabilities = asList(callResult);
List<String> capabilityNames = capabilities.stream().map(c -> ((TextValue) c[0]).stringValue()).collect(Collectors.toList());
assertThat(capabilityNames).containsExactlyInAnyOrder(DBMSCapabilities.dbms_instance_version.name().fullName(), DBMSCapabilities.dbms_instance_kernel_version.name().fullName(), DBMSCapabilities.dbms_instance_edition.name().fullName(), DBMSCapabilities.dbms_instance_operational_mode.name().fullName(), TestCapabilities.my_custom_capability.name().fullName(), TestCapabilities.my_internal_capability.name().fullName(), TestCapabilities.my_dynamic_capability.name().fullName());
}
Aggregations