Java Code Examples for org.codehaus.jackson.node.ArrayNode#add()

The following examples show how to use org.codehaus.jackson.node.ArrayNode#add() . 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: HttpMetricsIndexHandler.java    From blueflood with Apache License 2.0 7 votes vote down vote up
public static String getSerializedJSON(List<SearchResult> searchResults) {
    ArrayNode resultArray = JsonNodeFactory.instance.arrayNode();
    for (SearchResult result : searchResults) {
        ObjectNode resultNode = JsonNodeFactory.instance.objectNode();
        resultNode.put("metric", result.getMetricName());

        String unit = result.getUnit();
        if (unit != null) {
            //Preaggreated metrics do not have units. Do not want to return null units in query results.
            resultNode.put("unit", unit);
        }

        resultArray.add(resultNode);
    }
    return resultArray.toString();
}
 
Example 2
Source File: MovieTO.java    From big-data-lite with MIT License 6 votes vote down vote up
/** This method returns JSON object with all the movie attributes and its
 * values**/
public ObjectNode getMovieJson() {
    ObjectNode movieJson = new ObjectNode(factory);
    ArrayNode genreArray = new ArrayNode(factory);
    ObjectNode genreJson = null;

    movieJson.put(JsonConstant.ID, this.getId());
    movieJson.put(JsonConstant.TITLE, this.getTitle());
    movieJson.put(JsonConstant.RELEASE_DATE, this.getDate());
    movieJson.put(JsonConstant.OVERVIEW, this.getOverview());
    movieJson.put(JsonConstant.VOTE, this.getVoteCount());
    movieJson.put(JsonConstant.POPULARITY, this.getPopularity());
    movieJson.put(JsonConstant.POSTER, this.getPosterPath());
    movieJson.put(JsonConstant.RUNTIME, this.getRunTime());


    for (GenreTO genreTO : genres) {
        genreJson = genreTO.getGenreJson();
        genreArray.add(genreJson);
    } //EOF for

    //set genres to movie json object
    movieJson.put(JsonConstant.GENRES, genreArray);

    return movieJson;
}
 
Example 3
Source File: RewriteUtils.java    From Cubert with Apache License 2.0 6 votes vote down vote up
private static ObjectNode createdNestedColumnNode(String gcol)
{

    String[] nestedFields = gcol.split("\\.");
    if (nestedFields.length < 2)
        throw new RuntimeException("Too few arguments in nested column expression for column " + gcol + " split array len =" + nestedFields.length);
    ObjectNode toplevelColumn = createSimpleColumnNode(nestedFields[0]);

    ObjectNode childNode = toplevelColumn;
    ObjectNode resultNode = toplevelColumn;
    for (int i = 1; i < nestedFields.length; i++)
    {

        resultNode = JsonUtils.createObjectNode();
        resultNode.put("function", "PROJECTION");
        ArrayNode argsNode = JsonUtils.createArrayNode();
        argsNode.add(childNode);
        argsNode.add(nestedFields[i]);
        resultNode.put("arguments", argsNode);
        childNode = resultNode;

    }
    return resultNode;
}
 
Example 4
Source File: StencilsetServiceImpl.java    From fixflow with Apache License 2.0 6 votes vote down vote up
/**
 * 初始化处理命令类型
 * @param rootNode
 */
private void initTaskCommandType(JsonNode rootNode){
	 ArrayNode baseNodeArray = (ArrayNode)rootNode.get("propertyPackages");
        JsonNode commandInfoBase = JsonConverterUtil.getChildElementByProperty("commandinfobase", "name", baseNodeArray);
        commandInfoBase = commandInfoBase.get("properties").get(0);
        ArrayNode complexItemsNode =(ArrayNode)commandInfoBase.get("complexItems");
        JsonNode commandType = JsonConverterUtil.getChildElementByProperty("commandtype", "id", complexItemsNode);
        ArrayNode arrayNode = objectMapper.createArrayNode();
        TaskCommandConfig  taskCommandConfig = ProcessEngineManagement.getDefaultProcessEngine().getProcessEngineConfiguration().getTaskCommandConfig();
        List<TaskCommandDef> commandDefs = taskCommandConfig.getTaskCommandDef();
        for(TaskCommandDef taskCommandDef :commandDefs){
        	 ObjectNode typeNode = objectMapper.createObjectNode();
        	 if(StringUtil.getBoolean(taskCommandDef.getIsEnabled())&& !"system".equals(taskCommandDef.getType())){
        		 typeNode.put("id",taskCommandDef.getId());
                typeNode.put("title", taskCommandDef.getName());
                typeNode.put("value", taskCommandDef.getId());
                typeNode.put("refToView", "");
                arrayNode.add(typeNode);
        	 }
        }
        ((ObjectNode)commandType).put("items", arrayNode);
}
 
Example 5
Source File: PhysicalParser.java    From Cubert with Apache License 2.0 6 votes vote down vote up
private ObjectNode createProjectionConstantNode(ColumnProjectionExpressionContext columnexpr)
{
    // create constant object
    ObjectNode constant = objMapper.createObjectNode();
    constant.put("function", "CONSTANT");
    ArrayNode constantArgs = objMapper.createArrayNode();
    constant.put("arguments", constantArgs);

    if (columnexpr.ID() != null)
    {
        constantArgs.add(columnexpr.ID().getText());
    }
    else
    {
        constantArgs.add(Integer.parseInt(columnexpr.INT().getText()));
    }

    return constant;
}
 
Example 6
Source File: PhysicalParser.java    From Cubert with Apache License 2.0 6 votes vote down vote up
public ArrayNode createConstructorArgsNode(String functionName,
                                           List<Object> constructorArgs)
{
    ArrayNode constructorArgsNode = null;
    constructorArgsNode = objMapper.createArrayNode();
    if (constructorArgs != null && !constructorArgs.isEmpty())
    {
        for (Object constructorArg : constructorArgs)
        {
            if (constructorArg instanceof Boolean)
                constructorArgsNode.add((boolean) (Boolean) constructorArg);
            else if (constructorArg instanceof Integer)
                constructorArgsNode.add((int) (Integer) constructorArg);
            else if (constructorArg instanceof Float)
                constructorArgsNode.add((float) (Float) constructorArg);
            else if (constructorArg instanceof String)
                constructorArgsNode.add((String) constructorArg);
            else
                throw new RuntimeException(String.format("%s UDF cannot have [%s] of type %s as constructor argument",
                                                         functionName,
                                                         constructorArg,
                                                         constructorArg.getClass()));
        }
    }
    return constructorArgsNode;
}
 
Example 7
Source File: ShuffleRewriter.java    From Cubert with Apache License 2.0 6 votes vote down vote up
@Override
public JsonNode rewrite(JsonNode plan,
                        Set<String> namesUsed,
                        boolean debugMode,
                        boolean revisit)
{
    this.namesUsed = namesUsed;

    ObjectNode newPlan = (ObjectNode) cloneNode(plan);

    ArrayNode jobs = mapper.createArrayNode();

    for (JsonNode job : plan.path("jobs"))
    {
        jobs.add(rewriteJob(job));
    }

    newPlan.remove("jobs");
    newPlan.put("jobs", jobs);

    return newPlan;
}
 
Example 8
Source File: MetadataResource.java    From Eagle with Apache License 2.0 6 votes vote down vote up
@GET
	@Path(PATH_SERVICE)
	@Produces(MediaType.APPLICATION_JSON)
	public Response listAllEntities(@Context Application application,
                                     @Context HttpServletRequest request) throws Exception {
		Map<String,EntityDefinition> entities = EntityDefinitionManager.entities();
		ObjectNode root = JsonNodeFactory.instance.objectNode();

		ArrayNode services = JsonNodeFactory.instance.arrayNode();

		for(Map.Entry<String,EntityDefinition> entry : entities.entrySet()){
//			ObjectNode serviceNode = JsonNodeFactory.instance.objectNode();
//			serviceNode.put(entry.getKey(),entityDefationitionAsJson(entry.getValue()));
			services.add(entityDefationitionAsJson(entry.getValue()));
		}
		root.put("count",entities.keySet().size());
		root.put("services",services);
		return Response.ok().entity(root).build();
	}
 
