org.codehaus.jackson.node.ObjectNode Java Examples

The following examples show how to use org.codehaus.jackson.node.ObjectNode. 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: ShuffleRewriter.java    From Cubert with Apache License 2.0 6 votes vote down vote up
private JsonNode rewriteDistinct(JsonNode job)
{
    ObjectNode newJob = (ObjectNode) cloneNode(job);
    ObjectNode shuffle = (ObjectNode) newJob.get("shuffle");
    String name = getText(shuffle, "name");

    ObjectNode distinctOp =
            JsonUtils.createObjectNode("operator",
                                       "DISTINCT",
                                       "input",
                                       name,
                                       "output",
                                       name);

    if (!newJob.has("reduce") || newJob.get("reduce").isNull())
        newJob.put("reduce", mapper.createArrayNode());
    ArrayNode reduce = (ArrayNode) newJob.get("reduce");
    reduce.insert(0, distinctOp);

    shuffle.put("type", "SHUFFLE");
    shuffle.put("distinctShuffle", true);

    return newJob;
}
 
Example #2
Source File: CrewTO.java    From big-data-lite with MIT License 6 votes vote down vote up
public ObjectNode getCrewJson() {
    this.crewNode = super.getObjectNode();

    ObjectNode movieNode = null;
    ArrayNode movieArray = super.getArrayNode();

    crewNode.put(JsonConstant.ID, this.getId());
    crewNode.put(JsonConstant.NAME, this.getName());
    crewNode.put(JsonConstant.JOB, this.getJob());

    if (getMovieList() != null && getMovieList().size() > 0) {
        for (String movieId : this.getMovieList()) {
            movieNode = super.getObjectNode();
            movieNode.put(JsonConstant.ID, Integer.parseInt(movieId));
            movieArray.add(movieNode);
        } //EOF for

        //set cast to this object
        crewNode.put(JsonConstant.MOVIES, movieArray);
    }
    return crewNode;
}
 
Example #3
Source File: JobAccessor.java    From helix with Apache License 2.0 6 votes vote down vote up
@GET
public Response getJobs(@PathParam("clusterId") String clusterId,
    @PathParam("workflowName") String workflowName) {
  TaskDriver driver = getTaskDriver(clusterId);
  WorkflowConfig workflowConfig = driver.getWorkflowConfig(workflowName);
  ObjectNode root = JsonNodeFactory.instance.objectNode();

  if (workflowConfig == null) {
    return badRequest(String.format("Workflow %s is not found!", workflowName));
  }

  Set<String> jobs = workflowConfig.getJobDag().getAllNodes();
  root.put(Properties.id.name(), JobProperties.Jobs.name());
  ArrayNode jobsNode = root.putArray(JobProperties.Jobs.name());

  if (jobs != null) {
    jobsNode.addAll((ArrayNode) OBJECT_MAPPER.valueToTree(jobs));
  }
  return JSONRepresentation(root);
}
 
Example #4
Source File: PluginBusinessServiceImpl.java    From seldon-server with Apache License 2.0 6 votes vote down vote up
@Override
public JsonNode telepath_tag_prediction(final ConsumerBean consumerBean,final String client_item_id,final String attrName) 
{
	
	PluginProvider telepathProvider = findPlugin(consumerBean.getShort_name(), PLUGIN_TELEPATH_NAME);
	if (telepathProvider != null)
	{
		// get item and text
		ItemBean item = itemService.getItem(consumerBean, client_item_id, true);
		String text = item.getAttributesName().get(attrName);
		ObjectMapper mapper = new ObjectMapper();
		ObjectNode dataTable = mapper.createObjectNode();
		dataTable.put("text", text);
		OptionsHolder optsHolder = new OptionsHolder(defaultOptions, telepathProvider.config);
		return telepathProvider.pluginService.execute(dataTable,optsHolder);
	}
	else
		throw new APIException(APIException.PLUGIN_NOT_ENABLED);
}
 
Example #5
Source File: JobHistoryEventHandler.java    From big-c with Apache License 2.0 6 votes vote down vote up
@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 #6
Source File: ClusterResource.java    From exhibitor with Apache License 2.0 6 votes vote down vote up
@Path("state")
@GET
@Produces(MediaType.APPLICATION_JSON)
public String   getStatus() throws Exception
{
    ObjectNode          mainNode = JsonNodeFactory.instance.objectNode();

    ObjectNode          switchesNode = JsonNodeFactory.instance.objectNode();
    for ( ControlPanelTypes type : ControlPanelTypes.values() )
    {
        switchesNode.put(UIResource.fixName(type), context.getExhibitor().getControlPanelValues().isSet(type));
    }
    mainNode.put("switches", switchesNode);

    MonitorRunningInstance  monitorRunningInstance = context.getExhibitor().getMonitorRunningInstance();
    InstanceStateTypes      state = monitorRunningInstance.getCurrentInstanceState();
    mainNode.put("state", state.getCode());
    mainNode.put("description", state.getDescription());
    mainNode.put("isLeader", monitorRunningInstance.isCurrentlyLeader());

    return JsonUtil.writeValueAsString(mainNode);
}
 
Example #7
Source File: Lineage.java    From Cubert with Apache License 2.0 6 votes vote down vote up
private void addJoinKeyLineageToOtherInput(ObjectNode opNode, 
                                           List<OutputColumn> sourceCols,
                                           String relationName,
                                           String colName)
{
  // nothing to do for outer joins
  if (opNode.get("joinType") != null)
    return;
  String[] inputRelations = JsonUtils.asArray(opNode.get("input"));
  int relpos =  inputRelations[0].equals(relationName) ? LEFT: RIGHT;
  String[] joinKeys = getJoinKeys(opNode,relpos);
  List<String> joinKeysList = Arrays.asList(joinKeys);
  int colIdx = joinKeysList.indexOf(colName);
  if (colIdx == -1)
    return;
  String[] otherJoinKeys = getJoinKeys(opNode, (relpos == LEFT ? RIGHT: LEFT));
  String otherColName = otherJoinKeys[colIdx];
  String otherRelationName = inputRelations[(relpos==LEFT? 1: 0)];
  List<ObjectNode> sourceOps = preLineageInfo.findOperatorInputSources(opNode, otherRelationName);
  for (ObjectNode sourceOp: sourceOps)
    sourceCols.add(new OutputColumn(sourceOp, otherColName));
}
 
Example #8
Source File: WebModelServiceImpl.java    From fixflow with Apache License 2.0 6 votes vote down vote up
/**
 * 二次请求模型信息
 */
public void reTryModelInfo(){
	PrintWriter out = null;
	try {
		FixFlowConverter fixFlowConverter = new FixFlowConverter();
		
   		ObjectMapper objectMapper = new ObjectMapper();
           InputStream input = new FileInputStream(buildPath() +File.separator+request.getParameter("fileName")); 
           Definitions definitions = fixFlowConverter.getDefinitions("process_1", input);
           Process process = (Process)definitions.getRootElements().get(0);
   		ObjectNode on = fixFlowConverter.convertDefinitions2Json(definitions);
   		ObjectNode rootNode = objectMapper.createObjectNode();
   		rootNode.put("name", process.getName());
   		rootNode.put("description", process.getName());
   		rootNode.put("modelId", process.getId());
   		rootNode.put("model", on);
   		out = response.getWriter();
   		out.print(rootNode);
	} catch (Exception e) {
		throw new RuntimeException(e);
	}
	
}
 
Example #9
Source File: PhysicalParser.java    From Cubert with Apache License 2.0 6 votes vote down vote up
@Override
public void exitCreateDictionary(CreateDictionaryContext ctx)
{
    ObjectNode dict = objMapper.createObjectNode();
    String dictName = ctx.ID().getText();
    for (ColumnDictionaryContext colDict : ctx.columnDictionary())
    {
        String columnName = colDict.ID().getText();
        ArrayNode values = objMapper.createArrayNode();
        for (TerminalNode val : colDict.STRING())
        {
            values.add(CommonUtils.stripQuotes(val.getText()));
        }
        dict.put(columnName, values);
    }
    inlineDictionaries.put(dictName, dict);
}
 
