use of com.hortonworks.streamline.streams.layout.component.rule.expression.Window in project streamline by hortonworks.
the class TestWindowedQueryBolt method testJsonWindowConfig_EventTimeWindow.
@Test
public void testJsonWindowConfig_EventTimeWindow() throws IOException {
String windowConfigJson = "{\"windowLength\" : {\"class\":\".Window$Duration\", \"durationMs\":2000},\n" + " \"slidingInterval\":{\"class\":\".Window$Duration\", \"durationMs\":2000},\n" + " \"tsFields\": [\"s1:tsField1\" , \"s2:tsField2\", \"s3:field3.innerTsField\"],\n" + " \"lagMs\": 1000 ,\n" + " \"lateStream\": \"optionalLateStream\"}";
WindowedQueryBolt bolt = new WindowedQueryBolt("users", "city").join("cities", "cityName", "users").selectStreamLine("name, users:city as city, cities:country");
bolt.withWindowConfig(new Window(windowConfigJson));
}
use of com.hortonworks.streamline.streams.layout.component.rule.expression.Window in project streamline by hortonworks.
the class JoinBoltFluxComponentTest method testMakeWindowFromJson.
@Test
public void testMakeWindowFromJson() throws IOException {
String wjson = "{\"windowLength\":{\"class\":\".Window$Count\",\"count\":100},\"slidingInterval\":{\"class\":\".Window$Count\",\"count\":100},\"tsField\":null,\"lagMs\":0}";
// should not throw an exception
Window w = new Window(wjson);
}
use of com.hortonworks.streamline.streams.layout.component.rule.expression.Window in project streamline by hortonworks.
the class JoinBoltFluxComponentTest method testMakeEventTimeWindowFromJson.
@Test
public void testMakeEventTimeWindowFromJson() throws IOException {
String json = "{\"windowLength\" : {\"class\":\".Window$Count\", \"count\":100}, \"slidingInterval\":{\"class\":\".Window$Count\", \"count\":100}, " + // event time window related settings
"\"tsFields\": [\"stream1:tsField1\" , \"stream2:tsField2\"], \"lagMs\":10 , \"lateStream\": \"optionalLateStream\"} }";
// should not throw an exception
Window w = new Window(json);
}
use of com.hortonworks.streamline.streams.layout.component.rule.expression.Window in project streamline by hortonworks.
the class TopologyWindow method fromMap.
@Override
public Storable fromMap(Map<String, Object> map) {
super.fromMap(map);
setId((Long) map.get(ID));
setVersionId((Long) map.get(VERSIONID));
setTopologyId((Long) map.get(TOPOLOGY_ID));
setName((String) map.get(NAME));
setDescription((String) map.get(DESCRIPTION));
setCondition((String) map.get(CONDITION));
setParsedRuleStr((String) map.get(PARSED_RULE_STR));
try {
ObjectMapper mapper = new ObjectMapper();
String streamsStr = (String) map.get(STREAMS);
if (!StringUtils.isEmpty(streamsStr)) {
List<String> streams = mapper.readValue(streamsStr, new TypeReference<List<String>>() {
});
setStreams(streams);
}
String outputStreamsStr = (String) map.get(OUTPUT_STREAMS);
if (!StringUtils.isEmpty(outputStreamsStr)) {
List<String> outputStreams = mapper.readValue(outputStreamsStr, new TypeReference<List<String>>() {
});
setOutputStreams(outputStreams);
}
String windowStr = (String) map.get(WINDOW);
if (!StringUtils.isEmpty(windowStr)) {
Window window = mapper.readValue(windowStr, Window.class);
setWindow(window);
}
String actionsStr = (String) map.get(ACTIONS);
if (!StringUtils.isEmpty(actionsStr)) {
List<Action> actions = mapper.readValue(actionsStr, new TypeReference<List<Action>>() {
});
setActions(actions);
}
String projectionsStr = (String) map.get(PROJECTIONS);
if (!StringUtils.isEmpty(projectionsStr)) {
List<Projection> projections = mapper.readValue(projectionsStr, new TypeReference<List<Projection>>() {
});
setProjections(projections);
}
String groupbykeysStr = (String) map.get(GROUPBYKEYS);
if (!StringUtils.isEmpty(groupbykeysStr)) {
List<String> groupbykeys = mapper.readValue(groupbykeysStr, new TypeReference<List<String>>() {
});
setGroupbykeys(groupbykeys);
}
} catch (IOException e) {
throw new RuntimeException(e);
}
return this;
}
use of com.hortonworks.streamline.streams.layout.component.rule.expression.Window in project streamline by hortonworks.
the class TopologyRule method fromMap.
@Override
public Storable fromMap(Map<String, Object> map) {
super.fromMap(map);
setId((Long) map.get(ID));
setVersionId((Long) map.get(VERSIONID));
setTopologyId((Long) map.get(TOPOLOGY_ID));
setName((String) map.get(NAME));
setDescription((String) map.get(DESCRIPTION));
setCondition((String) map.get(CONDITION));
setSql((String) map.get(SQL));
setParsedRuleStr((String) map.get(PARSED_RULE_STR));
try {
ObjectMapper mapper = new ObjectMapper();
String streamsStr = (String) map.get(STREAMS);
if (!StringUtils.isEmpty(streamsStr)) {
List<String> streams = mapper.readValue(streamsStr, new TypeReference<List<String>>() {
});
setStreams(streams);
}
String outputStreamsStr = (String) map.get(OUTPUT_STREAMS);
if (!StringUtils.isEmpty(outputStreamsStr)) {
List<String> outputStreams = mapper.readValue(outputStreamsStr, new TypeReference<List<String>>() {
});
setOutputStreams(outputStreams);
}
String windowStr = (String) map.get(WINDOW);
if (!StringUtils.isEmpty(windowStr)) {
Window window = mapper.readValue(windowStr, Window.class);
setWindow(window);
}
String projectionsStr = (String) map.get(PROJECTIONS);
if (!StringUtils.isEmpty(projectionsStr)) {
setProjections(mapper.readValue(projectionsStr, new TypeReference<List<Projection>>() {
}));
}
String actionsStr = (String) map.get(ACTIONS);
if (!StringUtils.isEmpty(actionsStr)) {
setActions(mapper.readValue(actionsStr, new TypeReference<List<Action>>() {
}));
}
} catch (IOException e) {
throw new RuntimeException(e);
}
return this;
}
Aggregations