本文整理了Java中org.apache.pinot.common.utils.JsonUtils.newArrayNode()
方法的一些代码示例,展示了JsonUtils.newArrayNode()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonUtils.newArrayNode()
方法的具体详情如下:
包路径:org.apache.pinot.common.utils.JsonUtils
类名称:JsonUtils
方法名:newArrayNode
暂无
代码示例来源:origin: apache/incubator-pinot
private static ArrayNode convertStringsToJsonArray(String... strings) {
ArrayNode jsonArray = JsonUtils.newArrayNode();
for (String string : strings) {
jsonArray.add(string);
}
return jsonArray;
}
代码示例来源:origin: apache/incubator-pinot
/**
* Get the trace information added so far.
*/
public static String getTraceInfo() {
ArrayNode jsonTraces = JsonUtils.newArrayNode();
for (Trace trace : REQUEST_TO_TRACES_MAP.get(TRACE_ENTRY_THREAD_LOCAL.get()._requestId)) {
jsonTraces.add(trace.toJson());
}
return jsonTraces.toString();
}
代码示例来源:origin: apache/incubator-pinot
public static org.apache.avro.Schema getAvroSchema(Schema schema) {
ObjectNode avroSchema = JsonUtils.newObjectNode();
avroSchema.put("name", "data_gen_record");
avroSchema.put("type", "record");
ArrayNode fields = JsonUtils.newArrayNode();
for (FieldSpec fieldSpec : schema.getAllFieldSpecs()) {
JsonNode jsonObject = fieldSpec.toAvroSchemaJsonObject();
fields.add(jsonObject);
}
avroSchema.set("fields", fields);
return new org.apache.avro.Schema.Parser().parse(avroSchema.toString());
}
代码示例来源:origin: apache/incubator-pinot
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/schemas")
@ApiOperation(value = "List all schema names", notes = "Lists all schema names")
public String listSchemaNames() {
List<String> schemaNames = _pinotHelixResourceManager.getSchemaNames();
ArrayNode ret = JsonUtils.newArrayNode();
if (schemaNames != null) {
for (String schema : schemaNames) {
ret.add(schema);
}
}
return ret.toString();
}
代码示例来源:origin: apache/incubator-pinot
JsonNode toJson() {
ArrayNode jsonLogs = JsonUtils.newArrayNode();
for (LogEntry log : _logs) {
jsonLogs.add(log.toJson());
}
return JsonUtils.newObjectNode().set(_traceId, jsonLogs);
}
}
代码示例来源:origin: apache/incubator-pinot
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/segments")
@Deprecated
public String listAllSegmentNames()
throws Exception {
FileUploadPathProvider provider = new FileUploadPathProvider(_controllerConf);
ArrayNode ret = JsonUtils.newArrayNode();
for (final File file : provider.getBaseDataDir().listFiles()) {
final String fileName = file.getName();
if (fileName.equalsIgnoreCase("fileUploadTemp") || fileName.equalsIgnoreCase("schemasTemp")) {
continue;
}
final String url = _controllerConf.generateVipUrl() + "/segments/" + fileName;
ret.add(url);
}
return ret.toString();
}
代码示例来源:origin: apache/incubator-pinot
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/segments/{tableName}")
@ApiOperation(value = "Lists names of all segments of a table", notes = "Lists names of all segment names of a table")
public String listAllSegmentNames(
@ApiParam(value = "Name of the table", required = true) @PathParam("tableName") String tableName,
@ApiParam(value = "realtime|offline") @QueryParam("type") String tableTypeStr) {
ArrayNode ret = JsonUtils.newArrayNode();
CommonConstants.Helix.TableType tableType = Constants.validateTableType(tableTypeStr);
if (tableTypeStr == null) {
ret.add(formatSegments(tableName, CommonConstants.Helix.TableType.OFFLINE));
ret.add(formatSegments(tableName, CommonConstants.Helix.TableType.REALTIME));
} else {
ret.add(formatSegments(tableName, tableType));
}
return ret.toString();
}
代码示例来源:origin: apache/incubator-pinot
jsonSchema.put("schemaName", _schemaName);
if (!_dimensionFieldSpecs.isEmpty()) {
ArrayNode jsonArray = JsonUtils.newArrayNode();
for (DimensionFieldSpec dimensionFieldSpec : _dimensionFieldSpecs) {
jsonArray.add(dimensionFieldSpec.toJsonObject());
ArrayNode jsonArray = JsonUtils.newArrayNode();
for (MetricFieldSpec metricFieldSpec : _metricFieldSpecs) {
jsonArray.add(metricFieldSpec.toJsonObject());
ArrayNode jsonArray = JsonUtils.newArrayNode();
for (DateTimeFieldSpec dateTimeFieldSpec : _dateTimeFieldSpecs) {
jsonArray.add(dateTimeFieldSpec.toJsonObject());
代码示例来源:origin: apache/incubator-pinot
private String listSegmentMetadataInternal(@Nonnull String tableName, @Nonnull String segmentName,
@Nullable CommonConstants.Helix.TableType tableType) {
List<String> tableNamesWithType = getExistingTableNamesWithType(tableName, tableType);
ArrayNode result = JsonUtils.newArrayNode();
for (String tableNameWithType : tableNamesWithType) {
ArrayNode segmentMetaData = getSegmentMetaData(tableNameWithType, segmentName);
if (segmentMetaData != null) {
result.add(segmentMetaData);
}
}
if (result.size() == 0) {
String errorMessage = "Failed to find segment: " + segmentName + " in table: " + tableName;
if (tableType != null) {
errorMessage += " of type: " + tableType;
}
throw new ControllerApplicationException(LOGGER, errorMessage, Response.Status.NOT_FOUND);
}
return result.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
ObjectNode ret = JsonUtils.newObjectNode();
ret.put("tableName", tableName);
ArrayNode brokers = JsonUtils.newArrayNode();
ArrayNode servers = JsonUtils.newArrayNode();
ObjectNode e = JsonUtils.newObjectNode();
e.put("tableType", "offline");
ArrayNode a = JsonUtils.newArrayNode();
for (String ins : pinotHelixResourceManager.getBrokerInstancesForTable(tableName, TableType.OFFLINE)) {
a.add(ins);
ObjectNode e = JsonUtils.newObjectNode();
e.put("tableType", "realtime");
ArrayNode a = JsonUtils.newArrayNode();
for (String ins : pinotHelixResourceManager.getBrokerInstancesForTable(tableName, TableType.REALTIME)) {
a.add(ins);
ObjectNode e = JsonUtils.newObjectNode();
e.put("tableType", "offline");
ArrayNode a = JsonUtils.newArrayNode();
for (String ins : pinotHelixResourceManager.getServerInstancesForTable(tableName, TableType.OFFLINE)) {
a.add(ins);
ObjectNode e = JsonUtils.newObjectNode();
e.put("tableType", "realtime");
ArrayNode a = JsonUtils.newArrayNode();
for (String ins : pinotHelixResourceManager.getServerInstancesForTable(tableName, TableType.REALTIME)) {
a.add(ins);
代码示例来源:origin: apache/incubator-pinot
segmentMetadata.put("hllLog2m", _hllLog2m);
ArrayNode columnsMetadata = JsonUtils.newArrayNode();
for (String column : _allColumns) {
if (columnFilter != null && !columnFilter.contains(column)) {
代码示例来源:origin: apache/incubator-pinot
private String getInstanceToSegmentsMap(@Nonnull String tableName,
@Nullable CommonConstants.Helix.TableType tableType) {
List<String> tableNamesWithType = getExistingTableNamesWithType(tableName, tableType);
ArrayNode result = JsonUtils.newArrayNode();
for (String tableNameWithType : tableNamesWithType) {
ObjectNode resultForTable = JsonUtils.newObjectNode();
resultForTable.put(FileUploadPathProvider.TABLE_NAME, tableNameWithType);
try {
// NOTE: for backward-compatibility, we put serialized map string as the value
resultForTable.put("segments",
JsonUtils.objectToString(_pinotHelixResourceManager.getServerToSegmentsMap(tableNameWithType)));
} catch (JsonProcessingException e) {
throw new ControllerApplicationException(LOGGER,
"Caught JSON exception while getting instance to segments map for table: " + tableNameWithType,
Response.Status.INTERNAL_SERVER_ERROR, e);
}
result.add(resultForTable);
}
return result.toString();
}
代码示例来源:origin: apache/incubator-pinot
ArrayNode ret = JsonUtils.newArrayNode();
boolean tableExists = false;
代码示例来源:origin: apache/incubator-pinot
private ArrayNode getSegments(String tableName, String tableType) {
ArrayNode segments = JsonUtils.newArrayNode();
String realtimeTableName = TableNameBuilder.REALTIME.tableNameWithType(tableName);
String offlineTableName = TableNameBuilder.OFFLINE.tableNameWithType(tableName);
String tableNameWithType;
if (CommonConstants.Helix.TableType.valueOf(tableType).toString().equals("REALTIME")) {
tableNameWithType = realtimeTableName;
} else {
tableNameWithType = offlineTableName;
}
List<String> segmentList = _pinotHelixResourceManager.getSegmentsFor(tableNameWithType);
IdealState idealState =
HelixHelper.getTableIdealState(_pinotHelixResourceManager.getHelixZkManager(), tableNameWithType);
for (String segmentName : segmentList) {
Map<String, String> map = idealState.getInstanceStateMap(segmentName);
if (map == null) {
continue;
}
if (!map.containsValue(PinotHelixSegmentOnlineOfflineStateModelGenerator.OFFLINE_STATE)) {
segments.add(segmentName);
}
}
return segments;
}
代码示例来源:origin: apache/incubator-pinot
/**
* Returns the segment metadata.
*
* @param tableNameWithType Table name with type suffix
* @param segmentName Segment name
* @return Singleton JSON array of the segment metadata
*/
private ArrayNode getSegmentMetaData(String tableNameWithType, String segmentName) {
ZkHelixPropertyStore<ZNRecord> propertyStore = _pinotHelixResourceManager.getPropertyStore();
if (!ZKMetadataProvider.isSegmentExisted(propertyStore, tableNameWithType, segmentName)) {
return null;
}
ArrayNode ret = JsonUtils.newArrayNode();
ObjectNode jsonObj = JsonUtils.newObjectNode();
jsonObj.put(TABLE_NAME, tableNameWithType);
if (TableNameBuilder.OFFLINE.tableHasTypeSuffix(tableNameWithType)) {
// OFFLINE table
OfflineSegmentZKMetadata offlineSegmentZKMetadata =
ZKMetadataProvider.getOfflineSegmentZKMetadata(propertyStore, tableNameWithType, segmentName);
jsonObj.set(STATE, JsonUtils.objectToJsonNode(offlineSegmentZKMetadata.toMap()));
} else {
// REALTIME table
RealtimeSegmentZKMetadata realtimeSegmentZKMetadata =
ZKMetadataProvider.getRealtimeSegmentZKMetadata(propertyStore, tableNameWithType, segmentName);
jsonObj.set(STATE, JsonUtils.objectToJsonNode(realtimeSegmentZKMetadata.toMap()));
}
ret.add(jsonObj);
return ret;
}
代码示例来源:origin: apache/incubator-pinot
public static String toggleStateInternal(@Nonnull String tableName, StateType state,
CommonConstants.Helix.TableType tableType, String segmentName, PinotHelixResourceManager helixResourceManager) {
ArrayNode ret = JsonUtils.newArrayNode();
List<String> segmentsToToggle = new ArrayList<>();
String offlineTableName = TableNameBuilder.OFFLINE.tableNameWithType(tableName);
内容来源于网络,如有侵权,请联系作者删除!