Example #10
Source File: RollupEventSerializerTest.java    From blueflood with Apache License 2.0 6 votes vote down vote up
@Test
public void testBasicRollupSerialization() {
    BasicRollup rollup = new BasicRollup();
    rollup.setCount(20);
    rollup.setAverage(10);
    rollup.setMax(20);
    rollup.setMin(5);
    rollup.setVariance(12);
    rollup.setSum( 100 );
    //Get the JSON object node from Rollup
    ObjectNode resultNode = RollupSerializationHelper.rollupToJson(rollup);
    Assert.assertEquals(resultNode.get("max").asLong(), rollup.getMaxValue().toLong());
    Assert.assertEquals(resultNode.get("min").asLong(), rollup.getMinValue().toLong());
    Assert.assertEquals(resultNode.get("mean").asLong(), rollup.getAverage().toLong());
    Assert.assertEquals(resultNode.get("var").asDouble(), rollup.getVariance().toDouble());
    Assert.assertEquals(resultNode.get("count").asLong(), rollup.getCount());
    Assert.assertEquals(resultNode.get("sum").asDouble(), rollup.getSum(), EPSILON);
}
 
Example #11
Source File: AggregateRewriter.java    From Cubert with Apache License 2.0 6 votes vote down vote up
private void createMVBlockgen(String[] dimensions, String[] measures) throws AggregateRewriteException
{
    String[] mvDimensions = (dimensions);
    String[] mvMeasures = (measures);
    String[] mvColumns = (String[]) ArrayUtils.addAll(mvDimensions, mvMeasures);

    // Step1: At the very beginnning of the program, create a blockgen by index for
    // the
    // historical MV
    if (this.mvExists)
    {
        ObjectNode mvBlockgenJobNode =
                (ObjectNode) createBlockgenForMV(programNode,
                                                 cubeOperatorNode,
                                                 bgInfo,
                                                 mvName,
                                                 mvPath,
                                                 mvColumns);

        ArrayNode jobsListNode =
                JsonUtils.insertNodeListBefore((ArrayNode) (programNode.get("jobs")),
                                               cubeJobNode,
                                               Arrays.asList(new ObjectNode[] { mvBlockgenJobNode }));
        programNode.put("jobs", jobsListNode);
    }
}
 
Example #12
Source File: CountDistinctRewriter.java    From Cubert with Apache License 2.0 6 votes vote down vote up
public ObjectNode postCombineGroupBy()
{
    ArrayNode aggsNode = JsonUtils.createArrayNode();
    aggsNode.add(RewriteUtils.createObjectNode("type",
                                               "BITWISE_OR",
                                               "input",
                                               BITMAP_COLUMN_NAME,
                                               "output",
                                               BITMAP_COLUMN_NAME));
    ObjectNode groupByNode =
            RewriteUtils.createObjectNode("operator",
                                          "GROUP_BY",
                                          "input",
                                          combinedRelation,
                                          "output",
                                          combinedRelation,
                                          "groupBy",
                                          JsonUtils.createArrayNode(preCubeLoadColumns),
                                          "aggregates",
                                          aggsNode);
    return groupByNode;
}
 
Example #13
Source File: AwsCredentialValidatorTest.java    From cloudbreak with Apache License 2.0 6 votes vote down vote up
@Test
public void testKeyBasedToRoleBased() {
    Credential original = new Credential();
    ObjectNode rootOriginal = getAwsAttributes();
    putKeyBased(rootOriginal);
    original.setAttributes(rootOriginal.toString());

    Credential newCred = new Credential();
    ObjectNode rootNew = getAwsAttributes();
    putRoleBased(rootNew);
    newCred.setAttributes(rootNew.toString());
    ValidationResultBuilder resultBuilder = new ValidationResultBuilder();

    ValidationResult result = awsCredentialValidator.validateUpdate(original, newCred, resultBuilder);

    assertEquals(1, result.getErrors().size());
    assertThat(result.getErrors().get(0),
            CoreMatchers.containsString("Cannot change AWS credential from key based to role based."));
}
 
