use of io.vertigo.dynamo.search.metamodel.SearchChunk in project vertigo by KleeGroup.
the class CarSearchLoader method getTaskLoadCarList.
private TaskDefinition getTaskLoadCarList(final SearchChunk<Car> searchChunk) {
final Domain doCarList = definitionSpace.resolve("DO_DT_CAR_DTC", Domain.class);
final String sql = searchChunk.getAllURIs().stream().map(uri -> uri.getId().toString()).collect(Collectors.joining(", ", "select * from CAR where ID in (", ")"));
return TaskDefinition.builder("TK_LOAD_ALL_CARS").withEngine(TaskEngineSelect.class).withRequest(sql).withPackageName(TaskEngineSelect.class.getPackage().getName()).withOutRequired("dtc", doCarList).build();
}
use of io.vertigo.dynamo.search.metamodel.SearchChunk in project vertigo by KleeGroup.
the class ItemSearchLoader method getTaskDefinition.
private TaskDefinition getTaskDefinition(final SearchChunk<Item> searchChunk) {
final Domain doItems = definitionSpace.resolve("DO_DT_ITEM_DTC", Domain.class);
final String sql = searchChunk.getAllURIs().stream().map(uri -> uri.getId().toString()).collect(Collectors.joining(", ", "select * from ITEM where ID in (", ")"));
return TaskDefinition.builder("TK_LOAD_ALL_ITEMS").withEngine(TaskEngineSelect.class).withRequest(sql).withPackageName(TaskEngineSelect.class.getPackage().getName()).withOutRequired("dtc", doItems).build();
}
use of io.vertigo.dynamo.search.metamodel.SearchChunk in project vertigo by KleeGroup.
the class ReindexTask method run.
/**
* {@inheritDoc}
*/
@Override
public void run() {
long dirtyElementsCount = 0;
do {
final long startTime = System.currentTimeMillis();
final List<URI<? extends KeyConcept>> reindexUris = new ArrayList<>();
try {
synchronized (dirtyElements) {
if (!dirtyElements.isEmpty()) {
reindexUris.addAll(dirtyElements.subList(0, Math.min(dirtyElements.size(), DIRTY_ELEMENTS_CHUNK_SIZE)));
dirtyElements.removeAll(reindexUris);
}
}
dirtyElementsCount = reindexUris.size();
if (!reindexUris.isEmpty()) {
loadAndIndexAndRetry(new SearchChunk(reindexUris), 0);
}
} catch (final Exception e) {
LOGGER.error("Update index error, skip " + dirtyElementsCount + " elements (" + reindexUris + ")", e);
} finally {
LOGGER.log(dirtyElementsCount > 0 ? Level.INFO : Level.DEBUG, "Update index, " + dirtyElementsCount + " " + searchIndexDefinition.getName() + " finished in " + (System.currentTimeMillis() - startTime) + "ms");
}
} while (dirtyElementsCount > 0);
}
Aggregations