Java Code Examples for org.codehaus.jackson.map.ObjectMapper#createArrayNode()
The following examples show how to use
org.codehaus.jackson.map.ObjectMapper#createArrayNode() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JobHistoryEventHandler.java From big-c with Apache License 2.0 | 6 votes |
@Private public JsonNode countersToJSON(Counters counters) { ObjectMapper mapper = new ObjectMapper(); ArrayNode nodes = mapper.createArrayNode(); if (counters != null) { for (CounterGroup counterGroup : counters) { ObjectNode groupNode = nodes.addObject(); groupNode.put("NAME", counterGroup.getName()); groupNode.put("DISPLAY_NAME", counterGroup.getDisplayName()); ArrayNode countersNode = groupNode.putArray("COUNTERS"); for (Counter counter : counterGroup) { ObjectNode counterNode = countersNode.addObject(); counterNode.put("NAME", counter.getName()); counterNode.put("DISPLAY_NAME", counter.getDisplayName()); counterNode.put("VALUE", counter.getValue()); } } } return nodes; }
Example 2
Source File: PendingTasks.java From attic-aurora with Apache License 2.0 | 6 votes |
/** * Returns information about pending tasks. * * @return HTTP response. */ @GET @Produces(MediaType.APPLICATION_JSON) public Response getOffers() throws IOException { Map<TaskGroupKey, List<String>> taskGroupReasonMap = nearestFit.getPendingReasons(taskGroups.getGroups()); ObjectMapper mapper = new ObjectMapper(); ArrayNode jsonNode = mapper.createArrayNode(); // Add the attribute "reason" to each serialized taskgroup for (TaskGroup group : taskGroups.getGroups()) { ObjectNode pendingTask = (ObjectNode) mapper.valueToTree(group); pendingTask.put("reason", taskGroupReasonMap.get(group.getKey()).toString()); jsonNode.add(pendingTask); } return Response.ok(jsonNode).build(); }
Example 3
Source File: JobHistoryEventHandler.java From hadoop with Apache License 2.0 | 6 votes |
@Private public JsonNode countersToJSON(Counters counters) { ObjectMapper mapper = new ObjectMapper(); ArrayNode nodes = mapper.createArrayNode(); if (counters != null) { for (CounterGroup counterGroup : counters) { ObjectNode groupNode = nodes.addObject(); groupNode.put("NAME", counterGroup.getName()); groupNode.put("DISPLAY_NAME", counterGroup.getDisplayName()); ArrayNode countersNode = groupNode.putArray("COUNTERS"); for (Counter counter : counterGroup) { ObjectNode counterNode = countersNode.addObject(); counterNode.put("NAME", counter.getName()); counterNode.put("DISPLAY_NAME", counter.getDisplayName()); counterNode.put("VALUE", counter.getValue()); } } } return nodes; }
Example 4
Source File: TestSamzaObjectMapper.java From samza with Apache License 2.0 | 5 votes |
/** * Builds {@link ObjectNode} which matches the {@link JobModel} built in setup. */ private static ObjectNode buildJobModelJson() { ObjectMapper objectMapper = new ObjectMapper(); ObjectNode configJson = objectMapper.createObjectNode(); configJson.put("a", "b"); ObjectNode containerModel1TaskTestSSPJson = objectMapper.createObjectNode(); containerModel1TaskTestSSPJson.put("system", "foo"); containerModel1TaskTestSSPJson.put("stream", "bar"); containerModel1TaskTestSSPJson.put("partition", 1); ArrayNode containerModel1TaskTestSSPsJson = objectMapper.createArrayNode(); containerModel1TaskTestSSPsJson.add(containerModel1TaskTestSSPJson); ObjectNode containerModel1TaskTestJson = objectMapper.createObjectNode(); containerModel1TaskTestJson.put("task-name", "test"); containerModel1TaskTestJson.put("system-stream-partitions", containerModel1TaskTestSSPsJson); containerModel1TaskTestJson.put("changelog-partition", 2); containerModel1TaskTestJson.put("task-mode", "Active"); ObjectNode containerModel1TasksJson = objectMapper.createObjectNode(); containerModel1TasksJson.put("test", containerModel1TaskTestJson); ObjectNode containerModel1Json = objectMapper.createObjectNode(); // important: needs to be "processor-id" for compatibility between Samza 0.14 and 1.0 containerModel1Json.put("processor-id", "1"); containerModel1Json.put("tasks", containerModel1TasksJson); ObjectNode containersJson = objectMapper.createObjectNode(); containersJson.put("1", containerModel1Json); ObjectNode jobModelJson = objectMapper.createObjectNode(); jobModelJson.put("config", configJson); jobModelJson.put("containers", containersJson); return jobModelJson; }
Example 5
Source File: TestOperators.java From Cubert with Apache License 2.0 | 5 votes |
@Test public void testGroupByDedup() throws JsonGenerationException, JsonMappingException, IOException, InterruptedException { Object[][] rows1 = { { 0, 0 }, { 0, 1 }, { 0, 1 }, { 5, 6 }, { 5, 6 }, { 100, 10 } }; Block block = new ArrayBlock(Arrays.asList(rows1), new String[] { "a", "b" }, 1); Map<String, Block> input = new HashMap<String, Block>(); input.put("block", block); TupleOperator operator = new GroupByOperator(); ObjectMapper mapper = new ObjectMapper(); ObjectNode json = mapper.createObjectNode(); json.put("input", "block"); ArrayNode anode = mapper.createArrayNode(); anode.add("a"); anode.add("b"); json.put("groupBy", anode); BlockProperties props = new BlockProperties(null, new BlockSchema("INT a, INT b"), (BlockProperties) null); operator.setInput(input, json, props); Block output = new TupleOperatorBlock(operator, props); ArrayBlock.assertData(output, new Object[][] { { 0, 0 }, { 0, 1 }, { 5, 6 }, { 100, 10 } }, new String[] { "a", "b" }); }
Example 6
Source File: TestOperators.java From Cubert with Apache License 2.0 | 5 votes |
@Test public void testGroupByWithSum1() throws JsonGenerationException, JsonMappingException, IOException, InterruptedException { Object[][] rows1 = { { 0 }, { 2 }, { 2 }, { 5 }, { 10 }, { 100 } }; Block block = new ArrayBlock(Arrays.asList(rows1), new String[] { "a" }, 1); TupleOperator operator = new GroupByOperator(); Map<String, Block> input = new HashMap<String, Block>(); input.put("first", block); ObjectMapper mapper = new ObjectMapper(); ObjectNode json = mapper.createObjectNode(); json.put("input", "first"); ArrayNode anode = mapper.createArrayNode(); anode.add("a"); json.put("groupBy", anode); anode = mapper.createArrayNode(); ObjectNode onode = mapper.createObjectNode(); onode.put("type", "SUM"); onode.put("input", "a"); onode.put("output", "sum"); anode.add(onode); json.put("aggregates", anode); BlockProperties props = new BlockProperties(null, new BlockSchema("INT a, INT sum"), (BlockProperties) null); operator.setInput(input, json, props); Block output = new TupleOperatorBlock(operator, props); ArrayBlock.assertData(output, new Object[][] { { 0, 0 }, { 2, 4 }, { 5, 5 }, { 10, 10 }, { 100, 100 } }, new String[] { "a", "sum" }); }
Example 7
Source File: TestOperators.java From Cubert with Apache License 2.0 | 5 votes |
@Test public void testGroupByWithSum2() throws JsonGenerationException, JsonMappingException, IOException, InterruptedException { Object[][] rows1 = { { 0, 0 }, { 2, 2 }, { 2, 5 }, { 5, 6 }, { 10, 1 }, { 100, 10 } }; Block block = new ArrayBlock(Arrays.asList(rows1), new String[] { "a", "b" }, 1); TupleOperator operator = new GroupByOperator(); Map<String, Block> input = new HashMap<String, Block>(); input.put("first", block); ObjectMapper mapper = new ObjectMapper(); ObjectNode json = mapper.createObjectNode(); json.put("input", "first"); ArrayNode anode = mapper.createArrayNode(); anode.add("a"); json.put("groupBy", anode); anode = mapper.createArrayNode(); ObjectNode onode = mapper.createObjectNode(); onode.put("type", "SUM"); onode.put("input", "b"); onode.put("output", "sum"); anode.add(onode); json.put("aggregates", anode); BlockProperties props = new BlockProperties(null, new BlockSchema("INT a, INT sum"), (BlockProperties) null); operator.setInput(input, json, props); Block output = new TupleOperatorBlock(operator, props); ArrayBlock.assertData(output, new Object[][] { { 0, 0 }, { 2, 7 }, { 5, 6 }, { 10, 1 }, { 100, 10 } }, new String[] { "a", "sum" }); }
Example 8
Source File: TestOperators.java From Cubert with Apache License 2.0 | 5 votes |
@Test public void testSortOperator() throws JsonGenerationException, JsonMappingException, IOException, InterruptedException { System.out.println("Testing SORT operator"); Object[][] rows1 = { { 0, 10, 0 }, { 2, 5, 2 }, { 2, 8, 5 }, { 5, 9, 6 }, { 10, 11, 1 }, { 100, 6, 10 } }; Block block = new ArrayBlock(Arrays.asList(rows1), new String[] { "a", "b", "c" }, 1); TupleOperator operator = new SortOperator(); Map<String, Block> input = new HashMap<String, Block>(); input.put("unsorted", block); ObjectMapper mapper = new ObjectMapper(); ObjectNode json = mapper.createObjectNode(); json.put("input", "unsorted"); ArrayNode anode = mapper.createArrayNode(); anode.add("b"); anode.add("c"); json.put("sortBy", anode); BlockProperties props = new BlockProperties(null, new BlockSchema("INT a, INT b, INT c"), (BlockProperties) null); operator.setInput(input, json, props); Block output = new TupleOperatorBlock(operator, props); System.out.println("output is " + output); ArrayBlock.assertData(output, new Object[][] { { 2, 5, 2 }, { 100, 6, 10 }, { 2, 8, 5 }, { 5, 9, 6 }, { 0, 10, 0 }, { 10, 11, 1 } }, new String[] { "a", "b", "c" }); }
Example 9
Source File: TestOLAPCube.java From Cubert with Apache License 2.0 | 4 votes |
void validateGroupingSets(Object[][] rows, String[] expected, String[] groupingSets) throws JsonGenerationException, JsonMappingException, IOException, InterruptedException { /* Step 1: Create input block schema */ int ndims = rows[0].length - 1; String[] dimensions = new String[ndims]; String[] columnNames = new String[ndims + 1]; columnNames[0] = "clickCount"; StringBuffer typeName = new StringBuffer(); for (int i = 0; i < ndims; i++) { if (i > 0) typeName.append(","); typeName.append("int "); String name = "Dim" + i; typeName.append(name); columnNames[i + 1] = name; dimensions[i] = name; } BlockSchema inputSchema = new BlockSchema(typeName.toString()); /** Step 2: Create json */ ObjectMapper mapper = new ObjectMapper(); ObjectNode node = mapper.createObjectNode(); Configuration conf = new JobConf(); PhaseContext.create((MapContext) new TestContext(), conf); PhaseContext.create((ReduceContext) new TestContext(), conf); // add aggregates into json ArrayNode measures = mapper.createArrayNode(); measures.add(JsonUtils.createObjectNode("type", "SUM", "input", "clickCount", "output", "sum_clicks")); node.put("aggregates", measures); // add dimensions into json ArrayNode dimensionNode = mapper.createArrayNode(); for (int i = 0; i < dimensions.length; i++) dimensionNode.add(dimensions[i]); node.put("dimensions", dimensionNode); // add grouping sets into json ArrayNode groupingSetNode = mapper.createArrayNode(); if (groupingSets != null) for (String str : groupingSets) groupingSetNode.add(str); node.put("groupingSets", groupingSetNode); /** Step 3: create the input block */ HashMap<String, Block> map = new HashMap<String, Block>(); Block block = new ArrayBlock(Arrays.asList(rows), columnNames, 1); map.put("block", block); /** Step 4: create CUBE operator, initialize */ CubeOperator cd = new CubeOperator(); BlockSchema outputSchema = inputSchema.append(new BlockSchema("INT sum_clicks")); BlockProperties props = new BlockProperties(null, outputSchema, (BlockProperties) null); cd.setInput(map, node, props); /** Step 5: get the results from CUBE operator and put them in a set */ Set<String> computed = new HashSet<String>(); Tuple tuple; while ((tuple = cd.next()) != null) { computed.add(tuple.toString()); } /** Step 6: validate that computed and brute force results are same */ // System.out.println("Aggregated:" + computed); // System.out.println("Expected: " + java.util.Arrays.toString(expected)); Assert.assertEquals(computed.size(), expected.length); for (String entry : expected) { Assert.assertTrue(computed.contains(entry)); } }
Example 10
Source File: TestOperators.java From Cubert with Apache License 2.0 | 4 votes |
@Test public void testGroupByWith2Dimensions() throws JsonGenerationException, JsonMappingException, IOException, InterruptedException { Object[][] rows1 = { { 0, 0, 100 }, { 0, 0, 100 }, { 2, 2, 100 }, { 2, 5, 100 }, { 5, 6, 100 }, { 6, 6, 100 } }; Block block = new ArrayBlock(Arrays.asList(rows1), new String[] { "a", "b", "c" }, 1); Map<String, Block> input = new HashMap<String, Block>(); input.put("block", block); TupleOperator operator = new GroupByOperator(); ObjectMapper mapper = new ObjectMapper(); ObjectNode json = mapper.createObjectNode(); json.put("input", "block"); ArrayNode anode = mapper.createArrayNode(); anode.add("a"); anode.add("b"); json.put("groupBy", anode); anode = mapper.createArrayNode(); ObjectNode onode = mapper.createObjectNode(); onode.put("type", "SUM"); onode.put("input", "c"); onode.put("output", "sum"); anode.add(onode); json.put("aggregates", anode); BlockProperties props = new BlockProperties(null, new BlockSchema("INT a, INT b, INT sum"), (BlockProperties) null); operator.setInput(input, json, props); Block output = new TupleOperatorBlock(operator, props); ArrayBlock.assertData(output, new Object[][] { { 0, 0, 200 }, { 2, 2, 100 }, { 2, 5, 100 }, { 5, 6, 100 }, { 6, 6, 100 } }, new String[] { "a", "b", "sum" }); }
Example 11
Source File: TestOperators.java From Cubert with Apache License 2.0 | 4 votes |
@Test // testing multiple join keys public void testHashJoinMultipleJoinKeys() throws JsonGenerationException, JsonMappingException, IOException, InterruptedException { Object[][] rows1 = { { 0, 1 }, { 2, 1 }, { 2, 2 }, { 5, 1 }, { 10, 1 }, { 100, 1 } }; Object[][] rows2 = { { 1, 1 }, { 2, 0 }, { 2, 1 }, { 5, 1 }, { 100, 2 }, { 100, 3 } }; Object[][] expected = { { 2, 1, 2, 1 }, { 5, 1, 5, 1 } }; Block block1 = new ArrayBlock(Arrays.asList(rows1), new String[] { "a", "b" }); Block block2 = new ArrayBlock(Arrays.asList(rows2), new String[] { "c", "a" }); TupleOperator operator = new HashJoinOperator(); Map<String, Block> input = new HashMap<String, Block>(); input.put("block1", block1); input.put("block2", block2); ObjectMapper mapper = new ObjectMapper(); ObjectNode node = mapper.createObjectNode(); ArrayNode lkeys = mapper.createArrayNode(); lkeys.add("a"); lkeys.add("b"); node.put("leftJoinKeys", lkeys); ArrayNode rkeys = mapper.createArrayNode(); rkeys.add("c"); rkeys.add("a"); node.put("rightJoinKeys", rkeys); node.put("leftBlock", "block1"); BlockProperties props = new BlockProperties(null, new BlockSchema("INT block1___a, INT block1___b, INT block2___c, INT block2___a"), (BlockProperties) null); operator.setInput(input, node, props); Block output = new TupleOperatorBlock(operator, props); ArrayBlock.assertData(output, expected, new String[] { "block1.a", "block2.a" }); }
Example 12
Source File: TestOperators.java From Cubert with Apache License 2.0 | 4 votes |
@Test // testing multiple join keys public void testHashJoinMultipleJoinKeysInDifferentOrder() throws JsonGenerationException, JsonMappingException, IOException, InterruptedException { Object[][] rows1 = { { 0, 1 }, { 2, 1 }, { 2, 2 }, { 5, 1 }, { 10, 1 }, { 100, 1 } }; Object[][] rows2 = { { 1, 1 }, { 2, 0 }, { 2, 1 }, { 5, 1 }, { 100, 2 }, { 100, 3 } }; Object[][] expected = { { 0, 1, 2, 0 }, { 2, 1, 100, 2 }, { 2, 2, 100, 2 } }; Block block1 = new ArrayBlock(Arrays.asList(rows1), new String[] { "a", "b" }); Block block2 = new ArrayBlock(Arrays.asList(rows2), new String[] { "a", "c" }); TupleOperator operator = new HashJoinOperator(); Map<String, Block> input = new HashMap<String, Block>(); input.put("block1", block1); input.put("block2", block2); ObjectMapper mapper = new ObjectMapper(); ObjectNode node = mapper.createObjectNode(); ArrayNode lkeys = mapper.createArrayNode(); lkeys.add("a"); node.put("leftJoinKeys", lkeys); ArrayNode rkeys = mapper.createArrayNode(); rkeys.add("c"); node.put("rightJoinKeys", rkeys); node.put("leftBlock", "block1"); BlockProperties props = new BlockProperties(null, new BlockSchema("INT block1___a, INT block1___b, INT block2___c, INT block2___a"), (BlockProperties) null); operator.setInput(input, node, props); Block output = new TupleOperatorBlock(operator, props); ArrayBlock.assertData(output, expected, new String[] { "block1.a", "block2.c" }); }
Example 13
Source File: TestOperators.java From Cubert with Apache License 2.0 | 4 votes |
@Test // testing multiple join keys public void testMergeJoinMultipleJoinKeys() throws JsonGenerationException, JsonMappingException, IOException, InterruptedException { Object[][] rows1 = { { 0, 1 }, { 2, 1 }, { 2, 2 }, { 5, 1 }, { 10, 1 }, { 100, 1 } }; Object[][] rows2 = { { 1, 1 }, { 2, 0 }, { 2, 1 }, { 5, 1 }, { 100, 2 }, { 100, 3 } }; Object[][] expected = { { 2, 1, 2, 1 }, { 5, 1, 5, 1 } }; Block block1 = new ArrayBlock(Arrays.asList(rows1), new String[] { "a", "b" }); Block block2 = new ArrayBlock(Arrays.asList(rows2), new String[] { "c", "a" }); TupleOperator operator = new MergeJoinOperator(); Map<String, Block> input = new HashMap<String, Block>(); input.put("block1", block1); input.put("block2", block2); ObjectMapper mapper = new ObjectMapper(); ObjectNode node = mapper.createObjectNode(); ArrayNode lkeys = mapper.createArrayNode(); lkeys.add("a"); lkeys.add("b"); node.put("leftCubeColumns", lkeys); ArrayNode rkeys = mapper.createArrayNode(); rkeys.add("c"); rkeys.add("a"); node.put("rightCubeColumns", rkeys); node.put("leftBlock", "block1"); BlockProperties props = new BlockProperties(null, new BlockSchema("INT block1___a, INT block1___b, INT block2___c, INT block2___a"), (BlockProperties) null); operator.setInput(input, node, props); Block output = new TupleOperatorBlock(operator, props); ArrayBlock.assertData(output, expected, new String[] { "block1.a", "block2.a" }); }
Example 14
Source File: TestOperators.java From Cubert with Apache License 2.0 | 4 votes |
@Test public void testGroupByWithMin() throws JsonGenerationException, JsonMappingException, IOException, InterruptedException { Object[][] rows1 = { { 0, 0 }, { 2, 2 }, { 2, 5 }, { 5, 6 }, { 10, 1 }, { 10, 20 }, { 100, 10 }, { 100, 1 } }; Block block = new ArrayBlock(Arrays.asList(rows1), new String[] { "a", "b" }, 1); TupleOperator operator = new GroupByOperator(); Map<String, Block> input = new HashMap<String, Block>(); input.put("first", block); ObjectMapper mapper = new ObjectMapper(); ObjectNode json = mapper.createObjectNode(); json.put("input", "first"); ArrayNode anode = mapper.createArrayNode(); anode.add("a"); json.put("groupBy", anode); anode = mapper.createArrayNode(); ObjectNode onode = mapper.createObjectNode(); onode.put("type", "MIN"); onode.put("input", "b"); onode.put("output", "min"); anode.add(onode); json.put("aggregates", anode); BlockProperties props = new BlockProperties(null, new BlockSchema("INT a, INT min"), (BlockProperties) null); operator.setInput(input, json, props); Block output = new TupleOperatorBlock(operator, props); ArrayBlock.assertData(output, new Object[][] { { 0, 0 }, { 2, 2 }, { 5, 6 }, { 10, 1 }, { 100, 1 } }, new String[] { "a", "min" }); }
Example 15
Source File: TestOperators.java From Cubert with Apache License 2.0 | 4 votes |
@Test public void testGroupByWithCount() throws JsonGenerationException, JsonMappingException, IOException, InterruptedException { Object[][] rows1 = { { 0, 0 }, { 2, 2 }, { 2, 5 }, { 5, 6 }, { 10, 1 }, { 10, 20 }, { 100, 10 }, { 100, 1 } }; Block block = new ArrayBlock(Arrays.asList(rows1), new String[] { "a", "b" }, 1); TupleOperator operator = new GroupByOperator(); Map<String, Block> input = new HashMap<String, Block>(); input.put("first", block); ObjectMapper mapper = new ObjectMapper(); ObjectNode json = mapper.createObjectNode(); json.put("input", "first"); ArrayNode anode = mapper.createArrayNode(); anode.add("a"); json.put("groupBy", anode); anode = mapper.createArrayNode(); ObjectNode onode = mapper.createObjectNode(); onode.put("type", "COUNT"); onode.put("input", "b"); onode.put("output", "countCol"); anode.add(onode); json.put("aggregates", anode); BlockProperties props = new BlockProperties(null, new BlockSchema("INT a, LONG countCol"), (BlockProperties) null); operator.setInput(input, json, props); Block output = new TupleOperatorBlock(operator, props); ArrayBlock.assertData(output, new Object[][] { { 0, 1L }, { 2, 2L }, { 5, 1L }, { 10, 2L }, { 100, 2L } }, new String[] { "a", "countCol" }); }
Example 16
Source File: TestOperators.java From Cubert with Apache License 2.0 | 4 votes |
@Test public void testGroupByWithMax() throws JsonGenerationException, JsonMappingException, IOException, InterruptedException { Object[][] rows1 = { { 0, 0 }, { 2, 2 }, { 2, 5 }, { 5, 6 }, { 10, 1 }, { 10, 20 }, { 100, 10 }, { 100, 1 } }; Block block = new ArrayBlock(Arrays.asList(rows1), new String[] { "a", "b" }, 1); TupleOperator operator = new GroupByOperator(); Map<String, Block> input = new HashMap<String, Block>(); input.put("first", block); ObjectMapper mapper = new ObjectMapper(); ObjectNode json = mapper.createObjectNode(); json.put("input", "first"); ArrayNode anode = mapper.createArrayNode(); anode.add("a"); json.put("groupBy", anode); anode = mapper.createArrayNode(); ObjectNode onode = mapper.createObjectNode(); onode.put("type", "MAX"); onode.put("input", "b"); onode.put("output", "max"); anode.add(onode); json.put("aggregates", anode); BlockProperties props = new BlockProperties(null, new BlockSchema("INT a, INT max"), (BlockProperties) null); operator.setInput(input, json, props); Block output = new TupleOperatorBlock(operator, props); ArrayBlock.assertData(output, new Object[][] { { 0, 0 }, { 2, 5 }, { 5, 6 }, { 10, 20 }, { 100, 10 } }, new String[] { "a", "max" }); }
Example 17
Source File: TestOperators.java From Cubert with Apache License 2.0 | 4 votes |
@Test public void testGroupByWithNullInputs() throws JsonGenerationException, JsonMappingException, IOException, InterruptedException { Object[][] rows1 = {{0, 0}, {1, null}, {2, 2}, {2, 5}, {2, null}, {3, null}, {3, null}, {3, null}, {5, 6}, {8, null}, {8, null}, {8, null}, {8, 0}, {8, null}, {10, 1}, {18, 0}, {18, null}, {18, 0}, {18, null}, {100, 10}}; Block block = new ArrayBlock(Arrays.asList(rows1), new String[] { "a", "b" }, 1); TupleOperator operator = new GroupByOperator(); Map<String, Block> input = new HashMap<String, Block>(); input.put("first", block); ObjectMapper mapper = new ObjectMapper(); ObjectNode json = mapper.createObjectNode(); json.put("input", "first"); ArrayNode anode = mapper.createArrayNode(); anode.add("a"); json.put("groupBy", anode); anode = mapper.createArrayNode(); ObjectNode onode = mapper.createObjectNode(); onode.put("type", "SUM"); onode.put("input", "b"); onode.put("output", "sum"); anode.add(onode); onode = mapper.createObjectNode(); onode.put("type", "MIN"); onode.put("input", "b"); onode.put("output", "min"); anode.add(onode);onode = mapper.createObjectNode(); onode.put("type", "MAX"); onode.put("input", "b"); onode.put("output", "max"); anode.add(onode); onode = mapper.createObjectNode(); onode.put("type", "COUNT"); onode.put("input", "b"); onode.put("output", "count"); anode.add(onode); json.put("aggregates", anode); BlockProperties props = new BlockProperties(null, new BlockSchema("INT a, INT sum, INT min, INT max, INT count"), (BlockProperties) null); operator.setInput(input, json, props); Block output = new TupleOperatorBlock(operator, props); ArrayBlock.assertData(output, new Object[][] { { 0, 0, 0, 0, 1 }, { 1, null, null, null, null, 0}, { 2, 7, 2, 5, 2}, {3, null, null, 0}, { 5, 6, 6, 6, 1}, {8, 0, 0, 0, 1}, { 10, 1 , 1, 1, 1}, {18, 0, 0, 0, 2}, { 100, 10, 10, 10, 1} }, new String[] { "a", "sum" }); }