add numRows to segment metadata query response

This commit is contained in:
Himanshu Gupta 2015-11-20 01:12:39 -06:00
parent 6305dfe1b9
commit 7a89b2e1a6
6 changed files with 34 additions and 6 deletions

View File

@ -6,6 +6,7 @@ Segment metadata queries return per segment information about:
* Cardinality of all columns in the segment
* Estimated byte size for the segment columns if they were stored in a flat format
* Number of rows stored inside the segment
* Interval the segment covers
* Column type of all the columns in the segment
* Estimated total segment byte size in if it was stored in a flat format
@ -43,7 +44,8 @@ The format of the result is:
"dim2" : { "type" : "STRING", "size" : 100000, "cardinality" : 1504 },
"metric1" : { "type" : "FLOAT", "size" : 100000, "cardinality" : null }
},
"size" : 300000
"size" : 300000,
"numRows" : 5000000
} ]
```

View File

@ -132,7 +132,13 @@ public class SegmentMetadataQueryQueryToolChest extends QueryToolChest<SegmentAn
columns.put(columnName, rightColumns.get(columnName));
}
return new SegmentAnalysis("merged", newIntervals, columns, arg1.getSize() + arg2.getSize());
return new SegmentAnalysis(
"merged",
newIntervals,
columns,
arg1.getSize() + arg2.getSize(),
arg1.getNumRows() + arg2.getNumRows()
);
}
};
}

View File

@ -122,7 +122,8 @@ public class SegmentMetadataQueryRunnerFactory implements QueryRunnerFactory<Seg
segment.getIdentifier(),
Arrays.asList(segment.getDataInterval()),
columns,
totalSize
totalSize,
numRows
)
)
);

View File

@ -30,13 +30,15 @@ public class SegmentAnalysis
private final List<Interval> interval;
private final Map<String, ColumnAnalysis> columns;
private final long size;
private final int numRows;
@JsonCreator
public SegmentAnalysis(
@JsonProperty("id") String id,
@JsonProperty("intervals") List<Interval> interval,
@JsonProperty("columns") Map<String, ColumnAnalysis> columns,
@JsonProperty("size") long size
@JsonProperty("size") long size,
@JsonProperty("numRows") int numRows
)
{
@ -44,6 +46,7 @@ public class SegmentAnalysis
this.interval = interval;
this.columns = columns;
this.size = size;
this.numRows = numRows;
}
@JsonProperty
@ -70,6 +73,12 @@ public class SegmentAnalysis
return size;
}
@JsonProperty
public int getNumRows()
{
return numRows;
}
public String toDetailedString()
{
return "SegmentAnalysis{" +
@ -77,6 +86,7 @@ public class SegmentAnalysis
", interval=" + interval +
", columns=" + columns +
", size=" + size +
", numRows=" + numRows +
'}';
}
@ -87,6 +97,7 @@ public class SegmentAnalysis
"id='" + id + '\'' +
", interval=" + interval +
", size=" + size +
", numRows=" + numRows +
'}';
}
@ -105,6 +116,11 @@ public class SegmentAnalysis
if (size != that.size) {
return false;
}
if (numRows != that.numRows) {
return false;
}
if (id != null ? !id.equals(that.id) : that.id != null) {
return false;
}
@ -122,6 +138,7 @@ public class SegmentAnalysis
result = 31 * result + (interval != null ? interval.hashCode() : 0);
result = 31 * result + (columns != null ? columns.hashCode() : 0);
result = 31 * result + (int) (size ^ (size >>> 32));
result = 31 * result + (int) (numRows ^ (numRows >>> 32));
return result;
}
}

View File

@ -71,7 +71,8 @@ public class SegmentMetadataQueryQueryToolChestTest
1,
null
)
), 71982
), 71982,
100
);
Object preparedValue = strategy.prepareForCache().apply(result);

View File

@ -103,7 +103,8 @@ public class SegmentMetadataQueryTest
1,
null
)
), 71982
), 71982,
1209
);
}