Skip to content

Commit

Permalink
HTTPTupleView Windowing does not support multiple partition keys in a…
Browse files Browse the repository at this point in the history
… comma-delimited string #324
  • Loading branch information
joergboe committed May 22, 2018
1 parent b9ffddd commit d7a80f2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
public class TupleView extends ServletOperator {
static final String opName = "HTTPTupleView";
// Parameter setters just to define the parameters in the SPL operator model.
@Parameter(optional=true, cardinality=-1, description="Names of attributes to partition the window by")
@Parameter(optional=true, cardinality=-1, description="Names of attributes to partition the window by. If the cardinality of this parameter is > 1,"
+ "then every value represents one attribute name. If the cadinality equals to 1, the value may contain one attribute name or a comma separated list of attribute names.")
public void setPartitionKey(String[] attributeNames) {}

@Parameter(optional = true, description = "List of headers to insert into the http reply. Formatted as header:value")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,26 @@ public class WindowContentsAtTrigger<T> implements StreamWindowListener<T> {
private long lastModified = System.currentTimeMillis();

@SuppressWarnings("unchecked")
public WindowContentsAtTrigger(OperatorContext context, StreamingInput<T> input) {
public WindowContentsAtTrigger(OperatorContext context, StreamingInput<T> input) {
this.context = context;
this.input = input;
isSliding = StreamWindow.Type.SLIDING.equals(input.getStreamWindow().getType());
List<String> partitionKeys = context.getParameterValues("partitionKey");
List<String> partitionKeys = null;
//Tokenize paritionKey if cardinality is 1 and put all values to partitionKeys
List<String> primaryPartitionKeys = context.getParameterValues("partitionKey");
if (primaryPartitionKeys.size() == 1) {
String[] stringArr = primaryPartitionKeys.get(0).split(",");
if (stringArr.length > 1) {
partitionKeys = new ArrayList<String>();
for (int i = 0; i < stringArr.length; i++) {
partitionKeys.add(stringArr[i]);
}
} else {
partitionKeys = primaryPartitionKeys;
}
} else {
partitionKeys = primaryPartitionKeys;
}
if (!partitionKeys.isEmpty()) {
if (!input.getStreamWindow().isPartitioned())
throw new IllegalStateException("Input port " + input.getName() + "is not partitioned");
Expand Down

0 comments on commit d7a80f2

Please sign in to comment.