Skip to content

Commit b573dcf

Browse files
dbulahovstbischof
authored andcommitted
create olap modules - common
Signed-off-by: dbulahov <bulahovdenis@gmail.com>
1 parent 4a329a7 commit b573dcf

File tree

1,230 files changed

+92241
-8
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,230 files changed

+92241
-8
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright (c) 2025 Contributors to the Eclipse Foundation.
3+
*
4+
* This program and the accompanying materials are made
5+
* available under the terms of the Eclipse Public License 2.0
6+
* which is available at https://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
* SmartCity Jena, Stefan Bischof - initial
12+
*
13+
*/
14+
package org.eclipse.daanse.olap.api;
15+
16+
public interface CacheCommand<T> extends Message {
17+
18+
Locus getLocus();
19+
20+
T call() throws Exception;
21+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright (c) 2025 Contributors to the Eclipse Foundation.
3+
*
4+
* This program and the accompanying materials are made
5+
* available under the terms of the Eclipse Public License 2.0
6+
* which is available at https://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
* SmartCity Jena, Stefan Bischof - initial
12+
*
13+
*/
14+
package org.eclipse.daanse.olap.api;
15+
16+
public interface ISegmentCacheIndex {
17+
18+
void cancelExecutionSegments(Execution executionImpl);
19+
20+
}

api/src/main/java/org/eclipse/daanse/olap/api/ISegmentCacheManager.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ public interface ISegmentCacheManager {
2727

2828
void printCacheState(CellRegion region, PrintWriter pw, Locus locus);
2929

30+
<T> T execute( CacheCommand<T> command );
3031

32+
ISegmentCacheIndex getIndexRegistry();
3133

3234
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Copyright (c) 2025 Contributors to the Eclipse Foundation.
3+
*
4+
* This program and the accompanying materials are made
5+
* available under the terms of the Eclipse Public License 2.0
6+
* which is available at https://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
* SmartCity Jena, Stefan Bischof - initial
12+
*
13+
*/
14+
package org.eclipse.daanse.olap.api;
15+
16+
public interface Message {
17+
18+
}

api/src/main/java/org/eclipse/daanse/olap/api/calc/Calc.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ public interface Calc<E> {
8989
* depends on all dimensions except [Measures].
9090
*
9191
* The boolean expression
92-
* <blockquote>([Measures].[Unit Sales],
93-
* [Time].[1997]) &gt; 1000</blockquote>
92+
* ([Measures].[Unit Sales],
93+
* [Time].[1997]) &gt; 1000
9494
* depends on all hierarchies except [Measures] and [Time].
9595
*
9696
* The list expression

api/src/main/java/org/eclipse/daanse/olap/api/result/AllocationPolicy.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,33 +49,33 @@ public enum AllocationPolicy {
4949
* Every atomic cell that contributes to the updated cell will be
5050
* assigned an equal value that is:
5151
*
52-
* <blockquote>
52+
*
5353
* &lt;atomic cell value&gt; =
5454
* &lt;value&gt; / Count(atomic cells contained in &lt;tuple&gt;)
55-
* </blockquote>
55+
*
5656
*/
5757
EQUAL_ALLOCATION,
5858

5959
/**
6060
* Every atomic cell that contributes to the updated cell will be
6161
* changed according to:
6262
*
63-
* <blockquote>
63+
*
6464
* &lt;atomic cell value&gt; = &lt;atomic cell value&gt; +
6565
* (&lt;value&gt; - &lt;existing value&gt;) /
6666
* Count(atomic cells contained in &lt;tuple&gt;)
67-
* </blockquote>
67+
*
6868
*/
6969
EQUAL_INCREMENT,
7070

7171
/**
7272
* Every atomic cell that contributes to the updated cell will be
7373
* assigned an equal value that is:
7474
*
75-
* <blockquote>
75+
*
7676
* &lt;atomic cell value&gt; =
7777
* &lt;value&gt; * &lt;weight value expression&gt;
78-
* </blockquote>
78+
*
7979
*
8080
* Takes an optional argument, {@code weight_value_expression}.
8181
* If {@code weight_value_expression} is not provided, the following

common/pom.xml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/*********************************************************************
4+
* Copyright (c) 2024 Contributors to the Eclipse Foundation.
5+
*
6+
* This program and the accompanying materials are made
7+
* available under the terms of the Eclipse Public License 2.0
8+
* which is available at https://www.eclipse.org/legal/epl-2.0/
9+
*
10+
* SPDX-License-Identifier: EPL-2.0
11+
**********************************************************************/
12+
-->
13+
<project xmlns="http://maven.apache.org/POM/4.0.0"
14+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
15+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
16+
<modelVersion>4.0.0</modelVersion>
17+
<parent>
18+
<groupId>org.eclipse.daanse</groupId>
19+
<artifactId>org.eclipse.daanse.olap</artifactId>
20+
<version>${revision}</version>
21+
</parent>
22+
<artifactId>org.eclipse.daanse.olap.common</artifactId>
23+
<packaging>jar</packaging>
24+
25+
<dependencies>
26+
<dependency>
27+
<groupId>org.osgi</groupId>
28+
<artifactId>org.osgi.service.metatype.annotations</artifactId>
29+
<scope>compile</scope>
30+
</dependency>
31+
<dependency>
32+
<groupId>org.osgi</groupId>
33+
<artifactId>org.osgi.namespace.unresolvable</artifactId>
34+
<scope>compile</scope>
35+
</dependency>
36+
<dependency>
37+
<groupId>biz.aQute.bnd</groupId>
38+
<artifactId>biz.aQute.bndlib</artifactId>
39+
<version>${bnd.version}</version>
40+
</dependency>
41+
<dependency>
42+
<groupId>com.github.ben-manes.caffeine</groupId>
43+
<artifactId>caffeine</artifactId>
44+
<version>${caffeine.version}</version>
45+
</dependency>
46+
<dependency>
47+
<groupId>org.osgi</groupId>
48+
<artifactId>org.osgi.service.metatype.annotations</artifactId>
49+
<scope>compile</scope>
50+
</dependency>
51+
<dependency>
52+
<groupId>org.eclipse.daanse</groupId>
53+
<artifactId>org.eclipse.daanse.olap.api</artifactId>
54+
<version>0.0.1-SNAPSHOT</version>
55+
</dependency>
56+
<dependency>
57+
<groupId>org.eclipse.daanse</groupId>
58+
<artifactId>org.eclipse.daanse.olap.action.api</artifactId>
59+
<version>0.0.1-SNAPSHOT</version>
60+
</dependency>
61+
</dependencies>
62+
</project>
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
/*
2+
* Copyright (c) 2023 Contributors to the Eclipse Foundation.
3+
*
4+
* This program and the accompanying materials are made
5+
* available under the terms of the Eclipse Public License 2.0
6+
* which is available at https://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
* SmartCity Jena - initial
12+
* Stefan Bischof (bipolis.org) - initial
13+
*/
14+
package org.eclipse.daanse.olap.calc.base;
15+
16+
import java.time.Instant;
17+
import java.util.ArrayList;
18+
import java.util.HashMap;
19+
import java.util.List;
20+
import java.util.Map;
21+
import java.util.Optional;
22+
23+
import org.eclipse.daanse.olap.api.Evaluator;
24+
import org.eclipse.daanse.olap.api.calc.profile.CalcEvaluationProfile;
25+
import org.eclipse.daanse.olap.api.calc.profile.CalculationProfile;
26+
import org.eclipse.daanse.olap.api.calc.profile.ProfilingCalc;
27+
import org.eclipse.daanse.olap.api.type.Type;
28+
import org.eclipse.daanse.olap.calc.base.profile.CalcEvaluationProfileR;
29+
import org.eclipse.daanse.olap.calc.base.profile.CalcProfileR;
30+
31+
public abstract class AbstractProfilingCalc<T> implements ProfilingCalc<T> {
32+
33+
private Type type;
34+
35+
private Instant firstEvalStart = null;
36+
private Instant lastEvalEnd = null;
37+
38+
private final List<CalcEvaluationProfile> evaluations = new ArrayList<CalcEvaluationProfile>();
39+
40+
/**
41+
* Abstract Implementation of {@link ProfilingCalc} that generated a
42+
* {@link CalculationProfile} while calling
43+
* evaluateWithProfile(Evaluator)
44+
*
45+
* @param type type
46+
*/
47+
public AbstractProfilingCalc(Type type) {
48+
this.type = type;
49+
}
50+
51+
@Override
52+
public T evaluateWithProfile(Evaluator evaluator) {
53+
Instant startEval = Instant.now();
54+
if (firstEvalStart == null) {
55+
firstEvalStart = startEval;
56+
}
57+
final T evalResult = evaluate(evaluator);
58+
59+
Instant endEval = Instant.now();
60+
lastEvalEnd = endEval;
61+
62+
profileEvaluation(startEval, endEval, evalResult);
63+
return evalResult;
64+
}
65+
66+
protected void profileEvaluation(Instant evaluationStart, Instant evaluationEnd, T evaluationResult) {
67+
68+
CalcEvaluationProfile evaluationProfile = new CalcEvaluationProfileR(evaluationStart, evaluationEnd,
69+
evaluationResult, Map.of());
70+
evaluations.add(evaluationProfile);
71+
72+
}
73+
74+
protected Map<String, Object> profilingProperties(Map<String, Object> properties) {
75+
return properties;
76+
}
77+
78+
public CalculationProfile getCalculationProfile() {
79+
final List<CalculationProfile> childProfiles = getChildProfiles();
80+
Map<String, Object> profilingProperties = profilingProperties(new HashMap<String, Object>());
81+
return new CalcProfileR(this.getClass(), getType(), getResultStyle(), Optional.ofNullable(firstEvalStart),
82+
Optional.ofNullable(lastEvalEnd), profilingProperties, evaluations, childProfiles);
83+
}
84+
85+
List<CalculationProfile> getChildProfiles() {
86+
return List.of();
87+
}
88+
89+
@Override
90+
public Type getType() {
91+
return type;
92+
}
93+
94+
protected void requiresType(Class<? extends Type> typeClass) {
95+
Type type = getType();
96+
if (!typeClass.isInstance(type)) {
97+
throw new RuntimeException("Expecting Type " + typeClass + " but was " + type);
98+
}
99+
100+
}
101+
102+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright (c) 2023 Contributors to the Eclipse Foundation.
3+
*
4+
* This program and the accompanying materials are made
5+
* available under the terms of the Eclipse Public License 2.0
6+
* which is available at https://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
* SmartCity Jena - initial
12+
* Stefan Bischof (bipolis.org) - initial
13+
*/
14+
package org.eclipse.daanse.olap.calc.base;
15+
16+
import java.util.List;
17+
18+
import org.eclipse.daanse.olap.api.Evaluator;
19+
import org.eclipse.daanse.olap.api.calc.ConstantCalc;
20+
import org.eclipse.daanse.olap.api.calc.ResultStyle;
21+
import org.eclipse.daanse.olap.api.calc.profile.CalculationProfile;
22+
import org.eclipse.daanse.olap.api.element.Hierarchy;
23+
import org.eclipse.daanse.olap.api.type.Type;
24+
25+
public abstract class AbstractProfilingConstantCalc<T> extends AbstractProfilingCalc<T> implements ConstantCalc<T> {
26+
27+
private T value;
28+
29+
public AbstractProfilingConstantCalc(T value, Type type) {
30+
super(type);
31+
this.value = value;
32+
}
33+
34+
@Override
35+
public T evaluate(Evaluator evaluator) {
36+
return value;
37+
}
38+
39+
@Override
40+
public boolean dependsOn(Hierarchy hierarchy) {
41+
return false;
42+
}
43+
44+
@Override
45+
public ResultStyle getResultStyle() {
46+
return value == null ? ResultStyle.VALUE : ResultStyle.VALUE_NOT_NULL;
47+
}
48+
49+
@Override
50+
List<CalculationProfile> getChildProfiles() {
51+
return List.of();
52+
}
53+
54+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright (c) 2023 Contributors to the Eclipse Foundation.
3+
*
4+
* This program and the accompanying materials are made
5+
* available under the terms of the Eclipse Public License 2.0
6+
* which is available at https://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
* SmartCity Jena - initial
12+
* Stefan Bischof (bipolis.org) - initial
13+
*/
14+
15+
package org.eclipse.daanse.olap.calc.base;
16+
17+
import java.time.Instant;
18+
import java.util.Collection;
19+
import java.util.Map;
20+
21+
import org.eclipse.daanse.olap.api.type.Type;
22+
23+
public abstract class AbstractProfilingIteratorCalc<T> extends AbstractProfilingCalc<T> {
24+
25+
public AbstractProfilingIteratorCalc(Type type) {
26+
super(type);
27+
}
28+
29+
private long elementCount;
30+
private long elementSquaredCount;
31+
32+
@Override
33+
protected void profileEvaluation(Instant evaluationStart, Instant evaluationEnd, T evaluationResult) {
34+
super.profileEvaluation(evaluationStart, evaluationEnd, evaluationResult);
35+
if (evaluationResult instanceof Collection c) {
36+
long size = c.size();
37+
elementCount += size;
38+
elementSquaredCount += size * size;
39+
}
40+
}
41+
42+
@Override
43+
protected Map<String, Object> profilingProperties(Map<String, Object> properties) {
44+
45+
// TODO: may be removed writer can calculate its won because has access to the
46+
// objects
47+
properties.put("elementCount", elementCount);
48+
properties.put("elementSquaredCount", elementSquaredCount);
49+
return properties;
50+
}
51+
52+
}

0 commit comments

Comments
 (0)