Example #14
Source File: Jwt.java    From components with Apache License 2.0 6 votes vote down vote up
public JsonNode toJSONObject() {
    ObjectNode o = mapper.createObjectNode();
    for (Map.Entry<String, Object> claim : claims.entrySet()) {
        if (CLAIM_AUDIENCE.equals(claim.getKey())) {

            // Serialize single audience list and string
            List<String> audList = getAudience();
            if (audList != null && !audList.isEmpty()) {
                if (audList.size() == 1) {
                    o.put(CLAIM_AUDIENCE, audList.get(0));
                } else {
                    ArrayNode audArray = mapper.createArrayNode();
                    for (String aud : audList) {
                        audArray.add(aud);
                    }
                    o.put(CLAIM_AUDIENCE, audArray);
                }
            }

        } else if (claim.getValue() != null) {
            o.putPOJO(claim.getKey(), claim.getValue());
        }
    }
    return o;
}
 
Example #15
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 #16
Source File: AggregateRewriter.java    From Cubert with Apache License 2.0 6 votes vote down vote up
private Pair<ObjectNode, ObjectNode> extractFactBlockgenInfo(LineagePath matchingPath)
{
    List<LineageGraphVertex> nodes = matchingPath.nodes;
    int size = nodes.size();
    if (size == 3)
    {
        ObjectNode bijNode = ((OperatorLineage) (nodes.get(0))).node;
        return new Pair<ObjectNode, ObjectNode>(bijNode,
                                                ((OperatorLineage) (nodes.get(1))).node);
    }
    else
    {
        return new Pair<ObjectNode, ObjectNode>(null,
                                                ((OperatorLineage) (nodes.get(0))).node);
    }

}
 
Example #17
Source File: Lineage.java    From Cubert with Apache License 2.0 6 votes vote down vote up
public List<OutputColumn> traceLoadColumn(ObjectNode programNode,
                                          OutputColumn destColumn) throws LineageException
{
    List<OutputColumn> loadColumns = new ArrayList<OutputColumn>();
    ColumnLineage columnNode = this.lineageInfo.getColumnLineageNode(destColumn);
    List<LineageGraphVertex> list1 =
            LineageGraph.traceTerminalNodes(columnNode, new String[] { "LOAD" }, false);
    List<LineageGraphVertex> list2 =
            LineageGraph.traceTerminalNodes(columnNode, new String[] { "LOAD-BLOCK" }, false);
    list1.addAll(list2);

    for (LineageGraphVertex graphNode : list1)
    {
        ColumnLineage colInfo = (ColumnLineage) graphNode;
        Pair<ObjectNode, JsonNode> phaseInfo =
                this.getLineage().getPreLineage().getJobPhase(colInfo.node.opNode);
        if (LineageHelper.isLoadOperator(phaseInfo.getFirst(),
                                         phaseInfo.getSecond(),
                                         colInfo.node.opNode))
            loadColumns.add(colInfo.node);

    }
    return loadColumns;
}
 
Example #18
Source File: GenericEntitySerializer.java    From secure-data-service with Apache License 2.0 6 votes vote down vote up
private JsonNode seralizeList(final String key, final List<Object> val) {
    
    ObjectNode rval = mapper.createObjectNode();
    ArrayNode array = mapper.createArrayNode();
    
    for (Object obj : val) {
        array.add(serializeObject(obj));
    }
    
    if (key == null) {
        return array;
    }
    
    rval.put(key, array);
    return rval;
}
 
