org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonNode.size()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(216)

本文整理了Java中org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonNode.size()方法的一些代码示例,展示了JsonNode.size()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonNode.size()方法的具体详情如下:
包路径:org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonNode
类名称:JsonNode
方法名:size

JsonNode.size介绍

暂无

代码示例

代码示例来源:origin: apache/flink

private Object convertObjectArray(JsonNode node, TypeInformation<?> elementType) {
  final Object[] array = (Object[]) Array.newInstance(elementType.getTypeClass(), node.size());
  for (int i = 0; i < node.size(); i++) {
    array[i] = convert(node.get(i), elementType);
  }
  return array;
}

代码示例来源:origin: apache/flink

private static TypeInformation<?>[] convertTypes(String location, JsonNode arrayNode, JsonNode root) {
    final TypeInformation<?>[] types = new TypeInformation[arrayNode.size()];
    final Iterator<JsonNode> elements = arrayNode.elements();
    int i = 0;
    while (elements.hasNext()) {
      final TypeInformation<?> elementType = convertType(
        location + '[' + i + ']',
        elements.next(),
        root);
      types[i] = elementType;
      i += 1;
    }
    return types;
  }
}

代码示例来源:origin: apache/flink

.get("taskmanagers");
if (taskManagerList != null && taskManagerList.size() > 0) {
  LOG.info("Dispatcher REST endpoint is up.");
  return;

代码示例来源:origin: apache/flink

private static TypeInformation<Row> convertObject(String location, JsonNode node, JsonNode root) {
  // validate properties
  if (!node.has(PROPERTIES)) {
    return Types.ROW();
  }
  if (!node.isObject()) {
    throw new IllegalArgumentException(
      "Invalid '" + PROPERTIES + "' property for object type in node: " + location);
  }
  final JsonNode props = node.get(PROPERTIES);
  final String[] names = new String[props.size()];
  final TypeInformation<?>[] types = new TypeInformation[props.size()];
  final Iterator<Map.Entry<String, JsonNode>> fieldIter = props.fields();
  int i = 0;
  while (fieldIter.hasNext()) {
    final Map.Entry<String, JsonNode> subNode = fieldIter.next();
    // set field name
    names[i] = subNode.getKey();
    // set type
    types[i] = convertType(location + '/' + subNode.getKey(), subNode.getValue(), root);
    i++;
  }
  // validate that object does not contain additional properties
  if (node.has(ADDITIONAL_PROPERTIES) && node.get(ADDITIONAL_PROPERTIES).isBoolean() &&
      node.get(ADDITIONAL_PROPERTIES).asBoolean()) {
    throw new IllegalArgumentException(
      "An object must not allow additional properties in node: " + location);
  }
  return Types.ROW_NAMED(names, types);
}

代码示例来源:origin: org.apache.flink/flink-json

private Object convertObjectArray(JsonNode node, TypeInformation<?> elementType) {
  final Object[] array = (Object[]) Array.newInstance(elementType.getTypeClass(), node.size());
  for (int i = 0; i < node.size(); i++) {
    array[i] = convert(node.get(i), elementType);
  }
  return array;
}

代码示例来源:origin: com.alibaba.blink/flink-json

private Object convertObjectArray(JsonNode node, TypeInformation<?> elementType) {
  final Object[] array = (Object[]) Array.newInstance(elementType.getTypeClass(), node.size());
  for (int i = 0; i < node.size(); i++) {
    array[i] = convert(node.get(i), elementType);
  }
  return array;
}

代码示例来源:origin: org.apache.flink/flink-json

private static TypeInformation<?>[] convertTypes(String location, JsonNode arrayNode, JsonNode root) {
    final TypeInformation<?>[] types = new TypeInformation[arrayNode.size()];
    final Iterator<JsonNode> elements = arrayNode.elements();
    int i = 0;
    while (elements.hasNext()) {
      final TypeInformation<?> elementType = convertType(
        location + '[' + i + ']',
        elements.next(),
        root);
      types[i] = elementType;
      i += 1;
    }
    return types;
  }
}

代码示例来源:origin: com.alibaba.blink/flink-json

private static TypeInformation<?>[] convertTypes(String location, JsonNode arrayNode, JsonNode root) {
    final TypeInformation<?>[] types = new TypeInformation[arrayNode.size()];
    final Iterator<JsonNode> elements = arrayNode.elements();
    int i = 0;
    while (elements.hasNext()) {
      final TypeInformation<?> elementType = convertType(
        location + '[' + i + ']',
        elements.next(),
        root);
      types[i] = elementType;
      i += 1;
    }
    return types;
  }
}

代码示例来源:origin: com.alibaba.blink/flink-json

private static TypeInformation<Row> convertObject(String location, JsonNode node, JsonNode root) {
  // validate properties
  if (!node.has(PROPERTIES)) {
    return Types.ROW();
  }
  if (!node.isObject()) {
    throw new IllegalArgumentException(
      "Invalid '" + PROPERTIES + "' property for object type in node: " + location);
  }
  final JsonNode props = node.get(PROPERTIES);
  final String[] names = new String[props.size()];
  final TypeInformation<?>[] types = new TypeInformation[props.size()];
  final Iterator<Map.Entry<String, JsonNode>> fieldIter = props.fields();
  int i = 0;
  while (fieldIter.hasNext()) {
    final Map.Entry<String, JsonNode> subNode = fieldIter.next();
    // set field name
    names[i] = subNode.getKey();
    // set type
    types[i] = convertType(location + '/' + subNode.getKey(), subNode.getValue(), root);
    i++;
  }
  // validate that object does not contain additional properties
  if (node.has(ADDITIONAL_PROPERTIES) && node.get(ADDITIONAL_PROPERTIES).isBoolean() &&
      node.get(ADDITIONAL_PROPERTIES).asBoolean()) {
    throw new IllegalArgumentException(
      "An object must not allow additional properties in node: " + location);
  }
  return Types.ROW_NAMED(names, types);
}

代码示例来源:origin: org.apache.flink/flink-json

private static TypeInformation<Row> convertObject(String location, JsonNode node, JsonNode root) {
  // validate properties
  if (!node.has(PROPERTIES)) {
    return Types.ROW();
  }
  if (!node.isObject()) {
    throw new IllegalArgumentException(
      "Invalid '" + PROPERTIES + "' property for object type in node: " + location);
  }
  final JsonNode props = node.get(PROPERTIES);
  final String[] names = new String[props.size()];
  final TypeInformation<?>[] types = new TypeInformation[props.size()];
  final Iterator<Map.Entry<String, JsonNode>> fieldIter = props.fields();
  int i = 0;
  while (fieldIter.hasNext()) {
    final Map.Entry<String, JsonNode> subNode = fieldIter.next();
    // set field name
    names[i] = subNode.getKey();
    // set type
    types[i] = convertType(location + '/' + subNode.getKey(), subNode.getValue(), root);
    i++;
  }
  // validate that object does not contain additional properties
  if (node.has(ADDITIONAL_PROPERTIES) && node.get(ADDITIONAL_PROPERTIES).isBoolean() &&
      node.get(ADDITIONAL_PROPERTIES).asBoolean()) {
    throw new IllegalArgumentException(
      "An object must not allow additional properties in node: " + location);
  }
  return Types.ROW_NAMED(names, types);
}

相关文章