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/incubator-streampipes.git
The following commit(s) were added to refs/heads/dev by this push:
new ade3c68 [STREAMPIPES-340] Support of offset clause in Siddhi
wrapper/processors
new 6557658 Merge pull request #39 from sndp2693/STREAMPIPES-340
ade3c68 is described below
commit ade3c68bb63137ad3ec1e47c2f14e4de84b3a65a
Author: Sandeep Kumar <[email protected]>
AuthorDate: Wed Apr 7 15:14:08 2021 +0530
[STREAMPIPES-340] Support of offset clause in Siddhi wrapper/processors
---
.../wrapper/siddhi/SiddhiQueryBuilder.java | 9 +++++
.../wrapper/siddhi/constants/SiddhiConstants.java | 1 +
.../wrapper/siddhi/query/OffsetClause.java | 38 ++++++++++++++++++++++
.../wrapper/siddhi/query/SiddhiQuery.java | 15 +++++++++
4 files changed, 63 insertions(+)
diff --git
a/streampipes-wrapper-siddhi/src/main/java/org/apache/streampipes/wrapper/siddhi/SiddhiQueryBuilder.java
b/streampipes-wrapper-siddhi/src/main/java/org/apache/streampipes/wrapper/siddhi/SiddhiQueryBuilder.java
index 74e9412..de07c4c 100644
---
a/streampipes-wrapper-siddhi/src/main/java/org/apache/streampipes/wrapper/siddhi/SiddhiQueryBuilder.java
+++
b/streampipes-wrapper-siddhi/src/main/java/org/apache/streampipes/wrapper/siddhi/SiddhiQueryBuilder.java
@@ -90,6 +90,15 @@ public class SiddhiQueryBuilder {
return this;
}
+ public SiddhiQueryBuilder withOffsetClause(OffsetClause offsetClause) {
+ return this.withOffsetClause(offsetClause.toSiddhiEpl());
+ }
+
+ public SiddhiQueryBuilder withOffsetClause(String offsetClause) {
+ this.siddhiQuery.setOffsetClause(offsetClause);
+ return this;
+ }
+
public SiddhiQuery build() {
return this.siddhiQuery;
}
diff --git
a/streampipes-wrapper-siddhi/src/main/java/org/apache/streampipes/wrapper/siddhi/constants/SiddhiConstants.java
b/streampipes-wrapper-siddhi/src/main/java/org/apache/streampipes/wrapper/siddhi/constants/SiddhiConstants.java
index adb15f5..f89e7d3 100644
---
a/streampipes-wrapper-siddhi/src/main/java/org/apache/streampipes/wrapper/siddhi/constants/SiddhiConstants.java
+++
b/streampipes-wrapper-siddhi/src/main/java/org/apache/streampipes/wrapper/siddhi/constants/SiddhiConstants.java
@@ -22,6 +22,7 @@ public class SiddhiConstants {
public static final String SELECT = "select";
public static final String INSERT = "insert";
public static final String FROM = "from";
+ public static final String OFFSET = "offset";
public static final String WHITESPACE = " ";
public static final String COMMA = ",";
diff --git
a/streampipes-wrapper-siddhi/src/main/java/org/apache/streampipes/wrapper/siddhi/query/OffsetClause.java
b/streampipes-wrapper-siddhi/src/main/java/org/apache/streampipes/wrapper/siddhi/query/OffsetClause.java
new file mode 100644
index 0000000..cea0e96
--- /dev/null
+++
b/streampipes-wrapper-siddhi/src/main/java/org/apache/streampipes/wrapper/siddhi/query/OffsetClause.java
@@ -0,0 +1,38 @@
+/*
+ * 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.wrapper.siddhi.query;
+
+import org.apache.streampipes.wrapper.siddhi.constants.SiddhiConstants;
+
+public class OffsetClause extends SiddhiStatement {
+
+ private Integer offset;
+
+ public static OffsetClause create(Integer offset) {
+ return new OffsetClause(offset);
+ }
+
+ public OffsetClause(Integer offset) {
+ this.offset = offset;
+ }
+
+ @Override
+ public String toSiddhiEpl() {
+ return join(SiddhiConstants.WHITESPACE, SiddhiConstants.OFFSET,
String.valueOf(offset));
+ }
+}
diff --git
a/streampipes-wrapper-siddhi/src/main/java/org/apache/streampipes/wrapper/siddhi/query/SiddhiQuery.java
b/streampipes-wrapper-siddhi/src/main/java/org/apache/streampipes/wrapper/siddhi/query/SiddhiQuery.java
index db5b5ad..0d365a3 100644
---
a/streampipes-wrapper-siddhi/src/main/java/org/apache/streampipes/wrapper/siddhi/query/SiddhiQuery.java
+++
b/streampipes-wrapper-siddhi/src/main/java/org/apache/streampipes/wrapper/siddhi/query/SiddhiQuery.java
@@ -28,12 +28,14 @@ public class SiddhiQuery {
private String orderByClause;
private String limitClause;
private String insertIntoClause;
+ private String offsetClause;
private boolean hasSelectClause;
private boolean hasGroupByClause;
private boolean hasHavingClause;
private boolean hasOrderByClause;
private boolean hasLimitClause;
+ private boolean hasOffsetClause;
public String getFromClause() {
return fromClause;
@@ -52,6 +54,15 @@ public class SiddhiQuery {
this.hasSelectClause = true;
}
+ public String getOffsetClause() {
+ return offsetClause;
+ }
+
+ public void setOffsetClause(String offsetClause) {
+ this.offsetClause = offsetClause;
+ this.hasOffsetClause = true;
+ }
+
public String getGroupByClause() {
return groupByClause;
}
@@ -119,6 +130,10 @@ public class SiddhiQuery {
joiner.add(limitClause);
}
+ if (hasOffsetClause) {
+ joiner.add(offsetClause);
+ }
+
joiner.add(insertIntoClause);
return joiner.toString() + ";";