Search in sources :

Example 1 with SearchChunk

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();
}
Also used : AbstractSqlSearchLoader(io.vertigo.dynamox.search.AbstractSqlSearchLoader) SearchChunk(io.vertigo.dynamo.search.metamodel.SearchChunk) TaskDefinition(io.vertigo.dynamo.task.metamodel.TaskDefinition) DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) URI(io.vertigo.dynamo.domain.model.URI) DtObjectUtil(io.vertigo.dynamo.domain.util.DtObjectUtil) VTransactionWritable(io.vertigo.commons.transaction.VTransactionWritable) Domain(io.vertigo.dynamo.domain.metamodel.Domain) Task(io.vertigo.dynamo.task.model.Task) DefinitionSpace(io.vertigo.core.definition.DefinitionSpace) DtList(io.vertigo.dynamo.domain.model.DtList) SearchIndex(io.vertigo.dynamo.search.model.SearchIndex) Collectors(java.util.stream.Collectors) VTransactionManager(io.vertigo.commons.transaction.VTransactionManager) SearchIndexDefinition(io.vertigo.dynamo.search.metamodel.SearchIndexDefinition) Car(io.vertigo.dynamo.search_2_4.data.domain.Car) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) Home(io.vertigo.app.Home) List(java.util.List) TaskManager(io.vertigo.dynamo.task.TaskManager) SearchManager(io.vertigo.dynamo.search.SearchManager) TaskEngineSelect(io.vertigo.dynamox.task.TaskEngineSelect) Assertion(io.vertigo.lang.Assertion) Domain(io.vertigo.dynamo.domain.metamodel.Domain)

Example 2 with SearchChunk

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();
}
Also used : AbstractSqlSearchLoader(io.vertigo.dynamox.search.AbstractSqlSearchLoader) SearchChunk(io.vertigo.dynamo.search.metamodel.SearchChunk) TaskDefinition(io.vertigo.dynamo.task.metamodel.TaskDefinition) Item(io.vertigo.dynamo.search.data.domain.Item) DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) URI(io.vertigo.dynamo.domain.model.URI) DtObjectUtil(io.vertigo.dynamo.domain.util.DtObjectUtil) VTransactionWritable(io.vertigo.commons.transaction.VTransactionWritable) Domain(io.vertigo.dynamo.domain.metamodel.Domain) Task(io.vertigo.dynamo.task.model.Task) DefinitionSpace(io.vertigo.core.definition.DefinitionSpace) DtList(io.vertigo.dynamo.domain.model.DtList) SearchIndex(io.vertigo.dynamo.search.model.SearchIndex) Collectors(java.util.stream.Collectors) VTransactionManager(io.vertigo.commons.transaction.VTransactionManager) SearchIndexDefinition(io.vertigo.dynamo.search.metamodel.SearchIndexDefinition) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) Home(io.vertigo.app.Home) List(java.util.List) TaskManager(io.vertigo.dynamo.task.TaskManager) SearchManager(io.vertigo.dynamo.search.SearchManager) TaskEngineSelect(io.vertigo.dynamox.task.TaskEngineSelect) Assertion(io.vertigo.lang.Assertion) Domain(io.vertigo.dynamo.domain.metamodel.Domain)

Example 3 with SearchChunk

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);
}
Also used : SearchChunk(io.vertigo.dynamo.search.metamodel.SearchChunk) KeyConcept(io.vertigo.dynamo.domain.model.KeyConcept) ArrayList(java.util.ArrayList) URI(io.vertigo.dynamo.domain.model.URI)

Aggregations

URI (io.vertigo.dynamo.domain.model.URI)3 SearchChunk (io.vertigo.dynamo.search.metamodel.SearchChunk)3 ArrayList (java.util.ArrayList)3 Home (io.vertigo.app.Home)2 VTransactionManager (io.vertigo.commons.transaction.VTransactionManager)2 VTransactionWritable (io.vertigo.commons.transaction.VTransactionWritable)2 DefinitionSpace (io.vertigo.core.definition.DefinitionSpace)2 Domain (io.vertigo.dynamo.domain.metamodel.Domain)2 DtDefinition (io.vertigo.dynamo.domain.metamodel.DtDefinition)2 DtList (io.vertigo.dynamo.domain.model.DtList)2 DtObjectUtil (io.vertigo.dynamo.domain.util.DtObjectUtil)2 SearchManager (io.vertigo.dynamo.search.SearchManager)2 SearchIndexDefinition (io.vertigo.dynamo.search.metamodel.SearchIndexDefinition)2 SearchIndex (io.vertigo.dynamo.search.model.SearchIndex)2 TaskManager (io.vertigo.dynamo.task.TaskManager)2 TaskDefinition (io.vertigo.dynamo.task.metamodel.TaskDefinition)2 Task (io.vertigo.dynamo.task.model.Task)2 AbstractSqlSearchLoader (io.vertigo.dynamox.search.AbstractSqlSearchLoader)2 TaskEngineSelect (io.vertigo.dynamox.task.TaskEngineSelect)2 Assertion (io.vertigo.lang.Assertion)2