当前位置: 首页>>代码示例>>Java>>正文


Java ArrayNode.get方法代码示例

本文整理汇总了Java中org.codehaus.jackson.node.ArrayNode.get方法的典型用法代码示例。如果您正苦于以下问题:Java ArrayNode.get方法的具体用法?Java ArrayNode.get怎么用?Java ArrayNode.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.codehaus.jackson.node.ArrayNode的用法示例。


在下文中一共展示了ArrayNode.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getReadableBlogs

import org.codehaus.jackson.node.ArrayNode; //导入方法依赖的package包/类
/**
 * @throws Exception
 *             in case of an error
 */
@Test(dependsOnMethods = { "testCreateEditBlog" })
public void getReadableBlogs() throws Exception {

    ArrayNode array = doGetRequestAsJSONArray("/blogs.json?blogListType=READ&searchString="
            + searchString, username, password);

    Assert.assertTrue(array.size() >= 1,
            "The array must have at least one blog with the search string! array=" + array);
    for (int i = 0; i < array.size(); i++) {
        JsonNode blog = array.get(i);
        if (LOG.isDebugEnabled()) {
            LOG.debug("Checking blog=" + blog);
        }
        checkJSONBlogResult(blog, "blog[" + i + "]");
        String title = blog.get("title").asText();
        Assert.assertTrue(title.contains(searchString),
                "Blog title must contain searchString! title=" + title + " searchString="
                        + searchString);
    }

}
 
开发者ID:Communote,项目名称:communote-server,代码行数:26,代码来源:BlogApiTest.java

示例2: visitOperators

import org.codehaus.jackson.node.ArrayNode; //导入方法依赖的package包/类
public static void visitOperators(ObjectNode programNode,
                                  ObjectNode jobNode,
                                  OperatorVisitor tracerObj,
                                  boolean reverse)
{
    ArrayNode jobs = (ArrayNode) programNode.get("jobs");
    int si = (reverse ? jobs.size() - 1 : 0);
    int ei = (reverse ? -1 : jobs.size());

    for (int i = si; i != ei; i = i + increment(reverse))
    {
        if (jobNode != null && jobNode != jobs.get(i))
            continue;

        if (!visitOperatorsInJob(programNode,
                                 (ObjectNode) jobs.get(i),
                                 tracerObj,
                                 reverse))
            return;
    }
}
 
开发者ID:linkedin,项目名称:Cubert,代码行数:22,代码来源:Lineage.java

示例3: getOperatorDependency

import org.codehaus.jackson.node.ArrayNode; //导入方法依赖的package包/类
private static List<Integer>[] getOperatorDependency(ArrayNode operatorsJson)
{
    Map<String, Integer> relationName2OperatorID = new HashMap<String, Integer>();
    int numOperators = operatorsJson.size();
    List<Integer>[] inputOperatorIDs = new ArrayList[numOperators];

    for (int i = 0; i < numOperators; i++)
    {
        JsonNode operatorJson = operatorsJson.get(i);
        if (!operatorJson.has("operator"))
            continue;

        OperatorType type =
                OperatorType.valueOf(operatorJson.get("operator").getTextValue());
        String outputName = operatorJson.get("output").getTextValue();

        if (type.isTupleOperator())
        {
            inputOperatorIDs[i] =
                    getInputOperatorIDs(relationName2OperatorID, operatorJson);
            relationName2OperatorID.put(outputName, i);
        }
    }

    return inputOperatorIDs;
}
 
开发者ID:linkedin,项目名称:Cubert,代码行数:27,代码来源:PerfProfiler.java

示例4: getUsers

import org.codehaus.jackson.node.ArrayNode; //导入方法依赖的package包/类
/**
 * @throws Exception
 *             in case of an error
 */
