use of com.bakdata.conquery.models.common.CDateSet in project conquery by bakdata.
the class CountQuartersOfDateRangeAggregator method acceptEvent.
@Override
public void acceptEvent(Bucket bucket, int event) {
if (!bucket.has(event, getColumn())) {
return;
}
final CDateSet set = CDateSet.create(bucket.getDateRange(event, getColumn()));
set.retainAll(dateRestriction);
for (CDateRange subRange : set.asRanges()) {
// we can sensibly only look at real quarters.
if (subRange.isOpen()) {
continue;
}
addDateRange(subRange);
}
}
use of com.bakdata.conquery.models.common.CDateSet in project conquery by bakdata.
the class DateRestrictingNode method nextTable.
@Override
public void nextTable(QueryExecutionContext ctx, Table currentTable) {
// if there was no date restriction we can just use the restriction CDateSet
if (ctx.getDateRestriction().isAll()) {
ctx = ctx.withDateRestriction(CDateSet.create(restriction));
} else {
CDateSet dateRestriction = CDateSet.create(ctx.getDateRestriction());
dateRestriction.retainAll(restriction);
ctx = ctx.withDateRestriction(dateRestriction);
}
super.nextTable(ctx, currentTable);
preCurrentRow = ctx.getBucketManager().getEntityCBlocksForConnector(getEntity(), context.getConnector());
validityDateColumn = context.getValidityDateColumn();
if (validityDateColumn != null && !validityDateColumn.getType().isDateCompatible()) {
throw new IllegalStateException("The validityDateColumn " + validityDateColumn + " is not a DATE TYPE");
}
}
use of com.bakdata.conquery.models.common.CDateSet in project conquery by bakdata.
the class DateAggregator method createAggregationResult.
@Override
public CDateSet createAggregationResult() {
final Set<CDateSet> all = new HashSet<>();
children.forEach(s -> {
CDateSet result = s.createAggregationResult();
if (result != null) {
all.add(result);
}
});
// Repackage to get the results sorted. Might need some optimization.
return action.aggregate(all);
}
use of com.bakdata.conquery.models.common.CDateSet in project conquery by bakdata.
the class DateReader method parseToCDateSet.
/**
* Try and parse value to CDateSet using all available layouts, but starting at the last known successful one.
*/
public CDateSet parseToCDateSet(String value) {
if (Strings.isNullOrEmpty(value)) {
return null;
}
final int root = lastDateSetLayoutIndex.get();
for (int offset = 0; offset < dateSetLayouts.size(); offset++) {
final int index = (root + offset) % dateSetLayouts.size();
final LocaleConfig.ListFormat sep = dateSetLayouts.get(index);
try {
final CDateSet result = sep.parse(value, this);
lastDateSetLayoutIndex.set(index);
return result;
} catch (ParsingException e) {
log.trace("Parsing failed for date set '{}' with pattern '{}'", value, sep, e);
}
}
throw new ParsingException("None of the configured formats to parse the date set: " + value);
}
use of com.bakdata.conquery.models.common.CDateSet in project conquery by bakdata.
the class TemporalQueryNode method isContained.
/**
* Retrieves the {@link ConceptQueryPlan#getDateAggregator()} time of {@link #reference} and {@link #preceding}.
* Then tests whether they match the specific criteria for inclusion.
* If the criteria are met, the matching {@link CDateSet} is put into the @{@link SpecialDateUnion} node of the Queries associated QueryPlan.
*
* @return true, iff the Events match the specific criteria.
*/
@Override
public final boolean isContained() {
if (!reference.isContained()) {
return false;
}
CDateSet referenceDurations = dateAggregationAction.aggregate(getReference().getDateAggregators().stream().map(Aggregator::createAggregationResult).collect(Collectors.toSet()));
// Create copy as we are mutating the set
CDateSet precedingDurations = dateAggregationAction.aggregate(getPreceding().getDateAggregators().stream().map(Aggregator::createAggregationResult).collect(Collectors.toSet()));
OptionalInt sampledReference = getReferenceSampler().sample(referenceDurations);
if (sampledReference.isEmpty()) {
return false;
}
matcher.removePreceding(precedingDurations, sampledReference.getAsInt());
OptionalInt sampledPreceding = getPrecedingSampler().sample(precedingDurations);
if (matcher.isContained(sampledReference, sampledPreceding)) {
dateUnion.merge(referenceDurations);
return true;
}
return false;
}
Aggregations