You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ri...@apache.org on 2023/03/06 20:29:09 UTC
[streampipes] branch dev updated: Remove obsolete features from data explorer module (#1385) (#1386)
This is an automated email from the ASF dual-hosted git repository.
riemer pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/streampipes.git
The following commit(s) were added to refs/heads/dev by this push:
new cf85c2aa6 Remove obsolete features from data explorer module (#1385) (#1386)
cf85c2aa6 is described below
commit cf85c2aa698613cfbee53494f095a7da109db456
Author: Dominik Riemer <do...@gmail.com>
AuthorDate: Mon Mar 6 21:29:01 2023 +0100
Remove obsolete features from data explorer module (#1385) (#1386)
* Remove obsolete features from data explorer module (#1385)
* Update AutoAggregationHandler.java
---
.../dataexplorer/DataLakeManagementV4.java | 51 ------------
.../streampipes/dataexplorer/model/Order.java | 34 --------
.../dataexplorer/param/QueryParams.java | 36 ---------
.../param/RetentionPolicyQueryParams.java | 38 ---------
.../dataexplorer/query/DataExplorerQuery.java | 94 ----------------------
.../query/DataExplorerQueryBuilder.java | 61 --------------
.../dataexplorer/query/DeleteDataQuery.java | 28 +++++--
.../query/EditRetentionPolicyQuery.java | 77 ------------------
.../query/ParameterizedDataExplorerQuery.java | 28 -------
.../query/ShowRetentionPolicyQuery.java | 58 -------------
.../dataexplorer/template/QueryTemplates.java | 40 ---------
.../dataexplorer/v4/AutoAggregationHandler.java | 18 ++---
.../dataexplorer/v4/template/QueryTemplatesV4.java | 26 ------
.../apache/streampipes/ps/DataLakeResourceV4.java | 30 -------
14 files changed, 25 insertions(+), 594 deletions(-)
diff --git a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/DataLakeManagementV4.java b/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/DataLakeManagementV4.java
index 6cc0d5620..7f397af7a 100644
--- a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/DataLakeManagementV4.java
+++ b/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/DataLakeManagementV4.java
@@ -21,10 +21,7 @@ package org.apache.streampipes.dataexplorer;
import org.apache.streampipes.commons.environment.Environment;
import org.apache.streampipes.commons.environment.Environments;
import org.apache.streampipes.dataexplorer.commons.influx.InfluxClientProvider;
-import org.apache.streampipes.dataexplorer.param.RetentionPolicyQueryParams;
import org.apache.streampipes.dataexplorer.query.DeleteDataQuery;
-import org.apache.streampipes.dataexplorer.query.EditRetentionPolicyQuery;
-import org.apache.streampipes.dataexplorer.query.ShowRetentionPolicyQuery;
import org.apache.streampipes.dataexplorer.utils.DataExplorerUtils;
import org.apache.streampipes.dataexplorer.v4.ProvidedQueryParams;
import org.apache.streampipes.dataexplorer.v4.params.QueryParamsV4;
@@ -33,9 +30,7 @@ import org.apache.streampipes.dataexplorer.v4.query.QueryResultProvider;
import org.apache.streampipes.dataexplorer.v4.query.StreamedQueryResultProvider;
import org.apache.streampipes.dataexplorer.v4.query.writer.OutputFormat;
import org.apache.streampipes.dataexplorer.v4.utils.DataLakeManagementUtils;
-import org.apache.streampipes.model.datalake.DataLakeConfiguration;
import org.apache.streampipes.model.datalake.DataLakeMeasure;
-import org.apache.streampipes.model.datalake.DataLakeRetentionPolicy;
import org.apache.streampipes.model.datalake.SpQueryResult;
import org.apache.streampipes.model.schema.EventProperty;
import org.apache.streampipes.model.schema.EventPropertyList;
@@ -108,58 +103,12 @@ public class DataLakeManagementV4 {
return false;
}
- public SpQueryResult deleteData(String measurementID) {
- return this.deleteData(measurementID, null, null);
- }
-
public SpQueryResult deleteData(String measurementID, Long startDate, Long endDate) {
Map<String, QueryParamsV4> queryParts =
DataLakeManagementUtils.getDeleteQueryParams(measurementID, startDate, endDate);
return new DataExplorerQueryV4(queryParts).executeQuery(true);
}
- public DataLakeConfiguration getDataLakeConfiguration() {
- List<DataLakeRetentionPolicy> retentionPolicies = getAllExistingRetentionPolicies();
- return new DataLakeConfiguration(retentionPolicies);
- }
-
- public String editMeasurementConfiguration(DataLakeConfiguration config, boolean resetToDefault) {
-
- List<DataLakeRetentionPolicy> existingRetentionPolicies = getAllExistingRetentionPolicies();
-
- if (resetToDefault) {
- if (existingRetentionPolicies.size() > 1) {
- String drop =
- new EditRetentionPolicyQuery(RetentionPolicyQueryParams.from("custom", "0s"), "DROP").executeQuery();
- }
- return new EditRetentionPolicyQuery(RetentionPolicyQueryParams.from("autogen", "0s"), "DEFAULT").executeQuery();
- } else {
-
- Integer batchSize = config.getBatchSize();
- Integer flushDuration = config.getFlushDuration();
-
- //
- // TODO:
- // - Implementation of parameter update for batchSize and flushDuration
- // - Updating multiple retention policies
- //
-
- String operation = "CREATE";
- if (existingRetentionPolicies.size() > 1) {
- operation = "ALTER";
- }
- return new EditRetentionPolicyQuery(RetentionPolicyQueryParams.from("custom", "1d"), operation).executeQuery();
- }
- }
-
- public List<DataLakeRetentionPolicy> getAllExistingRetentionPolicies() {
- //
- // TODO:
- // - Implementation of parameter return for batchSize and flushDuration
- //
- return new ShowRetentionPolicyQuery(RetentionPolicyQueryParams.from("", "0s")).executeQuery();
- }
-
public boolean removeEventProperty(String measurementID) {
boolean isSuccess = false;
CouchDbClient couchDbClient = Utils.getCouchDbDataLakeClient();
diff --git a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/model/Order.java b/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/model/Order.java
deleted file mode 100644
index e5f27458a..000000000
--- a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/model/Order.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.streampipes.dataexplorer.model;
-
-public enum Order {
-
- ASC("ASC"),
- DESC("DESC");
-
- private String value;
-
- Order(String value) {
- this.value = value;
- }
-
- public String toValue() {
- return value;
- }
-}
diff --git a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/param/QueryParams.java b/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/param/QueryParams.java
deleted file mode 100644
index d664eb269..000000000
--- a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/param/QueryParams.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.streampipes.dataexplorer.param;
-
-public class QueryParams {
-
- private final String index;
-
- protected QueryParams(String index) {
- this.index = index;
- }
-
- public static QueryParams from(String index) {
- return new QueryParams(index);
- }
-
- public String getIndex() {
- return index;
- }
-
-}
diff --git a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/param/RetentionPolicyQueryParams.java b/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/param/RetentionPolicyQueryParams.java
deleted file mode 100644
index b42fa6d48..000000000
--- a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/param/RetentionPolicyQueryParams.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.streampipes.dataexplorer.param;
-
-public class RetentionPolicyQueryParams extends QueryParams {
- private final String durationLiteral;
-
- protected RetentionPolicyQueryParams(String index, String durationLiteral) {
- super(index);
- this.durationLiteral = durationLiteral;
- }
-
- public static RetentionPolicyQueryParams from(String index, String durationLiteral) {
- return new RetentionPolicyQueryParams(index, durationLiteral);
- }
-
- public String getDurationLiteral() {
- return durationLiteral;
- }
-
-
-}
diff --git a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/query/DataExplorerQuery.java b/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/query/DataExplorerQuery.java
deleted file mode 100644
index 33cd9b997..000000000
--- a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/query/DataExplorerQuery.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.streampipes.dataexplorer.query;
-
-import org.apache.streampipes.commons.environment.Environment;
-import org.apache.streampipes.commons.environment.Environments;
-import org.apache.streampipes.dataexplorer.commons.influx.InfluxClientProvider;
-import org.apache.streampipes.model.datalake.DataSeries;
-import org.apache.streampipes.model.datalake.SpQueryResult;
-
-import org.influxdb.InfluxDB;
-import org.influxdb.dto.Query;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-
-public abstract class DataExplorerQuery<T> {
-
- public T executeQuery() throws RuntimeException {
- InfluxDB influxDB = InfluxClientProvider.getInfluxDBClient();
- var databaseName = getEnvironment().getTsStorageBucket().getValueOrDefault();
- DataExplorerQueryBuilder queryBuilder =
- DataExplorerQueryBuilder.create(databaseName);
- getQuery(queryBuilder);
- Query query = queryBuilder.toQuery();
- org.influxdb.dto.QueryResult result;
- if (queryBuilder.hasTimeUnit()) {
- result = influxDB.query(query, queryBuilder.getTimeUnit());
- } else {
- result = influxDB.query(query);
- }
-
- T dataResult = postQuery(result);
- influxDB.close();
-
- return dataResult;
- }
-
- protected SpQueryResult convertResult(org.influxdb.dto.QueryResult result) {
- if (result.getResults().get(0).getSeries() != null) {
- DataSeries dataSeries = convertResult(result.getResults().get(0).getSeries().get(0));
- return new SpQueryResult(1, dataSeries.getHeaders(), Arrays.asList(dataSeries));
- } else {
- return new SpQueryResult();
- }
- }
-
- protected DataSeries convertResult(org.influxdb.dto.QueryResult.Series serie) {
- List<String> columns = serie.getColumns();
- for (int i = 0; i < columns.size(); i++) {
- String replacedColumnName = columns.get(i).replaceAll("mean_", "");
- columns.set(i, replacedColumnName);
- }
- List values = serie.getValues();
- return new DataSeries(values.size(), values, columns, new HashMap<>());
- }
-
- protected SpQueryResult convertMultiResult(org.influxdb.dto.QueryResult result) {
- SpQueryResult groupedDataResult = new SpQueryResult();
- if (result.getResults().get(0).getSeries() != null) {
- for (org.influxdb.dto.QueryResult.Series series : result.getResults().get(0).getSeries()) {
- String groupName = series.getTags().entrySet().toArray()[0].toString();
- DataSeries dataResult = convertResult(series);
- groupedDataResult.addDataResult(dataResult);
- }
- }
- return groupedDataResult;
-
- }
-
- private Environment getEnvironment() {
- return Environments.getEnvironment();
- }
-
- protected abstract void getQuery(DataExplorerQueryBuilder queryBuilder);
-
- protected abstract T postQuery(org.influxdb.dto.QueryResult result) throws RuntimeException;
-}
diff --git a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/query/DataExplorerQueryBuilder.java b/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/query/DataExplorerQueryBuilder.java
deleted file mode 100644
index 7ca849b68..000000000
--- a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/query/DataExplorerQueryBuilder.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.streampipes.dataexplorer.query;
-
-import org.influxdb.dto.Query;
-
-import java.util.StringJoiner;
-import java.util.concurrent.TimeUnit;
-
-public class DataExplorerQueryBuilder {
-
- private StringJoiner queryParts;
- private String databaseName;
- private TimeUnit timeUnit;
-
- private DataExplorerQueryBuilder(String databaseName) {
- this.queryParts = new StringJoiner(" ");
- this.databaseName = databaseName;
- }
-
- public static DataExplorerQueryBuilder create(String databaseName) {
- return new DataExplorerQueryBuilder(databaseName);
- }
-
- public DataExplorerQueryBuilder add(String queryPart) {
- this.queryParts.add(queryPart);
- return this;
- }
-
- public DataExplorerQueryBuilder withTimeUnit(TimeUnit timeUnit) {
- this.timeUnit = timeUnit;
- return this;
- }
-
- public boolean hasTimeUnit() {
- return this.timeUnit != null;
- }
-
- public TimeUnit getTimeUnit() {
- return this.timeUnit;
- }
-
- public Query toQuery() {
- return new Query(queryParts.toString(), databaseName);
- }
-}
diff --git a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/query/DeleteDataQuery.java b/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/query/DeleteDataQuery.java
index e4a7a05b9..6ef1d6856 100644
--- a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/query/DeleteDataQuery.java
+++ b/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/query/DeleteDataQuery.java
@@ -17,25 +17,37 @@
*/
package org.apache.streampipes.dataexplorer.query;
+import org.apache.streampipes.commons.environment.Environment;
+import org.apache.streampipes.commons.environment.Environments;
+import org.apache.streampipes.dataexplorer.commons.influx.InfluxClientProvider;
import org.apache.streampipes.model.datalake.DataLakeMeasure;
+import org.influxdb.InfluxDB;
+import org.influxdb.dto.Query;
import org.influxdb.dto.QueryResult;
-public class DeleteDataQuery extends DataExplorerQuery<QueryResult> {
+public class DeleteDataQuery {
- private DataLakeMeasure measure;
+ private final DataLakeMeasure measure;
public DeleteDataQuery(DataLakeMeasure measure) {
this.measure = measure;
}
- @Override
- protected void getQuery(DataExplorerQueryBuilder queryBuilder) {
- queryBuilder.add("DROP MEASUREMENT \"" + measure.getMeasureName() + "\"");
+ private String getQuery() {
+ return "DROP MEASUREMENT \"" + measure.getMeasureName() + "\"";
}
- @Override
- protected QueryResult postQuery(QueryResult result) {
- return result;
+ public QueryResult executeQuery() throws RuntimeException {
+ try (final InfluxDB influxDB = InfluxClientProvider.getInfluxDBClient()) {
+ var databaseName = getEnvironment().getTsStorageBucket().getValueOrDefault();
+
+ var query = new Query(getQuery(), databaseName);
+ return influxDB.query(query);
+ }
+ }
+
+ private Environment getEnvironment() {
+ return Environments.getEnvironment();
}
}
diff --git a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/query/EditRetentionPolicyQuery.java b/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/query/EditRetentionPolicyQuery.java
deleted file mode 100644
index c28931ad1..000000000
--- a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/query/EditRetentionPolicyQuery.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.streampipes.dataexplorer.query;
-
-import org.apache.streampipes.dataexplorer.param.RetentionPolicyQueryParams;
-
-import org.influxdb.dto.QueryResult;
-
-public class EditRetentionPolicyQuery extends ParameterizedDataExplorerQuery<RetentionPolicyQueryParams, String> {
-
- private static final String CREATE_OPERATOR = "CREATE";
- private static final String ALTER_OPERATOR = "ALTER";
- private static final String DROP_OPERATOR = "DROP";
- private static final String RESET_OPERATOR = "DEFAULT";
-
- private String operationToPerform;
-
- public EditRetentionPolicyQuery(RetentionPolicyQueryParams queryParams, String operation) {
- super(queryParams);
- this.operationToPerform = operation;
- }
-
-
- @Override
- protected void getQuery(DataExplorerQueryBuilder queryBuilder) {
- if (this.operationToPerform.equals(CREATE_OPERATOR)) {
- queryBuilder.add(createRetentionPolicyStatement(params.getIndex()));
- } else if (this.operationToPerform.equals(ALTER_OPERATOR)) {
- queryBuilder.add(alterRetentionPolicyStatement(params.getIndex()));
- } else if (this.operationToPerform.equals(DROP_OPERATOR)) {
- queryBuilder.add(dropRetentionPolicyStatement(params.getIndex()));
- } else if (this.operationToPerform.equals(RESET_OPERATOR)) {
- queryBuilder.add(resetRetentionPolicyStatement());
- }
-
- }
-
- @Override
- protected String postQuery(QueryResult result) throws RuntimeException {
- return result.toString();
- }
-
- private String createRetentionPolicyStatement(String index) {
- return "CREATE RETENTION POLICY " + index + " ON " + "sp DURATION " + params.getDurationLiteral()
- + " REPLICATION 1 DEFAULT";
- }
-
- private String alterRetentionPolicyStatement(String index) {
- return "ALTER RETENTION POLICY " + index + " ON " + "sp DURATION " + params.getDurationLiteral()
- + " REPLICATION 1 DEFAULT";
- }
-
- private String dropRetentionPolicyStatement(String index) {
- return "DROP RETENTION POLICY " + index + " ON " + "sp";
- }
-
- private String resetRetentionPolicyStatement() {
- return "ALTER RETENTION POLICY " + "autogen" + " ON " + "sp DURATION " + "0s" + " REPLICATION 1 DEFAULT";
- }
-
-}
diff --git a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/query/ParameterizedDataExplorerQuery.java b/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/query/ParameterizedDataExplorerQuery.java
deleted file mode 100644
index 1c66dfd23..000000000
--- a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/query/ParameterizedDataExplorerQuery.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.streampipes.dataexplorer.query;
-
-public abstract class ParameterizedDataExplorerQuery<K, V> extends DataExplorerQuery<V> {
-
- protected K params;
-
- public ParameterizedDataExplorerQuery(K queryParams) {
- this.params = queryParams;
- }
-
-}
diff --git a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/query/ShowRetentionPolicyQuery.java b/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/query/ShowRetentionPolicyQuery.java
deleted file mode 100644
index 4ccbb19f4..000000000
--- a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/query/ShowRetentionPolicyQuery.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.streampipes.dataexplorer.query;
-
-import org.apache.streampipes.dataexplorer.param.RetentionPolicyQueryParams;
-import org.apache.streampipes.model.datalake.DataLakeRetentionPolicy;
-
-import org.influxdb.dto.QueryResult;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class ShowRetentionPolicyQuery
- extends ParameterizedDataExplorerQuery<RetentionPolicyQueryParams, List<DataLakeRetentionPolicy>> {
-
- public ShowRetentionPolicyQuery(RetentionPolicyQueryParams queryParams) {
- super(queryParams);
- }
-
-
- @Override
- protected void getQuery(DataExplorerQueryBuilder queryBuilder) {
- queryBuilder.add(showRetentionPolicyStatement());
- }
-
- @Override
- protected List<DataLakeRetentionPolicy> postQuery(QueryResult result) throws RuntimeException {
- List<DataLakeRetentionPolicy> policies = new ArrayList<>();
- for (List<Object> a : result.getResults().get(0).getSeries().get(0).getValues()) {
- boolean isDefault = false;
- if (a.get(4).toString().equals("true")) {
- isDefault = true;
- }
- policies.add(new DataLakeRetentionPolicy(a.get(0).toString(), a.get(1).toString(), isDefault));
- }
- return policies;
- }
-
- private String showRetentionPolicyStatement() {
- return "SHOW RETENTION POLICIES ON " + "sp";
- }
-}
diff --git a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/template/QueryTemplates.java b/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/template/QueryTemplates.java
deleted file mode 100644
index 80ff5d1fa..000000000
--- a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/template/QueryTemplates.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.streampipes.dataexplorer.template;
-
-public class QueryTemplates {
-
- public static String selectWildcardFrom(String index) {
- return "SELECT * FROM " + index;
- }
-
- public static String selectMeanFrom(String index) {
- return "SELECT mean(*) FROM " + index;
- }
-
- public static String selectCountFrom(String index) {
- return "SELECT count(*) FROM " + index;
- }
-
- public static String whereTimeWithin(long startDate, long endDate) {
- return "WHERE time > "
- + startDate * 1000000
- + " AND time < "
- + endDate * 1000000;
- }
-}
diff --git a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/v4/AutoAggregationHandler.java b/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/v4/AutoAggregationHandler.java
index 63d9bd9fa..a63c98077 100644
--- a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/v4/AutoAggregationHandler.java
+++ b/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/v4/AutoAggregationHandler.java
@@ -18,7 +18,7 @@
package org.apache.streampipes.dataexplorer.v4;
import org.apache.streampipes.dataexplorer.DataLakeManagementV4;
-import org.apache.streampipes.dataexplorer.model.Order;
+import org.apache.streampipes.dataexplorer.sdk.DataLakeQueryOrdering;
import org.apache.streampipes.dataexplorer.v4.params.SelectColumn;
import org.apache.streampipes.model.datalake.SpQueryResult;
@@ -59,10 +59,9 @@ public class AutoAggregationHandler {
}
public ProvidedQueryParams makeAutoAggregationQueryParams() throws IllegalArgumentException {
- //checkAllArgumentsPresent();
try {
- SpQueryResult newest = getSingleRecord(Order.DESC);
- SpQueryResult oldest = getSingleRecord(Order.ASC);
+ SpQueryResult newest = getSingleRecord(DataLakeQueryOrdering.DESC);
+ SpQueryResult oldest = getSingleRecord(DataLakeQueryOrdering.ASC);
if (newest.getTotal() > 0) {
String sampleField = getSampleField(newest);
Integer count = getCount(sampleField);
@@ -86,13 +85,6 @@ public class AutoAggregationHandler {
return null;
}
- private void checkAllArgumentsPresent() throws IllegalArgumentException {
- if (!this.queryParams.has(QP_AGGREGATION_FUNCTION)) {
- throw new IllegalArgumentException(
- "Auto-Aggregate must provide one of the aggregationFunction parameters MEAN, FIRST, LAST.");
- }
- }
-
private ProvidedQueryParams disableAutoAgg(ProvidedQueryParams params) {
params.remove(QP_AUTO_AGGREGATE);
return params;
@@ -120,11 +112,11 @@ public class AutoAggregationHandler {
return Double.valueOf(v).intValue();
}
- private SpQueryResult getSingleRecord(Order order) throws ParseException {
+ private SpQueryResult getSingleRecord(DataLakeQueryOrdering order) throws ParseException {
ProvidedQueryParams singleEvent = disableAutoAgg(new ProvidedQueryParams(queryParams));
singleEvent.remove(QP_AGGREGATION_FUNCTION);
singleEvent.update(QP_LIMIT, 1);
- singleEvent.update(QP_ORDER, order.toValue());
+ singleEvent.update(QP_ORDER, order.name());
singleEvent.update(QP_COLUMNS, transformColumns(singleEvent.getAsString(QP_COLUMNS)));
return fireQuery(singleEvent);
diff --git a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/v4/template/QueryTemplatesV4.java b/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/v4/template/QueryTemplatesV4.java
index 9b0392cdb..5ada24d77 100644
--- a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/v4/template/QueryTemplatesV4.java
+++ b/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/v4/template/QueryTemplatesV4.java
@@ -17,34 +17,8 @@
*/
package org.apache.streampipes.dataexplorer.v4.template;
-import java.util.StringJoiner;
-
public class QueryTemplatesV4 {
- public static String selectFrom(String index, String columns) {
- return "SELECT " + columns + " FROM " + index;
- }
-
- public static String selectCountFrom(String index, String selectedColumns) {
- return selectAggregationFrom(index, selectedColumns, "COUNT");
- }
-
- public static String selectAggregationFrom(String index, String columns, String aggregationFunction) {
- String[] cols = columns.split(",");
- StringJoiner joiner = new StringJoiner(", ");
- //StringBuilder statement = new StringBuilder(aggregationFunction + "(" + cols[0] + ")");
-
- for (int i = 0; i < cols.length; i++) {
- String builder = aggregationFunction
- + "("
- + cols[i]
- + ")" + " AS " + cols[i];
- joiner.add(builder);
- }
-
- return "SELECT " + joiner + " FROM \"" + index + "\"";
- }
-
public static String deleteFrom(String index) {
return "DELETE FROM \"" + index + "\"";
}
diff --git a/streampipes-platform-services/src/main/java/org/apache/streampipes/ps/DataLakeResourceV4.java b/streampipes-platform-services/src/main/java/org/apache/streampipes/ps/DataLakeResourceV4.java
index 9186564ba..4ed1a0bd7 100644
--- a/streampipes-platform-services/src/main/java/org/apache/streampipes/ps/DataLakeResourceV4.java
+++ b/streampipes-platform-services/src/main/java/org/apache/streampipes/ps/DataLakeResourceV4.java
@@ -22,7 +22,6 @@ import org.apache.streampipes.dataexplorer.DataLakeManagementV4;
import org.apache.streampipes.dataexplorer.v4.ProvidedQueryParams;
import org.apache.streampipes.dataexplorer.v4.query.writer.OutputFormat;
import org.apache.streampipes.model.StreamPipesErrorMessage;
-import org.apache.streampipes.model.datalake.DataLakeConfiguration;
import org.apache.streampipes.model.datalake.DataLakeMeasure;
import org.apache.streampipes.model.datalake.DataSeries;
import org.apache.streampipes.model.datalake.SpQueryResult;
@@ -40,7 +39,6 @@ import org.slf4j.LoggerFactory;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.DELETE;
-import jakarta.ws.rs.DefaultValue;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
@@ -94,18 +92,6 @@ public class DataLakeResourceV4 extends AbstractRestResource {
}
- @POST
- @Path("/configuration")
- @Consumes(MediaType.APPLICATION_JSON)
- @Operation(summary = "Configure the parameters of the data lake", tags = {"Data Lake"},
- responses = {@ApiResponse(responseCode = "200", description = "Configuration was successful")})
- public Response configureMeasurement(
- @Parameter(in = ParameterIn.QUERY, description = "should any parameter be reset to its default value?")
- @DefaultValue("false") @QueryParam("resetToDefault") boolean resetToDefault,
- @Parameter(in = ParameterIn.DEFAULT, description = "the configuration parameters") DataLakeConfiguration config) {
- return ok(this.dataLakeManagement.editMeasurementConfiguration(config, resetToDefault));
- }
-
@DELETE
@Path("/measurements/{measurementID}")
@Operation(summary = "Remove data from a single measurement series with given id", tags = {"Data Lake"},
@@ -349,22 +335,6 @@ public class DataLakeResourceV4 extends AbstractRestResource {
}
}
-
- @GET
- @Path("/configuration")
- @Produces(MediaType.APPLICATION_JSON)
- @Operation(summary = "Get the configuration parameters of the data lake", tags = {"Data Lake"},
- responses = {
- @ApiResponse(
- responseCode = "200",
- description = "configuration parameters",
- content = @Content(schema = @Schema(implementation = DataLakeConfiguration.class)))})
- public Response getMeasurementConfiguration(
- @Parameter(in = ParameterIn.QUERY, description = "the id of a specific configuration parameter")
- @QueryParam("parameterID") String parameterID) {
- return ok(this.dataLakeManagement.getDataLakeConfiguration());
- }
-
@DELETE
@Path("/measurements")
@Operation(summary = "Remove all stored measurement series from Data Lake", tags = {"Data Lake"},