All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.datakernel.aggregation.ot.AggregationOT Maven / Gradle / Ivy

Go to download

Log-structured merge-tree table with fields representing aggregate functions, designed for OLAP workload.

There is a newer version: 3.1.0
Show newest version
package io.datakernel.aggregation.ot;

import io.datakernel.ot.OTSystem;
import io.datakernel.ot.OTSystemImpl;
import io.datakernel.ot.TransformResult;
import io.datakernel.ot.TransformResult.ConflictResolution;

import static io.datakernel.util.CollectionUtils.hasIntersection;
import static java.util.Collections.singletonList;

public class AggregationOT {
	public static OTSystem createAggregationOT() {
		return OTSystemImpl.create()
				.withTransformFunction(AggregationDiff.class, AggregationDiff.class, (left, right) -> {
					if (!hasIntersection(left.getAddedChunks(), right.getAddedChunks()) && !hasIntersection(left.getRemovedChunks(), right.getRemovedChunks())) {
						return TransformResult.of(right, left);
					}

					return left.getRemovedChunks().size() > right.getRemovedChunks().size() ?
							TransformResult.conflict(ConflictResolution.LEFT) :
							TransformResult.conflict(ConflictResolution.RIGHT);
				})
				.withInvertFunction(AggregationDiff.class, op -> singletonList(op.inverse()))
				.withEmptyPredicate(AggregationDiff.class, AggregationDiff::isEmpty)
				.withSquashFunction(AggregationDiff.class, AggregationDiff.class, AggregationDiff::squash);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy