Skip to content

Commit

Permalink
Merge pull request apache#1995 from himanshug/num_rows_seg_metadata_q…
Browse files Browse the repository at this point in the history
…uery

add numRows to segment metadata query response
  • Loading branch information
jon-wei committed Dec 17, 2015
2 parents 628643d + 7a89b2e commit f8cf84f
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 6 deletions.
4 changes: 3 additions & 1 deletion docs/content/querying/segmentmetadataquery.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
} ]
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,13 @@ public SegmentAnalysis apply(SegmentAnalysis arg1, SegmentAnalysis arg2)
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()
);
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ public Sequence<SegmentAnalysis> run(Query<SegmentAnalysis> inQ, Map<String, Obj
segment.getIdentifier(),
Arrays.asList(segment.getDataInterval()),
columns,
totalSize
totalSize,
numRows
)
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,23 @@ 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

)
{
this.id = id;
this.interval = interval;
this.columns = columns;
this.size = size;
this.numRows = numRows;
}

@JsonProperty
Expand All @@ -72,13 +75,20 @@ public long getSize()
return size;
}

@JsonProperty
public int getNumRows()
{
return numRows;
}

public String toDetailedString()
{
return "SegmentAnalysis{" +
"id='" + id + '\'' +
", interval=" + interval +
", columns=" + columns +
", size=" + size +
", numRows=" + numRows +
'}';
}

Expand All @@ -89,6 +99,7 @@ public String toString()
"id='" + id + '\'' +
", interval=" + interval +
", size=" + size +
", numRows=" + numRows +
'}';
}

Expand All @@ -107,6 +118,11 @@ public boolean equals(Object o)
if (size != that.size) {
return false;
}

if (numRows != that.numRows) {
return false;
}

if (id != null ? !id.equals(that.id) : that.id != null) {
return false;
}
Expand All @@ -124,6 +140,7 @@ public int hashCode()
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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ public void testCacheStrategy() throws Exception
1,
null
)
), 71982
), 71982,
100
);

Object preparedValue = strategy.prepareForCache().apply(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ public SegmentMetadataQueryTest()
1,
null
)
), 71982
), 71982,
1209
);
}

Expand Down

0 comments on commit f8cf84f

Please sign in to comment.