Skip to content

Commit 1ea143f

Browse files
committed
create olap modules - common
Signed-off-by: dbulahov <[email protected]>
1 parent 4a329a7 commit 1ea143f

File tree

1,228 files changed

+92242
-0
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,228 files changed

+92242
-0
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+
}

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: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
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+
* {@link #evaluateWithProfile(Evaluator)))
44+
*
45+
* @param Type
46+
* @param name
47+
*/
48+
public AbstractProfilingCalc(Type type) {
49+
this.type = type;
50+
}
51+
52+
@Override
53+
public T evaluateWithProfile(Evaluator evaluator) {
54+
Instant startEval = Instant.now();
55+
if (firstEvalStart == null) {
56+
firstEvalStart = startEval;
57+
}
58+
final T evalResult = evaluate(evaluator);
59+
60+
Instant endEval = Instant.now();
61+
lastEvalEnd = endEval;
62+
63+
profileEvaluation(startEval, endEval, evalResult);
64+
return evalResult;
65+
}
66+
67+
protected void profileEvaluation(Instant evaluationStart, Instant evaluationEnd, T evaluationResult) {
68+
69+
CalcEvaluationProfile evaluationProfile = new CalcEvaluationProfileR(evaluationStart, evaluationEnd,
70+
evaluationResult, Map.of());
71+
evaluations.add(evaluationProfile);
72+
73+
}
74+
75+
protected Map<String, Object> profilingProperties(Map<String, Object> properties) {
76+
return properties;
77+
}
78+
79+
public CalculationProfile getCalculationProfile() {
80+
final List<CalculationProfile> childProfiles = getChildProfiles();
81+
Map<String, Object> profilingProperties = profilingProperties(new HashMap<String, Object>());
82+
return new CalcProfileR(this.getClass(), getType(), getResultStyle(), Optional.ofNullable(firstEvalStart),
83+
Optional.ofNullable(lastEvalEnd), profilingProperties, evaluations, childProfiles);
84+
}
85+
86+
List<CalculationProfile> getChildProfiles() {
87+
return List.of();
88+
}
89+
90+
@Override
91+
public Type getType() {
92+
return type;
93+
}
94+
95+
protected void requiresType(Class<? extends Type> typeClass) {
96+
Type type = getType();
97+
if (!typeClass.isInstance(type)) {
98+
throw new RuntimeException("Expecting Type " + typeClass + " but was " + type);
99+
}
100+
101+
}
102+
103+
}
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)