Merge pull request #1995 from himanshug/num_rows_seg_metadata_query

add numRows to segment metadata query response
This commit is contained in:
Jonathan Wei 2015-12-17 12:23:46 -08:00
commit f8cf84f466
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

@ -134,7 +134,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

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

View File

@ -32,13 +32,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
)
{
@ -46,6 +48,7 @@ public class SegmentAnalysis
this.interval = interval;
this.columns = columns;
this.size = size;
this.numRows = numRows;
}
@JsonProperty
@ -72,6 +75,12 @@ public class SegmentAnalysis
return size;
}
@JsonProperty
public int getNumRows()
{
return numRows;
}
public String toDetailedString()
{
return "SegmentAnalysis{" +
@ -79,6 +88,7 @@ public class SegmentAnalysis
", interval=" + interval +
", columns=" + columns +
", size=" + size +
", numRows=" + numRows +
'}';
}
@ -89,6 +99,7 @@ public class SegmentAnalysis
"id='" + id + '\'' +
", interval=" + interval +
", size=" + size +
", numRows=" + numRows +
'}';
}
@ -107,6 +118,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;
}
@ -124,6 +140,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

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