Skip to content

Commit

Permalink
[#11252] Limit query to one row for faster response
Browse files Browse the repository at this point in the history
  • Loading branch information
intr3p1d committed Jul 25, 2024
1 parent 5dbf0be commit 5967edb
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ <T extends AgentStatDataPoint> boolean agentStatExists(AgentStatType agentStatTy
}

int resultLimit = 20;
Scan scan = this.createScan(agentStatType, agentId, range, resultLimit);
Scan scan = this.checkExist(agentStatType, agentId, range, resultLimit);

Check warning on line 93 in web/src/main/java/com/navercorp/pinpoint/web/dao/hbase/stat/HbaseAgentStatDaoOperations.java

View check run for this annotation

Codecov / codecov/patch

web/src/main/java/com/navercorp/pinpoint/web/dao/hbase/stat/HbaseAgentStatDaoOperations.java#L93

Added line #L93 was not covered by tests

TableName agentStatTableName = tableNameProvider.getTableName(columnFamily.getTable());
List<List<T>> result = hbaseOperations.findParallel(agentStatTableName, scan, this.operationFactory.getRowKeyDistributor(), resultLimit, mapper, AGENT_STAT_VER2_NUM_PARTITIONS);
Expand Down Expand Up @@ -130,5 +130,12 @@ private Scan createScan(AgentStatType agentStatType, String agentId, Range range
return scan;
}


private Scan checkExist(AgentStatType agentStatType, String agentId, Range range, int scanCacheSize) {
Scan scan = this.operationFactory.createScan(agentId, agentStatType, range.getFrom(), range.getTo());
scan.setCaching(scanCacheSize);
scan.setOneRowLimit();
scan.setId(agentStatType.getChartType());
scan.addFamily(columnFamily.getName());
return scan;

Check warning on line 139 in web/src/main/java/com/navercorp/pinpoint/web/dao/hbase/stat/HbaseAgentStatDaoOperations.java

View check run for this annotation

Codecov / codecov/patch

web/src/main/java/com/navercorp/pinpoint/web/dao/hbase/stat/HbaseAgentStatDaoOperations.java#L134-L139

Added lines #L134 - L139 were not covered by tests
}
}

0 comments on commit 5967edb

Please sign in to comment.