use of io.vertigo.dynamo.search.metamodel.SearchIndexDefinition in project vertigo by KleeGroup.
the class CarSearchLoader method loadNextURI.
/**
* {@inheritDoc}
*/
@Override
protected List<URI<Car>> loadNextURI(final Long lastId, final DtDefinition dtDefinition) {
final SearchIndexDefinition indexDefinition = searchManager.findFirstIndexDefinitionByKeyConcept(Car.class);
final List<URI<Car>> uris = new ArrayList<>(SEARCH_CHUNK_SIZE);
// call loader service
int i = 0;
for (final Car car : carDataBase.getAllCars()) {
if (i > lastId) {
uris.add(new URI(indexDefinition.getKeyConceptDtDefinition(), car.getId()));
}
if (uris.size() >= SEARCH_CHUNK_SIZE) {
break;
}
i++;
}
return uris;
}
use of io.vertigo.dynamo.search.metamodel.SearchIndexDefinition in project vertigo by KleeGroup.
the class CarSearchLoader method loadData.
/**
* {@inheritDoc}
*/
@Override
public List<SearchIndex<Car, Car>> loadData(final SearchChunk<Car> searchChunk) {
Assertion.checkNotNull(carDataBase, "carDataBase not bound");
// -----
final SearchIndexDefinition indexDefinition = searchManager.findFirstIndexDefinitionByKeyConcept(Car.class);
final List<SearchIndex<Car, Car>> carIndexes = new ArrayList<>();
final Map<Long, Car> carPerId = new HashMap<>();
for (final Car car : carDataBase.getAllCars()) {
carPerId.put(car.getId(), car);
}
for (final URI<Car> uri : searchChunk.getAllURIs()) {
final Car car = carPerId.get(uri.getId());
carIndexes.add(SearchIndex.createIndex(indexDefinition, uri, car));
}
return carIndexes;
}
use of io.vertigo.dynamo.search.metamodel.SearchIndexDefinition in project vertigo by KleeGroup.
the class SearchManagerMultiIndexTest method testClean.
/**
* Test de création nettoyage de l'index.
* La création s'effectue dans une seule transaction.
*/
@Test
public void testClean() {
final DefinitionSpace definitionSpace = getApp().getDefinitionSpace();
final SearchIndexDefinition carIndexDefinition = definitionSpace.resolve(IDX_CAR, SearchIndexDefinition.class);
final SearchIndexDefinition carDynIndexDefinition = definitionSpace.resolve(IDX_DYNA_CAR, SearchIndexDefinition.class);
final ListFilter removeQuery = ListFilter.of("*:*");
searchManager.removeAll(carIndexDefinition, removeQuery);
searchManager.removeAll(carDynIndexDefinition, removeQuery);
waitIndexation();
final long sizeCar = query("*:*", carIndexDefinition);
Assert.assertEquals(0, sizeCar);
final long sizeCarDyn = query("*:*", carDynIndexDefinition);
Assert.assertEquals(0, sizeCarDyn);
}
use of io.vertigo.dynamo.search.metamodel.SearchIndexDefinition in project vertigo by KleeGroup.
the class SearchManagerImpl method start.
/**
* {@inheritDoc}
*/
@Override
public void start() {
for (final SearchIndexDefinition indexDefinition : Home.getApp().getDefinitionSpace().getAll(SearchIndexDefinition.class)) {
final List<URI<? extends KeyConcept>> dirtyElements = new ArrayList<>();
dirtyElementsPerIndexName.put(indexDefinition.getName(), dirtyElements);
// on dépile les dirtyElements toutes les 1 secondes
executorService.scheduleWithFixedDelay(new ReindexTask(indexDefinition, dirtyElements, this), 1, 1, TimeUnit.SECONDS);
}
}
use of io.vertigo.dynamo.search.metamodel.SearchIndexDefinition in project vertigo by KleeGroup.
the class ItemSearchLoader method loadNextURI.
/**
* {@inheritDoc}
*/
@Override
protected List<URI<Item>> loadNextURI(final Long lastId, final DtDefinition dtDefinition) {
final SearchIndexDefinition indexDefinition = searchManager.findFirstIndexDefinitionByKeyConcept(Item.class);
final List<URI<Item>> uris = new ArrayList<>(SEARCH_CHUNK_SIZE);
// call loader service
int i = 0;
for (final Item item : itemDataBase.getAllItems()) {
if (i > lastId) {
uris.add(new URI(indexDefinition.getKeyConceptDtDefinition(), item.getId()));
}
if (uris.size() >= SEARCH_CHUNK_SIZE) {
break;
}
i++;
}
return uris;
}
Aggregations