Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reintegrate master #2657

Merged
merged 11 commits into from
Aug 8, 2022
50 changes: 50 additions & 0 deletions .github/workflows/create_backend_image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Create and publish a backend image

on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+-[0-9]+KW[0-9][0-9]"
- "v[0-9]+.[0-9]+.[0-9]+-[0-9]+KW[0-9][0-9]-HOTFIX-*"
- "!v[0-9]+.[0-9]+.[0-9]+-[0-9]+KW[0-9][0-9]-RC*" # Don't release RCs

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}-backend

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: type=semver,pattern={{version}}

- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
50 changes: 50 additions & 0 deletions .github/workflows/create_frontend_image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Create and publish a frontend image

on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+-[0-9]+KW[0-9][0-9]"
- "v[0-9]+.[0-9]+.[0-9]+-[0-9]+KW[0-9][0-9]-HOTFIX-*"
- "!v[0-9]+.[0-9]+.[0-9]+-[0-9]+KW[0-9][0-9]-RC*" # Don't release RCs

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}-frontend

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: type=semver,pattern={{version}}

- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: ./frontend
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Original file line number Diff line number Diff line change
Expand Up @@ -68,36 +68,31 @@ public class ConceptsProcessor {
private final DatasetRegistry namespaces;
private final Validator validator;

private final LoadingCache<Concept<?>, FEList> nodeCache =
CacheBuilder.newBuilder()
.softValues()
.expireAfterWrite(10, TimeUnit.MINUTES)
.build(new CacheLoader<>() {
@Override
public FEList load(Concept<?> concept) {
return FrontEndConceptBuilder.createTreeMap(concept);
}
});
private final LoadingCache<Concept<?>, FEList>
nodeCache =
CacheBuilder.newBuilder().softValues().expireAfterWrite(10, TimeUnit.MINUTES).build(new CacheLoader<>() {
@Override
public FEList load(Concept<?> concept) {
return FrontEndConceptBuilder.createTreeMap(concept);
}
});

/**
* Cache of all search results on SelectFilters.
*/
private final LoadingCache<Pair<SelectFilter<?>, String>, List<FEValue>> searchResults =
CacheBuilder.newBuilder()
.softValues()
.build(new CacheLoader<>() {
private final LoadingCache<Pair<SelectFilter<?>, String>, List<FEValue>> searchResults = CacheBuilder.newBuilder().softValues().build(new CacheLoader<>() {

@Override
public List<FEValue> load(Pair<SelectFilter<?>, String> filterAndSearch) {
String searchTerm = filterAndSearch.getValue();
SelectFilter<?> filter = filterAndSearch.getKey();
@Override
public List<FEValue> load(Pair<SelectFilter<?>, String> filterAndSearch) {
String searchTerm = filterAndSearch.getValue();
SelectFilter<?> filter = filterAndSearch.getKey();

log.trace("Calculating a new search cache for the term \"{}\" on filter[{}]", searchTerm, filter.getId());
log.trace("Calculating a new search cache for the term \"{}\" on filter[{}]", searchTerm, filter.getId());

return autocompleteTextFilter(filter, searchTerm);
}
return autocompleteTextFilter(filter, searchTerm);
}

});
});

/**
* Container class to pair number of available values and Cursor for those values.
Expand All @@ -112,17 +107,14 @@ private static class CursorAndLength {
* Cache of raw listing of values on a filter.
* We use Cursor here to reduce strain on memory and increase response time.
*/
private final LoadingCache<SelectFilter<?>, CursorAndLength> listResults =
CacheBuilder.newBuilder()
.softValues()
.build(new CacheLoader<>() {
@Override
public CursorAndLength load(SelectFilter<?> filter) {
log.debug("Creating cursor for `{}`", filter.getId());
return new CursorAndLength(listAllValues(filter), countAllValues(filter));
}
private final LoadingCache<SelectFilter<?>, CursorAndLength> listResults = CacheBuilder.newBuilder().softValues().build(new CacheLoader<>() {
@Override
public CursorAndLength load(SelectFilter<?> filter) {
log.debug("Creating cursor for `{}`", filter.getId());
return new CursorAndLength(listAllValues(filter), countAllValues(filter));
}

});
});


public FERoot getRoot(NamespaceStorage storage, Subject subject) {
Expand All @@ -148,14 +140,16 @@ public List<IdLabel<DatasetId>> getDatasets(Subject subject) {
return namespaces.getAllDatasets()
.stream()
.filter(d -> subject.isPermitted(d, Ability.READ))
.sorted(Comparator.comparing(Dataset::getWeight)
.thenComparing(Dataset::getLabel))
.sorted(Comparator.comparing(Dataset::getWeight).thenComparing(Dataset::getLabel))
.map(d -> new IdLabel<>(d.getId(), d.getLabel()))
.collect(Collectors.toList());
}

public Stream<ConnectorId> getEntityPreviewDefaultConnectors(Dataset dataset) {
return namespaces.get(dataset.getId()).getStorage().getAllConcepts().stream()
return namespaces.get(dataset.getId())
.getStorage()
.getAllConcepts()
.stream()
.map(Concept::getConnectors)
.flatMap(Collection::stream)
.filter(Connector::isDefaultForEntityPreview)
Expand Down Expand Up @@ -190,15 +184,7 @@ public ResolvedConceptsResult resolveFilterValues(SelectFilter<?> filter, List<S
}
}

return new ResolvedConceptsResult(
null,
new ResolvedFilterResult(
filter.getConnector().getId(),
filter.getId(),
out
),
openSearchTerms
);
return new ResolvedConceptsResult(null, new ResolvedFilterResult(filter.getConnector().getId(), filter.getId(), out), openSearchTerms);
}

@Data
Expand Down Expand Up @@ -255,11 +241,9 @@ private Cursor<FEValue> listAllValues(SelectFilter<?> filter) {
See: https://stackoverflow.com/questions/61114380/java-streams-buffering-huge-streams
*/

final Iterator<FEValue> iterators =
Iterators.concat(Iterators.transform(
namespace.getFilterSearch().getSearchesFor(filter).iterator(),
TrieSearch::iterator
));
final Iterator<FEValue>
iterators =
Iterators.concat(Iterators.transform(namespace.getFilterSearch().getSearchesFor(filter).iterator(), TrieSearch::iterator));

// Use Set to accomplish distinct values
final Set<FEValue> seen = new HashSet<>();
Expand All @@ -286,12 +270,10 @@ private List<FEValue> autocompleteTextFilter(SelectFilter<?> filter, String text
// they are already sorted in terms of information weight by getSearchesFor

// Also note: currently we are still issuing large search requests, but much smaller allocations at once, and querying only when the past is not sufficient
return namespace.getFilterSearch().getSearchesFor(filter).stream()
.map(search -> createSourceSearchResult(
search,
Collections.singletonList(text),
OptionalInt.empty()
))
return namespace.getFilterSearch()
.getSearchesFor(filter)
.stream()
.map(search -> createSourceSearchResult(search, Collections.singletonList(text), OptionalInt.empty()))
.flatMap(Collection::stream)
.distinct()
.collect(Collectors.toList());
Expand Down
16 changes: 8 additions & 8 deletions docs/REST API JSONs.md
Original file line number Diff line number Diff line change
Expand Up @@ -1297,7 +1297,7 @@ Supported Fields:
| [✎](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/apiv1/ExecutionStatus.java#L25) | tags | list of `String` | `null` | | |
</p></details>

### Type ResolvedConceptsResult<sup><sub><sup> [✎](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/resources/api/ConceptsProcessor.java#L354)</sup></sub></sup>
### Type ResolvedConceptsResult<sup><sub><sup> [✎](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/resources/api/ConceptsProcessor.java#L336)</sup></sub></sup>


<details><summary>Details</summary><p>
Expand All @@ -1308,12 +1308,12 @@ Supported Fields:

| | Field | Type | Default | Example | Description |
| --- | --- | --- | --- | --- | --- |
| [✎](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/resources/api/ConceptsProcessor.java#L359) | resolvedConcepts | `Set<ConceptElementId<?>>` | ? | | |
| [✎](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/resources/api/ConceptsProcessor.java#L360) | resolvedFilter | [ResolvedFilterResult](#Type-ResolvedFilterResult) | ? | | |
| [✎](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/resources/api/ConceptsProcessor.java#L361) | unknownCodes | `Collection<String>` | ? | | |
| [✎](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/resources/api/ConceptsProcessor.java#L341) | resolvedConcepts | `Set<ConceptElementId<?>>` | ? | | |
| [✎](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/resources/api/ConceptsProcessor.java#L342) | resolvedFilter | [ResolvedFilterResult](#Type-ResolvedFilterResult) | ? | | |
| [✎](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/resources/api/ConceptsProcessor.java#L343) | unknownCodes | `Collection<String>` | ? | | |
</p></details>

### Type ResolvedFilterResult<sup><sub><sup> [✎](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/resources/api/ConceptsProcessor.java#L344)</sup></sub></sup>
### Type ResolvedFilterResult<sup><sub><sup> [✎](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/resources/api/ConceptsProcessor.java#L326)</sup></sub></sup>


<details><summary>Details</summary><p>
Expand All @@ -1324,9 +1324,9 @@ Supported Fields:

| | Field | Type | Default | Example | Description |
| --- | --- | --- | --- | --- | --- |
| [✎](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/resources/api/ConceptsProcessor.java#L350) | filterId | ID of `Filter` | ? | | |
| [✎](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/resources/api/ConceptsProcessor.java#L349) | tableId | ID of `Connector` | ? | | |
| [✎](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/resources/api/ConceptsProcessor.java#L351) | value | `Collection<FEValue>` | ? | | |
| [✎](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/resources/api/ConceptsProcessor.java#L332) | filterId | ID of `Filter` | ? | | |
| [✎](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/resources/api/ConceptsProcessor.java#L331) | tableId | ID of `Connector` | ? | | |
| [✎](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/resources/api/ConceptsProcessor.java#L333) | value | `Collection<FEValue>` | ? | | |
</p></details>

### Type ValidityDateContainer<sup><sub><sup> [✎](https://github.com/bakdata/conquery/edit/develop/backend/src/main/java/com/bakdata/conquery/apiv1/query/concept/filter/ValidityDateContainer.java#L9)</sup></sub></sup>
Expand Down