Skip to content

Commit 63ef15b

Browse files
committed
Rename entrypoint into endpoint, prepare column searching API
1 parent b6fcea8 commit 63ef15b

File tree

75 files changed

+1458
-589
lines changed

Some content is hidden

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

75 files changed

+1458
-589
lines changed

adhoc/src/main/java/eu/solven/adhoc/beta/schema/AdhocSchemaForApi.java adhoc/src/main/java/eu/solven/adhoc/beta/schema/AdhocSchema.java

+20-10
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import eu.solven.adhoc.measure.AdhocMeasureBag;
3838
import eu.solven.adhoc.measure.IAdhocMeasureBag;
3939
import eu.solven.adhoc.measure.model.IMeasure;
40-
import eu.solven.adhoc.query.AdhocQuery;
4140
import eu.solven.adhoc.query.IQueryOption;
4241
import eu.solven.adhoc.query.cube.IAdhocQuery;
4342
import eu.solven.adhoc.storage.ITabularView;
@@ -53,7 +52,7 @@
5352
*/
5453
@Value
5554
@Builder
56-
public class AdhocSchemaForApi {
55+
public class AdhocSchema implements IAdhocSchema {
5756
@Builder.Default
5857
final IAdhocQueryEngine engine = AdhocQueryEngine.builder().build();
5958

@@ -63,7 +62,7 @@ public class AdhocSchemaForApi {
6362

6463
final Map<String, IAdhocCubeWrapper> nameToCube = new ConcurrentHashMap<>();
6564

66-
final Map<String, IAdhocQuery> nameToQuery = new ConcurrentHashMap<>();
65+
// final Map<String, IAdhocQuery> nameToQuery = new ConcurrentHashMap<>();
6766

6867
public void registerCube(String cubeName, String tableName, String measuresName) {
6968
AdhocCubeWrapper cube = AdhocCubeWrapper.builder()
@@ -76,8 +75,9 @@ public void registerCube(String cubeName, String tableName, String measuresName)
7675
nameToCube.put(cubeName, cube);
7776
}
7877

79-
public EntrypointSchemaMetadata getMetadata() {
80-
EntrypointSchemaMetadata.EntrypointSchemaMetadataBuilder metadata = EntrypointSchemaMetadata.builder();
78+
@Override
79+
public EndpointSchemaMetadata getMetadata() {
80+
EndpointSchemaMetadata.EndpointSchemaMetadataBuilder metadata = EndpointSchemaMetadata.builder();
8181

8282
nameToCube.forEach((name, cube) -> {
8383
CubeSchemaMetadataBuilder cubeSchema = CubeSchemaMetadata.builder();
@@ -97,13 +97,14 @@ public EntrypointSchemaMetadata getMetadata() {
9797
metadata.table(name, ColumnarMetadata.from(table.getColumns()));
9898
});
9999

100-
nameToQuery.forEach((name, query) -> {
101-
metadata.query(name, AdhocQuery.edit(query).build());
102-
});
100+
// nameToQuery.forEach((name, query) -> {
101+
// metadata.query(name, AdhocQuery.edit(query).build());
102+
// });
103103

104104
return metadata.build();
105105
}
106106

107+
@Override
107108
public ITabularView execute(String cube, IAdhocQuery query, Set<? extends IQueryOption> options) {
108109
return nameToCube.get(cube).execute(query, options);
109110
}
@@ -122,7 +123,16 @@ public void registerMeasure(String measureBagName, IMeasure measure) {
122123
measureBag.addMeasure(measure);
123124
}
124125

125-
public void registerQuery(String name, IAdhocQuery query) {
126-
nameToQuery.put(name, query);
126+
public Set<?> getCoordinates(ColumnIdentifier columnId) {
127+
if (columnId.isCubeElseTable()) {
128+
nameToCube.get(columnId.getHolder()).getCoordinates(columnId.getColumn());
129+
} else {
130+
131+
}
132+
return Set.of();
127133
}
134+
135+
// public void registerQuery(String name, IAdhocQuery query) {
136+
// nameToQuery.put(name, query);
137+
// }
128138
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* The MIT License
3+
* Copyright (c) 2025 Benoit Chatain Lacelle - SOLVEN
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy
6+
* of this software and associated documentation files (the "Software"), to deal
7+
* in the Software without restriction, including without limitation the rights
8+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
* copies of the Software, and to permit persons to whom the Software is
10+
* furnished to do so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in
13+
* all copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
* THE SOFTWARE.
22+
*/
23+
package eu.solven.adhoc.beta.schema;
24+
25+
import lombok.Builder;
26+
import lombok.Builder.Default;
27+
import lombok.NonNull;
28+
import lombok.Value;
29+
30+
@Value
31+
@Builder(toBuilder = true)
32+
public class ColumnIdentifier {
33+
// Is this a cube (else a table) column
34+
@Default
35+
boolean isCubeElseTable = true;
36+
37+
// The name of the cube/table
38+
@NonNull
39+
String holder;
40+
41+
String column;
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/**
2+
* The MIT License
3+
* Copyright (c) 2025 Benoit Chatain Lacelle - SOLVEN
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy
6+
* of this software and associated documentation files (the "Software"), to deal
7+
* in the Software without restriction, including without limitation the rights
8+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
* copies of the Software, and to permit persons to whom the Software is
10+
* furnished to do so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in
13+
* all copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
* THE SOFTWARE.
22+
*/
23+
package eu.solven.adhoc.beta.schema;
24+
25+
import java.util.Set;
26+
import java.util.UUID;
27+
28+
import lombok.Builder;
29+
import lombok.Builder.Default;
30+
import lombok.NonNull;
31+
import lombok.Singular;
32+
import lombok.Value;
33+
import lombok.extern.jackson.Jacksonized;
34+
import lombok.extern.slf4j.Slf4j;
35+
36+
@Value
37+
@Builder
38+
@Jacksonized
39+
@Slf4j
40+
public class ColumnMetadata {
41+
// May be null, in context where there is no entrypoint
42+
UUID entrypointId;
43+
44+
// Typically a cube or a table
45+
@NonNull
46+
String holder;
47+
48+
@NonNull
49+
String column;
50+
51+
@NonNull
52+
String type;
53+
54+
// The number of different coordinates. This is contextual to a cube/table.
55+
// -1 means the cardinality has not been estimated
56+
@Default
57+
long estimatedCardinality = -1;
58+
59+
// A subset of matching coordinates. Typically not exhaustive.
60+
@Singular
61+
Set<?> coordinates;
62+
63+
}

adhoc/src/main/java/eu/solven/adhoc/beta/schema/EntrypointSchemaMetadata.java adhoc/src/main/java/eu/solven/adhoc/beta/schema/EndpointSchemaMetadata.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
@Value
4646
@Builder
4747
@Jacksonized
48-
public class EntrypointSchemaMetadata {
48+
public class EndpointSchemaMetadata {
4949

5050
@Singular
5151
Map<String, ColumnarMetadata> tables;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* The MIT License
3+
* Copyright (c) 2025 Benoit Chatain Lacelle - SOLVEN
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy
6+
* of this software and associated documentation files (the "Software"), to deal
7+
* in the Software without restriction, including without limitation the rights
8+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
* copies of the Software, and to permit persons to whom the Software is
10+
* furnished to do so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in
13+
* all copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
* THE SOFTWARE.
22+
*/
23+
package eu.solven.adhoc.beta.schema;
24+
25+
import java.util.Set;
26+
27+
import eu.solven.adhoc.query.IQueryOption;
28+
import eu.solven.adhoc.query.cube.IAdhocQuery;
29+
import eu.solven.adhoc.storage.ITabularView;
30+
31+
/**
32+
* Wraps together the core structures of Adhoc
33+
*
34+
* @author Benoit Lacelle
35+
*/
36+
public interface IAdhocSchema {
37+
38+
EndpointSchemaMetadata getMetadata();
39+
40+
ITabularView execute(String cube, IAdhocQuery query, Set<? extends IQueryOption> options);
41+
42+
}

adhoc/src/main/java/eu/solven/adhoc/beta/schema/TargetedAdhocQuery.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
package eu.solven.adhoc.beta.schema;
2424

2525
import java.util.Set;
26+
import java.util.UUID;
2627

2728
import eu.solven.adhoc.query.AdhocQuery;
2829
import eu.solven.adhoc.query.IQueryOption;
@@ -43,7 +44,7 @@
4344
@Jacksonized
4445
public class TargetedAdhocQuery {
4546
@NonNull
46-
String entrypointId;
47+
UUID endpointId;
4748

4849
@NonNull
4950
String cube;

adhoc/src/main/java/eu/solven/adhoc/cube/AdhocCubeWrapper.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public class AdhocCubeWrapper implements IAdhocCubeWrapper {
6868
@NonNull
6969
@Default
7070
final IAdhocColumnsManager columnsManager = AdhocColumnsManager.builder().build();
71-
71+
7272
@Override
7373
public Map<String, IMeasure> getNameToMeasure() {
7474
return measures.getNameToMeasure();

adhoc/src/main/java/eu/solven/adhoc/cube/IAdhocCubeWrapper.java

+8
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@
2323
package eu.solven.adhoc.cube;
2424

2525
import java.util.Set;
26+
import java.util.stream.Collectors;
2627

2728
import eu.solven.adhoc.measure.IHasMeasures;
29+
import eu.solven.adhoc.query.AdhocQuery;
2830
import eu.solven.adhoc.query.IQueryOption;
2931
import eu.solven.adhoc.query.StandardQueryOptions;
3032
import eu.solven.adhoc.query.cube.IAdhocQuery;
@@ -52,4 +54,10 @@ default ITabularView execute(IAdhocQuery query) {
5254
*/
5355
ITabularView execute(IAdhocQuery query, Set<? extends IQueryOption> options);
5456

57+
default Set<Object> getCoordinates(String column) {
58+
ITabularView view = this.execute(AdhocQuery.builder().groupByAlso(column).build());
59+
60+
return view.slices().map(slice -> slice.getRawSliced(column)).collect(Collectors.toSet());
61+
}
62+
5563
}

adhoc/src/main/java/eu/solven/adhoc/dag/AdhocQueryEngine.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -549,12 +549,12 @@ protected void forEachStreamedRow(ExecutingQueryContext executingQueryContext,
549549
Optional<Aggregator> optAgg = isAggregator(columnToAggregators, aggregatedColumn);
550550

551551
optAgg.ifPresent(agg -> {
552-
coordinatesToAgg.contribute(agg, coordinates, v);
552+
coordinatesToAgg.contributeAggregate(agg, coordinates, v);
553553
});
554554
} else {
555555
// The DB provides the column raw value, and not an aggregated value
556556
// So we aggregate row values ourselves (e.g. InMemoryTable)
557-
aggs.forEach(agg -> coordinatesToAgg.contribute(agg, coordinates, v));
557+
aggs.forEach(agg -> coordinatesToAgg.contributeRaw(agg, coordinates, v));
558558
}
559559
}
560560
}

adhoc/src/main/java/eu/solven/adhoc/measure/sum/CountAggregation.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@
2323
package eu.solven.adhoc.measure.sum;
2424

2525
import eu.solven.adhoc.measure.aggregation.IAggregation;
26+
import eu.solven.adhoc.measure.sum.IAggregationCarrier.IHasCarriers;
2627
import eu.solven.adhoc.storage.IValueConsumer;
2728
import lombok.Builder;
2829
import lombok.Value;
2930

3031
/**
3132
* Keep the highest value amongst encountered values
3233
*/
33-
public class CountAggregation implements IAggregation {
34+
public class CountAggregation implements IAggregation, IHasCarriers {
3435

3536
public static final String KEY = "COUNT";
3637

@@ -95,6 +96,11 @@ protected Object aggregateOne(Object one) {
9596
}
9697
}
9798

99+
@Override
100+
public CountHolder wrap(Object v) {
101+
return CountHolder.builder().count(((Number) v).longValue()).build();
102+
}
103+
98104
// @Override
99105
// public double aggregateDoubles(double left, double right) {
100106
// throw new UnsupportedOperationException("COUNT does not fit into a double");

adhoc/src/main/java/eu/solven/adhoc/measure/sum/IAggregationCarrier.java

+14
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import eu.solven.adhoc.measure.aggregation.IAggregation;
2626
import eu.solven.adhoc.storage.IValueConsumer;
27+
import eu.solven.adhoc.table.IAdhocTableWrapper;
2728

2829
/**
2930
* This is used by {@link IAggregation} which need to differentiate clearly from inputs and a stateful-but-intermediate
@@ -32,5 +33,18 @@
3233
* @author Benoit Lacelle
3334
*/
3435
public interface IAggregationCarrier {
36+
37+
interface IHasCarriers {
38+
39+
/**
40+
*
41+
* @param v
42+
* some pre-aggregated value, typically computed by the {@link IAdhocTableWrapper}.
43+
* @return an {@link IAggregationCarrier}
44+
*/
45+
IAggregationCarrier wrap(Object v);
46+
47+
}
48+
3549
void acceptValueConsumer(IValueConsumer valueConsumer);
3650
}

0 commit comments

Comments
 (0)