Example #19
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 #20
Source File: CountDistinctRewriter.java    From Cubert with Apache License 2.0 5 votes vote down vote up
private String[] getCountDistinctMeasuresForCube(ObjectNode cubeOperatorNode)
{
    ArrayNode aggregates = (ArrayNode) cubeOperatorNode.get("aggregates");
    ArrayList<String> result = new ArrayList<String>();
    for (JsonNode node : aggregates)
    {
        if (!cubeCountDistinctAggregate(node))
            continue;
        result.addAll(Arrays.asList(JsonUtils.asArray(node.get("input"))));
    }
    return result.toArray(new String[aggregates.size()]);
}
 
Example #21
Source File: ColumnType.java    From Cubert with Apache License 2.0 5 votes vote down vote up
public JsonNode toJson()
{
    ObjectNode node = new ObjectMapper().createObjectNode();
    node.put("name", name);
    node.put("type", type.toString());
    if (columnSchema != null)
        node.put("schema", columnSchema.toJson());
    return node;
}
 
Example #22
Source File: LineageHelper.java    From Cubert with Apache License 2.0 5 votes vote down vote up
public ObjectNode findOperatorSourcePrior(int startSequence, String inputRelation)
{
    for (int i = startSequence; i >= 0; i--)
    {
        ObjectNode candidateOp = operatorList.get(i);

        if (isOutputOf(candidateOp, inputRelation))
            return candidateOp;
    }
    return null;
}
 
Example #23
Source File: JsonResponseUtil.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
public static ObjectNode buildResponseJSON(Object obj) {
  ObjectNode rootNode = MAPPER.getNodeFactory().objectNode();
  rootNode.put("Result", "OK");
  JsonNode node = MAPPER.convertValue(obj, JsonNode.class);
  rootNode.put("Record", node);
  return rootNode;
}
 
Example #24
Source File: JsonRelConverterFactory.java    From samza with Apache License 2.0 5 votes vote down vote up
private String convertToSamzaMessage(SamzaSqlRelRecord relRecord) {
  String jsonValue;
  ObjectNode node = mapper.createObjectNode();

  List<String> fieldNames = relRecord.getFieldNames();
  List<Object> values = relRecord.getFieldValues();

  for (int index = 0; index < fieldNames.size(); index++) {
    Object value = values.get(index);
    if (value == null) {
      continue;
    }

    // TODO limited support right now.
    if (Long.class.isAssignableFrom(value.getClass())) {
      node.put(fieldNames.get(index), (Long) value);
    } else if (Integer.class.isAssignableFrom(value.getClass())) {
      node.put(fieldNames.get(index), (Integer) value);
    } else if (Double.class.isAssignableFrom(value.getClass())) {
      node.put(fieldNames.get(index), (Double) value);
    } else if (String.class.isAssignableFrom(value.getClass())) {
      node.put(fieldNames.get(index), (String) value);
    } else if (SamzaSqlRelRecord.class.isAssignableFrom(value.getClass())) {
      // If the value is a SamzaSqlRelRecord, call convertToSamzaMessage to convert the record to json string.
      node.put(fieldNames.get(index), convertToSamzaMessage((SamzaSqlRelRecord) value));
    } else {
      node.put(fieldNames.get(index), value.toString());
    }
  }
  try {
    jsonValue = mapper.writeValueAsString(node);
  } catch (IOException e) {
    throw new SamzaException("Error json serializing object", e);
  }

  return jsonValue;
}
 
