QueryResult
Class: com.aliyun.hitsdb.client.value.response.QueryResult
Inheritance hierarchy:
java.lang.Object
└── com.aliyun.hitsdb.client.value.JSONValue
└── com.aliyun.hitsdb.client.value.response.QueryResultpublic class QueryResult extends JSONValueRepresents a single time series result returned by a data query. Each QueryResult instance holds the metric name, tags, data points (dps), and — when results span multiple time series — the aggregate tags that were common across all series.
Constructor summary
| Constructor | Description |
|---|---|
QueryResult() | Creates an empty query result instance. |
Method summary
Getters
| Return type | Method | Description |
|---|---|---|
String | getMetric() | Returns the metric name for this result. |
Map<String, String> | getTags() | Returns the tags for this result. Non-empty only when the result represents a single, non-aggregated time series. |
List<String> | getAggregateTags() | Returns the tag names shared across all aggregated time series. Non-empty only when the result aggregates multiple time series. |
LinkedHashMap<Long, Number> | getDps() | Returns the data points as a map of Unix timestamps to numeric values, ordered by insertion. |
Setters
| Return type | Method | Description |
|---|---|---|
void | setMetric(String metric) | Sets the metric name. |
void | setTags(Map<String, String> tags) | Sets the tags. |
void | setAggregateTags(List<String> aggregateTags) | Sets the aggregate tags. |
void | setDps(LinkedHashMap<Long, Number> dps) | Sets the data points. |
Inherited from com.aliyun.hitsdb.client.value.JSONValue
appendJSON, parseObject, toJSON, toString
Inherited from java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait
Tags vs. aggregate tags
A query result contains two tag-related fields. Which field is populated depends on whether the query returns a single time series or aggregates multiple series.
| Scenario | getTags() | getAggregateTags() |
|---|---|---|
| Single time series (no aggregation) | Returns all tags that identify this series, e.g., {"host": "web01", "region": "cn-hangzhou"} | Empty |
| Multiple time series (aggregated) | Empty | Returns the tag names shared across all aggregated series, e.g., ["host"] |
Example — aggregated result:
{
"metric": "sys.cpu.user",
"tags": {},
"aggregateTags": ["host"],
"dps": {
"1365966001": 42.5,
"1365966061": 43.1
}
}In this example, the query aggregated data from multiple hosts. The host tag appeared in all series, so it is listed in aggregateTags rather than tags.
Constructor details
QueryResult()
public QueryResult()Creates an empty QueryResult instance.
Method details
getMetric()
public String getMetric()Returns: The metric name for this result.
setMetric(String metric)
public void setMetric(String metric)Parameters:
metric— The metric name to set.
getTags()
public Map<String, String> getTags()Returns: A map of tag key-value pairs for this result. Non-empty only when the result represents a single, non-aggregated time series.
setTags(Map<String, String> tags)
public void setTags(Map<String, String> tags)Parameters:
tags— The tag map to set.
getAggregateTags()
public List<String> getAggregateTags()Returns: A list of tag names that were common across all aggregated time series. Non-empty only when the result aggregates multiple time series.
setAggregateTags(List<String> aggregateTags)
public void setAggregateTags(List<String> aggregateTags)Parameters:
aggregateTags— The aggregate tag name list to set.
getDps()
public LinkedHashMap<Long, Number> getDps()Returns: The data points as a LinkedHashMap of Unix timestamps (as Long) to numeric values (as Number), ordered by insertion.
setDps(LinkedHashMap<Long, Number> dps)
public void setDps(LinkedHashMap<Long, Number> dps)Parameters:
dps— The data points map to set.