Example 9
Source File: PhysicalParser.java    From Cubert with Apache License 2.0 5 votes vote down vote up
@Override
public void exitGatherOperator(GatherOperatorContext ctx)
{
    operatorNode.put("operator", "GATHER");
    operatorNode.put("output", operatorCommandLhs);
    ArrayNode anode = objMapper.createArrayNode();
    for (TerminalNode id : ctx.ID())
        anode.add(id.getText());
    operatorNode.put("input", anode);
}
 
Example 10
Source File: JsonResponseUtil.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
public static ObjectNode buildResponseJSON(List<? extends Object> list) {
  ObjectNode rootNode = MAPPER.getNodeFactory().objectNode();
  ArrayNode resultArrayNode = MAPPER.createArrayNode();
  rootNode.put("Result", "OK");
  for (Object obj : list) {
    JsonNode node = MAPPER.convertValue(obj, JsonNode.class);
    resultArrayNode.add(node);
  }
  rootNode.put("Records", resultArrayNode);
  return rootNode;
}
 
Example 11
Source File: TestOperators.java    From Cubert with Apache License 2.0 5 votes vote down vote up
@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 12
Source File: PhysicalParser.java    From Cubert with Apache License 2.0 5 votes vote down vote up
private JsonNode createGroupingSetsNode(GroupingSetsClauseContext groupingSetsClause)
{
    ArrayNode groupingSetsNode = objMapper.createArrayNode();
    for (CuboidContext cuboidContext : groupingSetsClause.cuboid())
    {
        StringBuffer cuboidBuffer = new StringBuffer();
        emitCommaSeparatedIDList(cuboidBuffer,
                                 cuboidContext.columns().ID(),
                                 false);
        groupingSetsNode.add(cuboidBuffer.toString());
    }
    return groupingSetsNode;
}
 
Example 13
Source File: MetadataResource.java    From Eagle with Apache License 2.0 5 votes vote down vote up
private JsonNode entityDefationitionAsJson(EntityDefinition def) {
	ObjectNode node = JsonNodeFactory.instance.objectNode();
	node.put("service",def.getService());
	node.put("entityClass",def.getEntityClass().getName());
	node.put("table",def.getTable());
	node.put("columnFamily",def.getColumnFamily());
	node.put("prefix",def.getPrefix());
	if(def.getPartitions()!=null){
		node.put("partitions",arrayNode(def.getPartitions()));
	}
	node.put("isTimeSeries",def.isTimeSeries());

	MetricDefinition mdf = def.getMetricDefinition();
	if(mdf!=null){
		node.put("interval", mdf.getInterval());
	}

	IndexDefinition[] indexDef = def.getIndexes();
	if(indexDef!=null){
		ArrayNode indexDefArray = JsonNodeFactory.instance.arrayNode();
		for(IndexDefinition idef : indexDef){
			ObjectNode idn = JsonNodeFactory.instance.objectNode();
			idn.put("indexPrefix",idef.getIndexPrefix());

			if(idef.getIndex()!=null){
				ObjectNode index = JsonNodeFactory.instance.objectNode();
				index.put("name",idef.getIndex().name());
				index.put("columns",arrayNode(idef.getIndex().columns()));
				idn.put("index",index);
			}

			indexDefArray.add(idn);
		}
		node.put("indexs",indexDefArray);
	}
	return node;
}
 
Example 14
Source File: StencilsetServiceImpl.java    From fixflow with Apache License 2.0 5 votes vote down vote up
/**
 * 初始化任务分配中的资源类型
 */
