org.apache.pinot.common.utils.JsonUtils.objectToPrettyString()方法的使用及代码示例

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

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

JsonUtils.objectToPrettyString介绍

暂无

代码示例

代码示例来源:origin: apache/incubator-pinot

public String toJsonString()
   throws JsonProcessingException {
  return JsonUtils.objectToPrettyString(this);
 }
}

代码示例来源:origin: apache/incubator-pinot

public String toJsonString()
  throws Exception {
 return JsonUtils.objectToPrettyString(this);
}

代码示例来源:origin: apache/incubator-pinot

private void printIdealState(Map<String, Map<String, String>> idealState)
  throws JsonProcessingException {
 System.out.println(JsonUtils.objectToPrettyString(idealState));
}

代码示例来源:origin: apache/incubator-pinot

public static String convertToJsonString(Object object) {
  try {
   return JsonUtils.objectToPrettyString(object);
  } catch (IOException e) {
   LOGGER.error("Failed to convert json into string: ", e);
   throw new WebApplicationException("Failed to convert json into string.", Response.Status.INTERNAL_SERVER_ERROR);
  }
 }
}

代码示例来源:origin: apache/incubator-pinot

@Override
public String toString() {
 try {
  return JsonUtils.objectToPrettyString(toJSONConfig(this));
 } catch (JsonProcessingException e) {
  throw new RuntimeException(e);
 }
}

代码示例来源:origin: apache/incubator-pinot

protected void printSegmentAssignment(Map<String, Map<String, String>> mapping)
  throws Exception {
 LOGGER.info(JsonUtils.objectToPrettyString(mapping));
 Map<String, List<String>> serverToSegmentMapping = new TreeMap<>();
 for (String segment : mapping.keySet()) {
  Map<String, String> serverToStateMap = mapping.get(segment);
  for (String server : serverToStateMap.keySet()) {
   if (!serverToSegmentMapping.containsKey(server)) {
    serverToSegmentMapping.put(server, new ArrayList<>());
   }
   serverToSegmentMapping.get(server).add(segment);
  }
 }
 DescriptiveStatistics stats = new DescriptiveStatistics();
 for (String server : serverToSegmentMapping.keySet()) {
  List<String> list = serverToSegmentMapping.get(server);
  LOGGER.info("server " + server + " has " + list.size() + " segments");
  stats.addValue(list.size());
 }
 LOGGER.info("Segment Distrbution stat");
 LOGGER.info(stats.toString());
}

代码示例来源:origin: apache/incubator-pinot

@Override
 public String dumpSnapshot(String tableName)
   throws Exception {
  ObjectNode ret = JsonUtils.newObjectNode();
  ArrayNode routingTableSnapshot = JsonUtils.newArrayNode();

  for (String currentTable : _routingTableBuilderMap.keySet()) {
   if (tableName == null || currentTable.startsWith(tableName)) {
    ObjectNode tableEntry = JsonUtils.newObjectNode();
    tableEntry.put("tableName", currentTable);

    ArrayNode entries = JsonUtils.newArrayNode();
    RoutingTableBuilder routingTableBuilder = _routingTableBuilderMap.get(currentTable);
    List<Map<String, List<String>>> routingTables = routingTableBuilder.getRoutingTables();
    for (Map<String, List<String>> routingTable : routingTables) {
     entries.add(JsonUtils.objectToJsonNode(routingTable));
    }
    tableEntry.set("routingTableEntries", entries);
    routingTableSnapshot.add(tableEntry);
   }
  }
  ret.set("routingTableSnapshot", routingTableSnapshot);
  ret.put("host", NetUtil.getHostnameOrAddress());

  return JsonUtils.objectToPrettyString(ret);
 }
}

代码示例来源:origin: apache/incubator-pinot

return JsonUtils.objectToPrettyString(jsonSchema);
} catch (JsonProcessingException e) {
 throw new RuntimeException(e);

代码示例来源:origin: apache/incubator-pinot

public static void main(String[] args)
   throws IOException {
  SchemaBuilder schemaBuilder = new SchemaBuilder();

  schemaBuilder.addSingleValueDimension("name", DataType.STRING);
  schemaBuilder.addSingleValueDimension("age", DataType.INT);
  schemaBuilder.addMetric("percent", DataType.FLOAT);
  schemaBuilder.addTime("days", TimeUnit.DAYS, DataType.LONG);

  Schema schema = schemaBuilder.build();
  System.out.println(JsonUtils.objectToPrettyString(schema));
 }
}

代码示例来源:origin: apache/incubator-pinot

private String getAllCrcMetadataForTable(String tableName) {
  // TODO
  // In the restlet.resource version, we see this code block below
  // seems to be wrong comparing the table name to have the table type, but we copy it here anyway.
  // Realtime table is not supported.
  if (TableNameBuilder.getTableTypeFromTableName(tableName) == CommonConstants.Helix.TableType.REALTIME) {
   throw new ControllerApplicationException(LOGGER, "Realtime table is not supported", Response.Status.FORBIDDEN);
  }

  // Check that the offline table exists.
  String offlineTableName = TableNameBuilder.OFFLINE.tableNameWithType(tableName);
  if (!_pinotHelixResourceManager.getAllTables().contains(offlineTableName)) {
   throw new ControllerApplicationException(LOGGER, "Offline table " + tableName + " does not exist.", BAD_REQUEST);
  }

  Map<String, String> segmentCrcForTable = _pinotHelixResourceManager.getSegmentsCrcForTable(offlineTableName);
  String result;
  try {
   result = JsonUtils.objectToPrettyString(segmentCrcForTable);
  } catch (JsonProcessingException e) {
   throw new ControllerApplicationException(LOGGER,
     String.format("Failed to write segment crc values for table: %s", tableName),
     Response.Status.INTERNAL_SERVER_ERROR);
  }
  return result;
 }
}

代码示例来源:origin: apache/incubator-pinot

public StarTreeIndexViewer(File segmentDir)
  throws Exception {
 IndexSegment indexSegment = ImmutableSegmentLoader.load(segmentDir, ReadMode.heap);
 dictionaries = new HashMap<>();
 valueIterators = new HashMap<>();
 SegmentMetadataImpl metadata = new SegmentMetadataImpl(segmentDir);
 for (String columnName : metadata.getAllColumns()) {
  DataSource dataSource = indexSegment.getDataSource(columnName);
  Block block = dataSource.nextBlock();
  BlockValSet blockValSet = block.getBlockValueSet();
  BlockSingleValIterator itr = (BlockSingleValIterator) blockValSet.iterator();
  valueIterators.put(columnName, itr);
  dictionaries.put(columnName, dataSource.getDictionary());
 }
 StarTree tree = indexSegment.getStarTrees().get(0).getStarTree();
 _dimensionNames = tree.getDimensionNames();
 StarTreeJsonNode jsonRoot = new StarTreeJsonNode("ROOT");
 build(tree.getRoot(), jsonRoot);
 indexSegment.destroy();
 String writeValueAsString = JsonUtils.objectToPrettyString(jsonRoot);
 LOGGER.info(writeValueAsString);
 startServer(segmentDir, writeValueAsString);
}

相关文章