in tablestore/src/main/java/com/alicloud/openservices/tablestore/core/protocol/timeseries/TimeseriesResponseFactory.java [119:155]
public static TimeseriesRow parseRowFromPlainbuffer(PlainBufferRow plainBufferRow) throws IOException {
List<PlainBufferCell> primaryKeys = plainBufferRow.getPrimaryKey();
int timeseriesKeyCount = 0;
String measurement = "", source = "", tagsStr = "";
long time = -1;
SortedMap<String, String> tags = new TreeMap<String, String>();
for (int i = 0; i < primaryKeys.size(); i++) {
PlainBufferCell pkCell = primaryKeys.get(i);
if (pkCell.getCellName().equals(MEASUREMENT_COLUMN_NAME)) {
measurement = pkCell.getPkCellValue().asString();
} else if (pkCell.getCellName().equals(DATASOURCE_COLUMN_NAME)) {
source = pkCell.getPkCellValue().asString();
} else if (pkCell.getCellName().equals(TAGS_COLUMN_NAME)) {
tagsStr = pkCell.getPkCellValue().asString();
} else if (pkCell.getCellName().equals(TIME_COLUMN_NAME)) {
timeseriesKeyCount = i;
time = pkCell.getPkCellValue().asLong();
break;
} else if (!pkCell.getCellName().equals(HASH_COLUMN_NAME)) {
tags.put(pkCell.getCellName(), pkCell.getPkCellValue().asString());
}
}
if (!tagsStr.isEmpty()) {
tags.putAll(parseTagsOrAttrs(tagsStr));
}
if (time == -1) {
throw new ClientException("time column not found in timeseries row");
}
TimeseriesRow row = new TimeseriesRow(new TimeseriesKey(measurement, source, tags), time);
for (PlainBufferCell cell : plainBufferRow.getCells()) {
row.addField(convertColumnName(cell.getCellName()), cell.getCellValue());
}
for (PlainBufferCell cell : plainBufferRow.getPrimaryKey().subList(timeseriesKeyCount + 1, plainBufferRow.getPrimaryKey().size())) {
row.addField(cell.getCellName(), cell.getPkCellValue().toColumnValue());
}
return row;
}