private void initGroupInfo(JsonNode rootNode){
	ArrayNode baseNodeArray = (ArrayNode)rootNode.get("propertyPackages");
       JsonNode taskAssignBase = JsonConverterUtil.getChildElementByProperty("taskassignbase", "name", baseNodeArray);
       taskAssignBase = taskAssignBase.get("properties");
       JsonNode potentialownerNode = JsonConverterUtil.getChildElementByProperty("potentialowner", "id", (ArrayNode)taskAssignBase);
       
       JsonNode complexItemsNode = potentialownerNode.get("complexItems");
       JsonNode resourceType = JsonConverterUtil.getChildElementByProperty("resourcetype", "id", (ArrayNode)complexItemsNode);
       
       ArrayNode arrayNode = objectMapper.createArrayNode();
       ObjectNode typeNode = objectMapper.createObjectNode();
	typeNode.put("id","user");
       typeNode.put("title", "用户");
       typeNode.put("value", "user");
       arrayNode.add(typeNode);
       
       List<GroupDefinition> groupDefinitions = ProcessEngineManagement.getDefaultProcessEngine().getProcessEngineConfiguration().getGroupDefinitions();
       for(GroupDefinition groupDefinition :groupDefinitions){
       	ObjectNode objectNode = objectMapper.createObjectNode();
       	objectNode.put("id",groupDefinition.getId());
       	objectNode.put("title", groupDefinition.getName());
       	objectNode.put("value", groupDefinition.getId());
           arrayNode.add(objectNode);
       }
       ((ObjectNode)resourceType).put("items", arrayNode);
}
 
Example 15
Source File: CastCrewTO.java    From big-data-lite with MIT License 5 votes vote down vote up
public ObjectNode getJsonObject() {
    castCrewNode = super.getObjectNode();
    ObjectNode node = null;
    ArrayNode castArray = super.getArrayNode();
    ArrayNode crewArray = super.getArrayNode();

    castCrewNode.put(JsonConstant.ID, this.getMovieId());
    castCrewNode.put(JsonConstant.MID, this.getMovieId());

    if (castList != null) {
        for (CastTO castTO : castList) {
            node = castTO.geCastJson();
            castArray.add(node);
        } //EOF for
    }
    if (crewList != null) {
        for (CrewTO crewTO : crewList) {
            node = crewTO.getCrewJson();
            crewArray.add(node);
        } //EOF for
    }
    //set cast to this object
    castCrewNode.put(JsonConstant.CAST, castArray);

    //set crew to this object
    castCrewNode.put(JsonConstant.CREW, crewArray);
    return castCrewNode;
}
 
Example 16
Source File: PhysicalParser.java    From Cubert with Apache License 2.0 5 votes vote down vote up
@Override
public void exitMapReduceJob(@NotNull MapReduceJobContext ctx)
{
    mapReduceJobNode.put("name", CommonUtils.stripQuotes(ctx.STRING().getText()));

    int mappersCount =
            (ctx.mappersCount == null) ? 0
                    : Integer.parseInt(ctx.mappersCount.getText());
    int reducersCount =
            (ctx.reducersCount == null) ? 0
                    : Integer.parseInt(ctx.reducersCount.getText());

    mapReduceJobNode.put("mappers", mappersCount);
    mapReduceJobNode.put("reducers", reducersCount);

    // removing and adding the "map" field in the json object
    // stupid hack to ensure that the map section is printed after name and
    // reducers (only needed for pretty printing)
    JsonNode mapNode = mapReduceJobNode.get("map");
    mapReduceJobNode.remove("map");
    mapReduceJobNode.put("map", mapNode);

    mapReduceJobNode.put("shuffle", this.shuffleCommandNode);
    mapReduceJobNode.put("reduce", this.reduceCommandsNode);
    if (this.cacheIndexNode != null)
        mapReduceJobNode.put("cacheIndex", this.cacheIndexNode);
    if (!this.cachedFiles.isEmpty())
    {
        ArrayNode anode = objMapper.createArrayNode();
        for (String cachedFile : cachedFiles)
            anode.add(cachedFile);
        mapReduceJobNode.put("cachedFiles", anode);
    }
    mapReduceJobNode.put("output", this.outputCommandNode);
    this.cacheIndexNode = objMapper.createArrayNode();
    jobsNode.add(mapReduceJobNode);
}
 
