-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3396 from ingef/reintegrate-master
Reintegrate master
- Loading branch information
Showing
22 changed files
with
361 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
backend/src/main/java/com/bakdata/conquery/apiv1/LabelMap.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package com.bakdata.conquery.apiv1; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import com.bakdata.conquery.apiv1.frontend.FrontendValue; | ||
import com.bakdata.conquery.models.config.IndexConfig; | ||
import com.bakdata.conquery.models.datasets.concepts.Searchable; | ||
import com.bakdata.conquery.models.identifiable.ids.specific.FilterId; | ||
import com.bakdata.conquery.models.query.FilterSearch; | ||
import com.bakdata.conquery.util.search.TrieSearch; | ||
import com.google.common.collect.BiMap; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.experimental.Delegate; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.apache.commons.lang3.time.StopWatch; | ||
|
||
@Getter | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
@EqualsAndHashCode | ||
public class LabelMap implements Searchable { | ||
|
||
private final FilterId id; | ||
@Delegate | ||
private final BiMap<String, String> delegate; | ||
private final int minSuffixLength; | ||
private final boolean generateSearchSuffixes; | ||
|
||
@Override | ||
public TrieSearch<FrontendValue> createTrieSearch(IndexConfig config) { | ||
|
||
final TrieSearch<FrontendValue> search = config.createTrieSearch(true); | ||
|
||
final List<FrontendValue> collected = delegate.entrySet().stream() | ||
.map(entry -> new FrontendValue(entry.getKey(), entry.getValue())) | ||
.collect(Collectors.toList()); | ||
|
||
if (log.isTraceEnabled()) { | ||
log.trace("Labels for {}: `{}`", getId(), collected.stream().map(FrontendValue::toString).collect(Collectors.toList())); | ||
} | ||
|
||
StopWatch timer = StopWatch.createStarted(); | ||
log.trace("START-SELECT ADDING_ITEMS for {}", getId()); | ||
|
||
collected.forEach(feValue -> search.addItem(feValue, FilterSearch.extractKeywords(feValue))); | ||
|
||
log.trace("DONE-SELECT ADDING_ITEMS for {} in {}", getId(), timer); | ||
|
||
timer.reset(); | ||
log.trace("START-SELECT SHRINKING for {}", getId()); | ||
|
||
search.shrinkToFit(); | ||
|
||
log.trace("DONE-SELECT SHRINKING for {} in {}", getId(), timer); | ||
|
||
return search; | ||
} | ||
|
||
@Override | ||
public boolean isGenerateSuffixes() { | ||
return generateSearchSuffixes; | ||
} | ||
|
||
@Override | ||
public boolean isSearchDisabled() { | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.