Example #25
Source File: CastCrewTO.java    From big-data-lite with MIT License 5 votes vote down vote up
public ObjectNode getJsonObject() {
    castCrewNode = new ObjectNode(factory);
    ObjectNode node = null;
    ArrayNode castArray = new ArrayNode(factory);
    ArrayNode crewArray = new ArrayNode(factory);

    castCrewNode.put(JsonConstant.ID, 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 #26
Source File: CastTO.java    From big-data-lite with MIT License 5 votes vote down vote up
public ObjectNode geCastJson() {
    this.castNode = super.getObjectNode();
    ObjectNode castMovieNode = null;
    ArrayNode movieArray = super.getArrayNode();

    castNode.put(JsonConstant.ID, this.getId());
    castNode.put(JsonConstant.NAME, this.getName());

    if (StringUtil.isNotEmpty(this.character) && this.order > 0) {            
        castNode.put(JsonConstant.ORDER, this.getOrder());
        castNode.put(JsonConstant.CHARACTER, this.getCharacter());
    } else {
        for (CastMovieTO castMovieTO : this.getCastMovieList()) {
            castMovieNode = super.getObjectNode();
            
            castMovieNode.put(JsonConstant.ID, castMovieTO.getId());
            castMovieNode.put(JsonConstant.CHARACTER,
                              castMovieTO.getCharacter());
            castMovieNode.put(JsonConstant.ORDER, castMovieTO.getOrder());

            movieArray.add(castMovieNode);
        } //EOF for

        //set cast to this object
        castNode.put(JsonConstant.MOVIES, movieArray);
        
    }
    return castNode;
}
 
Example #27
Source File: BlockgenLineageAnalyzer.java    From Cubert with Apache License 2.0 5 votes vote down vote up
@Override
public void exitJob(JsonNode json)
{
    JsonNode outputJson = json.get("output");
    boolean isRubixStorage =
            outputJson.has("type")
                    && getText(outputJson, "type").equalsIgnoreCase("rubix");
    if (isRubixStorage)
    {
        ((ObjectNode) outputJson).put("blockgenId", currentBlockgenId);
    }

    currentBlockgenId = null;
}
 
Example #28
Source File: CustomerTO.java    From big-data-lite with MIT License 5 votes vote down vote up
/**
 * This method construct JSON object and put param=values for all the
 * attributes defined in the CustomerTO
 * @return JSON object representing CutomerTO
 */
public ObjectNode geCustomertJson() {
    objectNode =super.getObjectNode();
    objectNode.put(JsonConstant.ID, this.getId());
    objectNode.put(JsonConstant.NAME, this.getName());
    objectNode.put(JsonConstant.EMAIL, this.getEmail());
    objectNode.put(JsonConstant.USERNAME, this.getUserName());
    objectNode.put(JsonConstant.PASSWORD, this.getPassword());
    return objectNode;
}
 
Example #29
Source File: CustomerGenreMovieTO.java    From big-data-lite with MIT License 5 votes vote down vote up
public void setJsonObject(ObjectNode custGenreNode) {
    this.custGenreNode = custGenreNode;
    
    int custId = custGenreNode.get(JsonConstant.ID).getIntValue();
    int genreId = custGenreNode.get(JsonConstant.GENRE_ID).getIntValue();
    int movieId = custGenreNode.get(JsonConstant.MOVIE_ID).getIntValue();
    this.setId(custId);
    this.setGenreId(genreId);
    this.setMovieId(movieId);

}
 
Example #30
Source File: TestOperators.java    From Cubert with Apache License 2.0 5 votes vote down vote up
@Test
// when there are multiple rows in one table
public void testHashJoin4() throws JsonGenerationException,
        JsonMappingException,
        IOException,
        InterruptedException
{
    Object[][] rows1 = { { 0 }, { 2 }, { 2 }, { 5 }, { 10 }, { 100 } };
    Object[][] rows2 = { { 1 }, { 2 }, { 7 }, { 9 }, { 100 }, { 100 } };
    Object[][] expected = { { 2, 2 }, { 2, 2 }, { 100, 100 }, { 100, 100 } };

    Block block1 = new ArrayBlock(Arrays.asList(rows1), new String[] { "a" });
    Block block2 = new ArrayBlock(Arrays.asList(rows2), new String[] { "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();
    node.put("leftJoinKeys", "a");
    node.put("rightJoinKeys", "a");
    node.put("leftBlock", "block1");

    BlockProperties props =
            new BlockProperties(null,
                                new BlockSchema("INT block1___a, 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" });
}