Example 17
Source File: UIResource.java    From exhibitor with Apache License 2.0 5 votes vote down vote up
@Path("backup-config")
@GET
@Produces(MediaType.APPLICATION_JSON)
public String getBackupConfig() throws Exception
{
    ArrayNode           node = JsonNodeFactory.instance.arrayNode();

    if ( context.getExhibitor().getBackupManager().isActive() )
    {
        EncodedConfigParser parser = context.getExhibitor().getBackupManager().getBackupConfigParser();
        List<BackupConfigSpec>  configs = context.getExhibitor().getBackupManager().getConfigSpecs();
        for ( BackupConfigSpec c : configs )
        {
            ObjectNode      n = JsonNodeFactory.instance.objectNode();
            String          value = parser.getValue(c.getKey());

            n.put("key", c.getKey());
            n.put("name", c.getDisplayName());
            n.put("help", c.getHelpText());
            n.put("value", (value != null) ? value : "");
            n.put("type", c.getType().name().toLowerCase().substring(0, 1));

            node.add(n);
        }
    }

    return JsonUtil.writeValueAsString(node);
}
 
Example 18
Source File: CountDistinctRewriter.java    From Cubert with Apache License 2.0 4 votes vote down vote up
private void insertIncrementalMultipleDayGroupBy(ObjectNode programNode,
                                                 Pair<ObjectNode, ObjectNode> bgInfo) throws AggregateRewriteException
{
    String[] factColumns = lineage.getSchemaOutputColumns(bgInfo.getSecond());
    String[] sortKeys;
    String[] groupByColumns;

    if (lineage.isBlockgenByIndex(bgInfo.getSecond()))
    {
        ObjectNode jobNode = lineage.getOperatorJobNode(bgInfo.getSecond());
        sortKeys =      JsonUtils.asArray(((ObjectNode) (jobNode.get("shuffle"))).get("pivotKeys"));
        groupByColumns =
                (String[]) ArrayUtils.addAll(new String[] { "BLOCK_ID" }, factColumns);
    }
    else {
        sortKeys = JsonUtils.asArray(bgInfo.getSecond().get("pivotKeys"));
        groupByColumns = factColumns;
    }

    // check sort key condition
    if (!CommonUtils.isPrefix(sortKeys, groupByColumns))
      throw new AggregateRewriteException("Blockgen of union fact not sorted by fact collumns");

    ArrayNode aggsNode = JsonUtils.createArrayNode();
    ArrayNode udafArgsNode = JsonUtils.createArrayNode();

    String startDateHyphenated = DateTimeUtilities.getHyphenated(this.factStartDate);
    udafArgsNode.add(startDateHyphenated);
    aggsNode.add(RewriteUtils.createObjectNode("type",
                                               "USER_DEFINED_AGGREGATION",
                                               "udaf",
                                               "com.linkedin.cubert.operator.aggregate.PresenceBitmapUDAF",
                                               "constructorArgs",
                                               udafArgsNode,
                                               "input",
                                               DATE_COLUMN_NAME,
                                               "output",
                                               BITMAP_COLUMN_NAME));
    String blockgenInputRelation =
            lineage.getOperatorSources(bgInfo.getSecond())
                   .get(0)
                   .get("output")
                   .getTextValue();
    ObjectNode groupByNode =
            RewriteUtils.createObjectNode("operator",
                                          "GROUP_BY",
                                          "input",
                                          blockgenInputRelation,
                                          "output",
                                          blockgenInputRelation,
                                          "groupBy",
                                          JsonUtils.createArrayNode(groupByColumns),
                                          "aggregates",
                                          aggsNode);

    ArrayNode phaseOperators =
            lineage.getPhaseOperators(lineage.getPhase(bgInfo.getSecond()));
    int blockGenIndex = 0;
    for (; blockGenIndex < phaseOperators.size(); blockGenIndex++)
    {
        if (phaseOperators.get(blockGenIndex) == bgInfo.getSecond())
            break;
    }
    if (blockGenIndex == phaseOperators.size())
        throw new RuntimeException("Cannot find CREATE_BLOCK operator in phase operator list");
    phaseOperators.insert(blockGenIndex, groupByNode);
    // phaseOperators.insert(blockGenIndex + 1, generateNode);

}
 
Example 19
Source File: TestOLAPCube.java    From Cubert with Apache License 2.0 4 votes vote down vote up
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 20
Source File: TestOperators.java    From Cubert with Apache License 2.0 4 votes vote down vote up
@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" });
}