Skip to content

Commit

Permalink
Explorer UI: show num shards per type
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunjeet committed Jul 14, 2023
1 parent 644569d commit 9d73930
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,18 @@ public class TypeOverview {
private final long approxHeapFootprint;
private final PrimaryKey primaryKey;
private final HollowSchema schema;
private final int numShards;

public TypeOverview(String typeName, int numRecords, int numHoles, long approxHoleFootprint, long approxHeapFootprint, PrimaryKey primaryKey, HollowSchema schema) {
public TypeOverview(String typeName, int numRecords, int numHoles, long approxHoleFootprint, long approxHeapFootprint,
PrimaryKey primaryKey, HollowSchema schema, int numShards) {
this.typeName = typeName;
this.numRecords = numRecords;
this.numHoles = numHoles;
this.approxHoleFootprint = approxHoleFootprint;
this.approxHeapFootprint = approxHeapFootprint;
this.primaryKey = primaryKey;
this.schema = schema;
this.numShards = numShards;
}

public String getTypeName() {
Expand Down Expand Up @@ -68,4 +71,11 @@ public String getPrimaryKey() {
public String getSchema() {
return schema.toString();
}

public int getNumShardsInt() {
return numShards;
}
public String getNumShards() {
return NumberFormat.getIntegerInstance().format(numShards);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ protected void setUpContext(HttpServletRequest req, HollowUISession session, Vel
PrimaryKey primaryKey = typeState.getSchema().getSchemaType() == SchemaType.OBJECT ? ((HollowObjectSchema)typeState.getSchema()).getPrimaryKey() : null;
long approxHeapFootprint = typeState.getApproximateHeapFootprintInBytes();
HollowSchema schema = typeState.getSchema();
int numShards = typeState.numShards();

typeOverviews.add(new TypeOverview(typeName, numRecords, numHoles, approxHoleFootprint, approxHeapFootprint, primaryKey, schema));
typeOverviews.add(new TypeOverview(typeName, numRecords, numHoles, approxHoleFootprint, approxHeapFootprint, primaryKey, schema, numShards));
}

switch(sort) {
Expand All @@ -76,10 +77,10 @@ public int compare(TypeOverview o1, TypeOverview o2) {
}
});
break;
case "numHoles":
case "numHoles":
typeOverviews.sort((o1, o2) -> Integer.compare(o2.getNumHolesInt(), o1.getNumHolesInt()));
break;
case "holeSize":
case "holeSize":
typeOverviews.sort((o1, o2) -> Long.compare(o2.getApproxHoleFootprintLong(), o1.getApproxHoleFootprintLong()));
break;
case "heapSize":
Expand All @@ -89,6 +90,9 @@ public int compare(TypeOverview o1, TypeOverview o2) {
}
});
break;
case "numShards":
typeOverviews.sort((o1, o2) -> Integer.compare(o2.getNumShardsInt(), o1.getNumShardsInt()));
break;
default:
Collections.sort(typeOverviews, new Comparator<TypeOverview>() {
public int compare(TypeOverview o1, TypeOverview o2) {
Expand Down
2 changes: 2 additions & 0 deletions hollow-explorer-ui/src/main/resources/show-all-types.vm
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<th><a href="$basePath/home?sort=heapSize">Heap Footprint</a></th>
<th><a href="$basePath/home?sort=primaryKey">Primary Key</a></th>
<th><a href="$basePath/home?sort=primaryKey">Schema</a></th>
<th><a href="$basePath/home?sort=numShards">Shards</a></th>
</tr>

#foreach($typeOverview in $typeOverviews)
Expand All @@ -36,6 +37,7 @@
<td>$typeOverview.getApproxHeapFootprint()</td>
<td><pre>$esc.html($typeOverview.getPrimaryKey())</pre></td>
<td><pre>$esc.html($typeOverview.getSchema())</pre></td>
<td>$typeOverview.getNumShards()</td>
</tr>
#end
</table>

0 comments on commit 9d73930

Please sign in to comment.