@Test
public void getUsers() throws Exception {
    ArrayNode array = doGetRequestAsJSONArray("/users.json", username, password);

    Assert.assertTrue(array.size() > 0, "Must have at least on user!");
    for (int i = 0; i < array.size(); i++) {
        JsonNode user = array.get(i);
        if (LOG.isDebugEnabled()) {
            LOG.debug("Checking user=" + user);
        }
        checkJSONUserResult(user, "user[" + i + "]");
    }
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:18,代码来源:UserApiTest.java

示例5: getManagerBlogs

import org.codehaus.jackson.node.ArrayNode; //导入方法依赖的package包/类
/**
 * @throws Exception
 *             in case of an error
 */
@Test()
public void getManagerBlogs() throws Exception {

    ArrayNode array = doGetRequestAsJSONArray("/blogs.json?blogListType=MANAGER", username,
            password);

    for (int i = 0; i < array.size(); i++) {
        JsonNode blog = array.get(i);
        if (LOG.isDebugEnabled()) {
            LOG.debug("Checking blog=" + blog);
        }
        checkJSONBlogResult(blog, "blog[" + i + "]");
    }
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:19,代码来源:BlogApiTest.java

示例6: getIndexFromArray

import org.codehaus.jackson.node.ArrayNode; //导入方法依赖的package包/类
public static int getIndexFromArray(ArrayNode anode, JsonNode element)
{
    for (int i = 0; i < anode.size(); i++)
    {
        if (anode.get(i) == element)
            return i;
    }
    return -1;
}
 
开发者ID:linkedin,项目名称:Cubert,代码行数:10,代码来源:JsonUtils.java

示例7: getOperatorSourceInPhase

import org.codehaus.jackson.node.ArrayNode; //导入方法依赖的package包/类
private ObjectNode getOperatorSourceInPhase(ObjectNode jobNode,
                                            JsonNode phaseNode,
                                            ObjectNode opNode,
                                            String inputRelation)
{
    ArrayNode opsNode =
            isReducePhase(phaseNode) ? (ArrayNode) phaseNode
                    : (ArrayNode) (((ObjectNode) phaseNode).get("operators"));

    boolean reachedDest = false;

    // don't expect to find store in the list of oeprators.
    if (isReducePhase(phaseNode) && isStoreCommand(jobNode, phaseNode, opNode))
        reachedDest = true;

    for (int i = opsNode.size() - 1; i >= 0; i--)
    {
        ObjectNode candidateOp = (ObjectNode) (opsNode.get(i));
        if (candidateOp == opNode)
        {
            reachedDest = true;
            continue;
        }

        if (!reachedDest)
            continue;
        if (isOutputOf(candidateOp, inputRelation))
            return candidateOp;
    }
    return null;
}
 
开发者ID:linkedin,项目名称:Cubert,代码行数:32,代码来源:LineageHelper.java

示例8: findOperatorInputSources

import org.codehaus.jackson.node.ArrayNode; //导入方法依赖的package包/类
public List<ObjectNode> findOperatorInputSources(ObjectNode opNode,
                                                 String inputRelation)
{
    int opSequence = this.getOpSequence(opNode);
    ObjectNode jobNode = (ObjectNode) (this.getJobPhase(opNode).getFirst());
    JsonNode phaseNode = this.getJobPhase(opNode).getSecond();
    List<ObjectNode> result = new ArrayList<ObjectNode>();

    if (isReducePhase(phaseNode)
            && (opSequence == 0 || getOperatorSourceInPhase(jobNode,
                                                            (ArrayNode) phaseNode,
                                                            opNode,
                                                            inputRelation) == null))
    {
        // if either first operator in reduce phase or a matching source within
        // the same phase cannot be found,
        // look inside all the map jobs.
        ArrayNode mapsArray = (ArrayNode) getJobPhase(opNode).getFirst().get("map");
        for (JsonNode mapNode : mapsArray)
        {
            ArrayNode mapOps = (ArrayNode) ((ObjectNode) mapNode).get("operators");
            if (mapOps == null || mapOps.size() == 0)
                continue;
            ObjectNode lastOp = (ObjectNode) mapOps.get(mapOps.size() - 1);
            result.add(findOperatorSourcePrior(getOpSequence(lastOp), inputRelation));
        }
    }
    else
        result.add(findOperatorSource(opNode, inputRelation));

    return result;

}
 
开发者ID:linkedin,项目名称:Cubert,代码行数:34,代码来源:LineageHelper.java

示例9: updateCounter

import org.codehaus.jackson.node.ArrayNode; //导入方法依赖的package包/类
private void updateCounter()
{
    long[] operatorTime = getOperatorTime();

    String profileCounterGroupName =
            PhaseContext.isMapper() ? mapperProfileCounterGroupName
                    : reducerProfileCounterGroupName;

    ArrayNode operatorsJson = multipassOperatorsJson.get(currentPassIndex);
    for (int i = 0; i < operatorTime.length; i++)
    {
        if (operatorTime[i] > 0)
        {
            JsonNode operatorJson = operatorsJson.get(i);

            OperatorType type =
                    OperatorType.valueOf(operatorJson.get("operator").getTextValue());
            String outputName = operatorJson.get("output").getTextValue();

            String counterName =
                    String.format("P%d-O%d-%s-%s",
                                  currentPassIndex,
                                  i,
                                  type,
                                  outputName);
            Counter profileCounter =
                    PhaseContext.getCounter(profileCounterGroupName, counterName);
            profileCounter.increment(operatorTime[i]);
        }
    }
}
 
开发者ID:linkedin,项目名称:Cubert,代码行数:32,代码来源:PerfProfiler.java

示例10: mapJsonComments

import org.codehaus.jackson.node.ArrayNode; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private RedditComments mapJsonComments(final int limit) throws RedditException{
	final JsonNode parentLinkNode	= rootNode.get(0);
	final JsonNode commentsNode		= rootNode.get(1);
	final ArrayNode childrenNode  	= (ArrayNode)commentsNode.get(RedditJsonConstants.DATA)
											  .get(RedditJsonConstants.CHILDREN);

	final JsonNode moreNode			= childrenNode.get(childrenNode.size() - 1);
       boolean moreExists = false;
       if (moreNode != null) {
           moreExists = moreNode.get(RedditJsonConstants.KIND).asText().equals("more");
       }
	//See the 'replies' attribute of RedditComment. It is a JsonNode
	final List<RedditLink> theParentLink	   = (List<RedditLink>) parseSpecificType(parentLinkNode, RedditJsonConstants.TYPE_LINK);
	//final List<RedditComment> topLevelComments = (List<RedditComment>) parseSpecificType(rootNode, RedditJsonConstants.TYPE_COMMENT);
       final List<RedditComment> topLevelComments = (List<RedditComment>) parseSpecificType(commentsNode, RedditJsonConstants.TYPE_COMMENT);

	if(moreExists){
		final RedditMore theMore;
		
		try {
			theMore = mapper.readValue(moreNode.get(RedditJsonConstants.DATA), RedditMore.class);
		} catch (Exception e) {
			throw new RedditException(e);
		}
		
		return new RedditComments(theParentLink.get(0), topLevelComments, theMore);			
	}else{
		//Return non-null default reddit more with count of 0
		return new RedditComments(theParentLink.get(0), topLevelComments, new RedditMore());			
	}
}
 
开发者ID:mdaguillo,项目名称:Reddit-Underground,代码行数:33,代码来源:RedditJsonParser.java

示例11: createSchemaString

import org.codehaus.jackson.node.ArrayNode; //导入方法依赖的package包/类
/**
 * Creates the schema string.
 *
 * @param schema the schema
 * @param pretty the pretty
 * @return the string
 * @throws IOException Signals that an I/O exception has occurred.
 */
public static String createSchemaString(Schema schema, boolean pretty) throws IOException {
    Schema holderSchema = Schema.createRecord(SchemaFormAvroConverter.class.getSimpleName(), 
            null, SchemaFormAvroConverter.class.getPackage().getName(), false);
    List<Field> fields = new ArrayList<Field>();
    JsonNode dependenciesNode = schema.getJsonProp(DEPENDENCIES);
    if (dependenciesNode != null && dependenciesNode.isArray()) {
        for (int i=0;i<dependenciesNode.size();i++) {
            JsonNode dependencyNode = dependenciesNode.get(i);
            String fqn = dependencyNode.get(FQN).asText();
            Schema fieldType = findType(schema, fqn, null);
            if (fieldType != null) {
                Field tempField =  new Field(fqn.replaceAll("\\.", "_"), fieldType, null, null);
                fields.add(tempField);
            }
        }
    }        
    Field holdedField = new Field(HOLDED_SCHEMA_FIELD, schema, null, null);
    fields.add(holdedField);        
    holderSchema.setFields(fields);
    String schemaString = holderSchema.toString();
    ObjectMapper mapper = new ObjectMapper();
    JsonNode node = mapper.readTree(schemaString);
    ArrayNode fieldsNode = (ArrayNode)node.get(FIELDS);
    JsonNode fieldNode = fieldsNode.get(fields.size()-1);
    JsonNode typeNode = fieldNode.get(TYPE);
    if (pretty) {
        return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(typeNode);
    } else {
        return mapper.writeValueAsString(typeNode);
    }
}
 
开发者ID:kaaproject,项目名称:avro-ui,代码行数:40,代码来源:SchemaFormAvroConverter.java

示例12: printQueueInfo

import org.codehaus.jackson.node.ArrayNode; //导入方法依赖的package包/类
public void printQueueInfo(HttpClient client, ObjectMapper mapper, String schedulerResourceURL) {
	
	//http://sandbox.hortonworks.com:8088/ws/v1/cluster/scheduler in case of HDP
	GetMethod get = new GetMethod(schedulerResourceURL);
    get.setRequestHeader("Accept", "application/json");
    try {
        int statusCode = client.executeMethod(get);

        if (statusCode != HttpStatus.SC_OK) {
        	LOGGER.error("Method failed: " + get.getStatusLine());
        }
        
		InputStream in = get.getResponseBodyAsStream();
		
		JsonNode jsonNode = mapper.readValue(in, JsonNode.class);
		ArrayNode queues = (ArrayNode) jsonNode.path("scheduler").path("schedulerInfo").path("queues").get("queue");
		for (int i = 0; i < queues.size(); i++) {
			JsonNode queueNode = queues.get(i);						
			LOGGER.info("queueName / usedCapacity / absoluteUsedCap / absoluteCapacity / absMaxCapacity: " + 
					queueNode.findValue("queueName") + " / " +
					queueNode.findValue("usedCapacity") + " / " + 
					queueNode.findValue("absoluteUsedCapacity") + " / " + 
					queueNode.findValue("absoluteCapacity") + " / " +
					queueNode.findValue("absoluteMaxCapacity"));
		}
	} catch (IOException e) {
		LOGGER.error("Exception occured", e);
	} finally {	        
		get.releaseConnection();
	}	      
        
}
 
开发者ID:sequenceiq,项目名称:sequenceiq-samples,代码行数:33,代码来源:QueueInformation.java

示例13: testFailInviteUser

import org.codehaus.jackson.node.ArrayNode; //导入方法依赖的package包/类
/**
 * @throws Exception
 *             in case of an error
 */
@Test
public void testFailInviteUser() throws Exception {
    Map<String, String> parameters = new HashMap<String, String>();

    Long blogId = getManageableBlogId(username, password, 0);

    String alias = "" + new Date().getTime();

    parameters.put("blogId", blogId.toString());
    parameters.put("role", "MEMBER");
    parameters.put("alias", alias);
    parameters.put("languageCode", "de");

    JsonNode result = doApiPostRequest("/blogInviteUser.json", username, password, parameters,
            "ERROR");

    Assert.assertTrue(result.get("result").isArray());
    ArrayNode errorFields = (ArrayNode) result.get("result");

    List<String> missingFields = new ArrayList<String>();
    missingFields.add("firstName");
    missingFields.add("lastName");
    missingFields.add("email");

    for (int i = 0; i < errorFields.size(); i++) {
        JsonNode errorField = errorFields.get(i);
        String fieldName = errorField.get("name").asText();
        String message = errorField.get("message").asText();
        String newValue = errorField.get("message").asText();

        if (!missingFields.contains(fieldName)) {
            Assert.fail("FieldName has error but should not! fieldName=" + fieldName
                    + " message=" + message + " newValue=" + newValue);
        }
        missingFields.remove(fieldName);
    }

    if (missingFields.size() > 0) {
        Assert.fail("There are missing fields that have not be returned as an error! Example fieldName="
                + missingFields.iterator().next());
    }
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:47,代码来源:BlogApiTest.java

示例14: incrementalizeInputLoad

import org.codehaus.jackson.node.ArrayNode; //导入方法依赖的package包/类
private void incrementalizeInputLoad(ObjectNode programNode,
                                     ObjectNode inputNode,
                                     ObjectNode cubeOperatorNode,
                                     String mvName,
                                     String mvPath) throws IOException,
        AggregateRewriteException
{

    // extract input paths from inputNode and adjust start-date to MV refresh date+1.
    ArrayNode paths = (ArrayNode) inputNode.get("path");
    System.out.println("Incrementalize InputNode = " + inputNode.toString());
    int newMvRefreshTime = 0;
    for (int i = 0; i < paths.size(); i++)
    {
        JsonNode pathNode = paths.get(i);
        if (pathNode instanceof ObjectNode)
        {
            String startDate =
                    ((ObjectNode) pathNode).get("startDate").getTextValue();
            // System.out.println("startDate = " + startDate);
            DateTime loadStart = DateTimeUtilities.getDateTime((startDate));
            String endDate = ((ObjectNode) pathNode).get("endDate").getTextValue();
            DateTime loadEnd = DateTimeUtilities.getDateTime(endDate);

            if (mvRefreshDate != 0 && incLoadDate != null)
            {
                if (loadStart.isBefore(incLoadDate) && loadEnd.isAfter(incLoadDate))
                {
                    ((ObjectNode) pathNode).put("origStartDate", startDate);
                    ((ObjectNode) pathNode).put("startDate",
                                                Integer.toString(DateTimeUtilities.asInt(incLoadDate)));
                }
                else
                    throw new AggregateRewriteException(String.format("MV date range mis-matches load range[%s, %s] ",
                                                                      startDate,
                                                                      endDate));
            }

            newMvRefreshTime =
                    Math.max(Integer.parseInt(((ObjectNode) pathNode).get("endDate")
                                                                     .getTextValue()),
                             newMvRefreshTime);
        }
    }

    System.out.println("Setting MV refresh time for " + mvName + " to "
            + newMvRefreshTime);
    mvRefreshMap.put(mvName, newMvRefreshTime);

}
 
开发者ID:linkedin,项目名称:Cubert,代码行数:51,代码来源:AggregateRewriter.java

示例15: insertIncrementalMultipleDayGroupBy

import org.codehaus.jackson.node.ArrayNode; //导入方法依赖的package包/类
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);

}
 
开发者ID:linkedin,项目名称:Cubert,代码行数:70,代码来源:CountDistinctRewriter.java


注:本文中的org.codehaus.jackson.node.ArrayNode.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。