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

Implement MatchingStats for SQL mode #3278

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion backend/src/main/java/com/bakdata/conquery/Conquery.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
import jakarta.validation.Validator;

import ch.qos.logback.classic.Level;
import com.bakdata.conquery.commands.*;
import com.bakdata.conquery.commands.DistributedStandaloneCommand;
import com.bakdata.conquery.commands.ManagerNode;
import com.bakdata.conquery.commands.MigrateCommand;
import com.bakdata.conquery.commands.PreprocessorCommand;
import com.bakdata.conquery.commands.RecodeStoreCommand;
import com.bakdata.conquery.commands.ShardCommand;
import com.bakdata.conquery.io.jackson.Jackson;
import com.bakdata.conquery.io.jackson.MutableInjectableValues;
import com.bakdata.conquery.metrics.prometheus.PrometheusBundle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import java.util.Set;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;

import com.bakdata.conquery.ResultHeaders;
import com.bakdata.conquery.io.cps.CPSType;
Expand All @@ -19,9 +22,6 @@
import com.bakdata.conquery.models.types.SemanticType;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonView;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
Expand Down Expand Up @@ -96,15 +96,15 @@ public List<ResultInfo> getResultInfos() {
final List<ResultInfo> resultInfos = new ArrayList<>();
ResultInfo dateInfo = ResultHeaders.datesInfo();

if(getResolvedDateAggregationMode() != DateAggregationMode.NONE){
if (getResolvedDateAggregationMode() != DateAggregationMode.NONE) {
// Add one DateInfo for the whole Query
resultInfos.add(0, dateInfo);
}
int lastIndex = resultInfos.size();

childQueries.forEach(q -> resultInfos.addAll(q.getResultInfos()));

if(!resultInfos.isEmpty()) {
if (!resultInfos.isEmpty()) {
// Remove DateInfo from each childQuery
resultInfos.subList(lastIndex, resultInfos.size())
.removeIf(resultInfo -> resultInfo.getSemantics().contains(new SemanticType.EventDateT()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import java.util.List;
import java.util.Set;
import java.util.function.Consumer;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;

import com.bakdata.conquery.ResultHeaders;
import com.bakdata.conquery.io.cps.CPSType;
Expand All @@ -19,8 +21,6 @@
import com.bakdata.conquery.models.query.resultinfo.ResultInfo;
import com.fasterxml.jackson.annotation.JsonView;
import com.google.common.base.Preconditions;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
Expand Down Expand Up @@ -108,4 +108,4 @@ public CQElement getReusableComponents() {
public RequiredEntities collectRequiredEntities(QueryExecutionContext context) {
return getRoot().collectRequiredEntities(context);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import java.util.Optional;
import java.util.Set;
import java.util.function.Consumer;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;

import com.bakdata.conquery.apiv1.forms.export_form.ExportForm;
import com.bakdata.conquery.apiv1.query.CQElement;
Expand All @@ -32,8 +34,6 @@
import com.bakdata.conquery.util.QueryUtils;
import com.fasterxml.jackson.annotation.JsonView;
import com.google.common.base.Preconditions;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import java.util.Optional;
import java.util.Set;
import java.util.function.Consumer;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;

import com.bakdata.conquery.apiv1.forms.export_form.ExportForm;
import com.bakdata.conquery.apiv1.query.CQElement;
Expand All @@ -32,8 +34,6 @@
import com.bakdata.conquery.util.QueryUtils;
import com.fasterxml.jackson.annotation.JsonView;
import com.google.common.base.Preconditions;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import jakarta.validation.constraints.NotEmpty;

import com.bakdata.conquery.apiv1.query.CQElement;
import com.bakdata.conquery.io.cps.CPSType;
Expand All @@ -34,7 +35,6 @@
import com.fasterxml.jackson.annotation.JsonView;
import com.google.common.collect.Streams;
import io.dropwizard.validation.ValidationMethod;
import jakarta.validation.constraints.NotEmpty;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;

import com.bakdata.conquery.models.common.CDateSet;
import com.bakdata.conquery.models.config.IdColumnConfig;
import com.bakdata.conquery.models.identifiable.mapping.EntityIdMap;
import com.bakdata.conquery.util.DateReader;
import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;

public interface EntityResolver {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import java.util.concurrent.TimeUnit;
import java.util.function.Predicate;
import java.util.zip.GZIPInputStream;
import jakarta.validation.ValidationException;
import jakarta.validation.Validator;

import com.bakdata.conquery.ConqueryConstants;
import com.bakdata.conquery.io.jackson.Jackson;
Expand All @@ -32,8 +34,6 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.jakewharton.byteunits.BinaryByteUnit;
import io.dropwizard.core.setup.Environment;
import jakarta.validation.ValidationException;
import jakarta.validation.Validator;
import lombok.SneakyThrows;
import lombok.experimental.FieldNameConstants;
import lombok.extern.slf4j.Slf4j;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@

import c10n.C10N;
import com.bakdata.conquery.internationalization.ExcelSheetNameC10n;
import com.bakdata.conquery.models.common.CDate;
import com.bakdata.conquery.models.auth.entities.User;
import com.bakdata.conquery.models.config.ExcelConfig;
import com.bakdata.conquery.models.execution.ManagedExecution;
import com.bakdata.conquery.models.i18n.I18n;
import com.bakdata.conquery.models.identifiable.mapping.PrintIdMapper;
import com.bakdata.conquery.models.identifiable.ids.specific.UserId;
import com.bakdata.conquery.models.identifiable.mapping.PrintIdMapper;
import com.bakdata.conquery.models.query.PrintSettings;
import com.bakdata.conquery.models.query.SingleTableResult;
import com.bakdata.conquery.models.query.resultinfo.ResultInfo;
Expand Down Expand Up @@ -54,14 +52,20 @@ public class ExcelRenderer {
private final ExcelConfig config;
private final PrintSettings settings;
private final ImmutableMap<String, CellStyle> styles;

public ExcelRenderer(ExcelConfig config, PrintSettings settings) {
workbook = new SXSSFWorkbook();
this.config = config;
styles = config.generateStyles(workbook, settings);
this.settings = settings;
}

public <E extends ManagedExecution & SingleTableResult> void renderToStream(List<ResultInfo> idHeaders, E exec, OutputStream outputStream, OptionalLong limit, PrintSettings printSettings)
public <E extends ManagedExecution & SingleTableResult> void renderToStream(
List<ResultInfo> idHeaders,
E exec,
OutputStream outputStream,
OptionalLong limit,
PrintSettings printSettings)
throws IOException {
final List<ResultInfo> resultInfosExec = exec.getResultInfos();

Expand Down Expand Up @@ -180,7 +184,8 @@ private int writeBody(
// Row 0 is the Header the data starts at 1
final AtomicInteger currentRow = new AtomicInteger(1);

final TypeWriter[] writers = infos.stream().map(info -> writer(info.getType(), info.createPrinter(printerFactory, settings), settings)).toArray(TypeWriter[]::new);
final TypeWriter[] writers =
infos.stream().map(info -> writer(info.getType(), info.createPrinter(printerFactory, settings), settings)).toArray(TypeWriter[]::new);
final PrintIdMapper idMapper = settings.getIdMapper();

final int writtenLines = resultLines.mapToInt(l -> writeRowsForEntity(infos, l, currentRow, sheet, writers, idMapper)).sum();
Expand Down Expand Up @@ -218,7 +223,13 @@ private void postProcessTable(SXSSFSheet sheet, XSSFTable table, int writtenLine
/**
* Writes the result lines for each entity.
*/
private int writeRowsForEntity(List<ResultInfo> infos, EntityResult internalRow, final AtomicInteger currentRow, SXSSFSheet sheet, TypeWriter[] writers, PrintIdMapper idMapper) {
private int writeRowsForEntity(
List<ResultInfo> infos,
EntityResult internalRow,
final AtomicInteger currentRow,
SXSSFSheet sheet,
TypeWriter[] writers,
PrintIdMapper idMapper) {

final String[] ids = idMapper.map(internalRow).getExternalId();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package com.bakdata.conquery.mode.cluster;

import static com.bakdata.conquery.apiv1.query.concept.specific.external.EntityResolverUtil.collectExtraData;
import static com.bakdata.conquery.apiv1.query.concept.specific.external.EntityResolverUtil.readDates;
import static com.bakdata.conquery.apiv1.query.concept.specific.external.EntityResolverUtil.tryResolveId;
import static com.bakdata.conquery.apiv1.query.concept.specific.external.EntityResolverUtil.verifyOnlySingles;
import static com.bakdata.conquery.apiv1.query.concept.specific.external.EntityResolverUtil.*;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import jakarta.validation.constraints.NotEmpty;

import com.bakdata.conquery.apiv1.query.concept.specific.external.EntityResolver;
import com.bakdata.conquery.apiv1.query.concept.specific.external.EntityResolverUtil;
Expand All @@ -19,7 +17,6 @@
import com.bakdata.conquery.models.identifiable.mapping.ExternalId;
import com.bakdata.conquery.util.DateReader;
import com.bakdata.conquery.util.io.IdColumnUtil;
import jakarta.validation.constraints.NotEmpty;

public class ClusterEntityResolver implements EntityResolver {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.bakdata.conquery.mode.cluster;

import jakarta.validation.Validator;

import com.bakdata.conquery.io.jackson.Jackson;
import com.bakdata.conquery.io.jackson.MutableInjectableValues;
import com.bakdata.conquery.io.jackson.View;
Expand All @@ -12,7 +14,6 @@
import com.fasterxml.jackson.databind.DeserializationConfig;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationConfig;
import jakarta.validation.Validator;

public record InternalMapperFactory(ConqueryConfig config, Validator validator) {

Expand Down
Loading
Loading