Jackie-Jiang commented on code in PR #13296:
URL: https://github.com/apache/pinot/pull/13296#discussion_r1724005276


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSchemaRestletResource.java:
##########
@@ -118,6 +121,23 @@ public List<String> listSchemaNames(@Context HttpHeaders 
headers) {
     return 
_pinotHelixResourceManager.getSchemaNames(headers.getHeaderString(DATABASE));
   }
 
+  @GET
+  @Produces(MediaType.APPLICATION_JSON)
+  @Path("/schemas/info")
+  @Authorize(targetType = TargetType.CLUSTER, action = 
Actions.Cluster.GET_SCHEMA_INFO)
+  @ApiOperation(value = "List all schemas info with count of field specs", 
notes = "Lists all schemas with field "
+      + "count details")
+  public List<SchemaInfo> getSchemaInfo(@Context HttpHeaders headers) {
+    List<SchemaInfo> schemasInfo = new ArrayList<>();
+    TableCache tableCache = _pinotHelixResourceManager.getTableCache();
+    List<Schema> schemaList = tableCache.getSchemas();

Review Comment:
   This will by-pass the database check. We need to filter out schema that 
doesn't belong to the current database



##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/SegmentStatusInfo.java:
##########
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.controller.api.resources;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ * This class gives the details of a particular segment and it's status
+ *
+ */
+public class SegmentStatusInfo {
+  @JsonProperty("segmentName")
+  String _segmentName;
+
+  @JsonProperty("segmentStatus")
+  String _segmentStatus;
+
+  public String getSegmentName() {
+    return _segmentName;
+  }
+
+  public String getSegmentStatus() {
+    return _segmentStatus;
+  }
+
+  public SegmentStatusInfo(String segmentName, String segmentStatus) {

Review Comment:
   Same here, let's add a ser/de test to verify it works



##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSegmentRestletResource.java:
##########
@@ -231,25 +231,41 @@ public List<Map<TableType, List<String>>> getSegments(
   @Path("segments/{tableName}/servers")
   @Authorize(targetType = TargetType.TABLE, paramName = "tableName", action = 
Actions.Table.GET_SERVER_MAP)
   @Produces(MediaType.APPLICATION_JSON)
-  @ApiOperation(value = "Get a map from server to segments hosted by the 
server",
-      notes = "Get a map from server to segments hosted by the server")
+  @ApiOperation(value = "Get a map from server to segments hosted by the 
server", notes = "Get a map from server to "

Review Comment:
   (nit) Suggest reverting this change as the original one is more readable



##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSchemaRestletResource.java:
##########
@@ -118,6 +121,23 @@ public List<String> listSchemaNames(@Context HttpHeaders 
headers) {
     return 
_pinotHelixResourceManager.getSchemaNames(headers.getHeaderString(DATABASE));
   }
 
+  @GET
+  @Produces(MediaType.APPLICATION_JSON)
+  @Path("/schemas/info")
+  @Authorize(targetType = TargetType.CLUSTER, action = 
Actions.Cluster.GET_SCHEMA_INFO)
+  @ApiOperation(value = "List all schemas info with count of field specs", 
notes = "Lists all schemas with field "
+      + "count details")
+  public List<SchemaInfo> getSchemaInfo(@Context HttpHeaders headers) {
+    List<SchemaInfo> schemasInfo = new ArrayList<>();
+    TableCache tableCache = _pinotHelixResourceManager.getTableCache();
+    List<Schema> schemaList = tableCache.getSchemas();
+    for (Schema schema : schemaList) {
+      schemasInfo.add(new SchemaInfo(schema.getSchemaName(), 
schema.getDimensionFieldSpecs().size() - 3,

Review Comment:
   Suggest adding a constructor to `SchemaInfo` which takes a `schema` and hide 
the implementation details. Also consider adding some comments describing why 
we deduct 3 from dimensions



##########
pinot-spi/src/main/java/org/apache/pinot/spi/data/SchemaInfo.java:
##########
@@ -0,0 +1,65 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.spi.data;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+
+/**
+ * This class gives the details of a particular schema and the corresponding 
column metrics
+ *
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class SchemaInfo {
+  @JsonProperty("schemaName")
+  private String _schemaName;
+
+  @JsonProperty("numDimensionFields")
+  private int _numDimensionFields;
+
+  @JsonProperty("numDateTimeFields")
+  private int _numDateTimeFields;
+
+  @JsonProperty("numMetricFields")
+  private int _numMetricFields;
+
+  public String getSchemaName() {
+    return _schemaName;
+  }
+
+  public int getNumDimensionFields() {
+    return _numDimensionFields;
+  }
+
+  public int getNumDateTimeFields() {
+    return _numDateTimeFields;
+  }
+
+  public int getNumMetricFields() {
+    return _numMetricFields;
+  }
+
+  public SchemaInfo(String schemaName, int numDimensionFields, int 
numDateTimeFields, int numMetricFields) {

Review Comment:
   I think you'll need to annotate this as `@JsonCreator`, or provide an empty 
constructor, or it won't deserialize properly. Suggest adding a json ser/de 
test for this class to verify that it works as expected



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to