@Override public AggregateResult aggregate(EntityDefinition entityDefinition, Scan scan, List<String> groupbyFields, List<byte[]> aggregateFuncTypes, List<String> aggregatedFields) throws IOException { checkNotNull(entityDefinition, "entityDefinition"); String serviceName = entityDefinition.getService(); LOG.info(this.getLogHeader() + " raw group aggregate on service: " + serviceName + " by: " + groupbyFields + " func: " + AggregateFunctionType.fromBytesList(aggregateFuncTypes) + " fields: " + aggregatedFields); if (LOG.isDebugEnabled()) { LOG.debug("SCAN: " + scan.toJSON()); } final long startTimestamp = System.currentTimeMillis(); final RawAggregator aggregator = new RawAggregator(groupbyFields, AggregateFunctionType.fromBytesList(aggregateFuncTypes), aggregatedFields, entityDefinition); InternalReadReport report = this.asyncStreamRead(entityDefinition, scan, aggregator); List<GroupbyKeyValue> keyValues = aggregator.getGroupbyKeyValues(); AggregateResult result = new AggregateResult(); result.setKeyValues(keyValues); result.setStartTimestamp(report.getStartTimestamp()); result.setStopTimestamp(report.getStopTimestamp()); long _stop = System.currentTimeMillis(); LOG.info(String.format("%s: scan = %d rows, group = %d keys, startTime = %d, endTime = %d, spend = %d ms", this.getLogHeader(), report.getCounter(), keyValues.size(), report.getStartTimestamp(), report.getStopTimestamp(), (_stop - startTimestamp))); return result; }
/** * <pre> * Region-unittest * ,\x82\xB4\x85\xC2\x7F\xFF\xFE\xB6\xC9jNG\xEE!\x5C3\xBB\xAE\xA1 * :\x05\xA5\xA9x\xB0\xA1"8\x05\xFB(\xD2VY\xDB\x9A\x06\x09\xA9\x98\xC2\xE3\x8D=,1413960230654.aaf2a6c9f2c87c196f43497243bb2424. * * RegionID-unittest,1413960230654 * </pre> */ protected String getLogHeader() { HRegion region = this.getCurrentRegion(); return LOG.isDebugEnabled() ? String.format("Region-%s", region.getRegionNameAsString()) : String.format("Region-%s,%d", region.getTableDesc().getNameAsString(), region.getRegionId()); }
@Override public void aggregate(RpcController controller, AggregateProtos.AggregateRequest request, RpcCallback<AggregateProtos.AggregateResult> done) { AggregateResult result = null; try { result = this.aggregate(ProtoBufConverter.fromPBEntityDefinition(request.getEntityDefinition()), ProtoBufConverter.fromPBScan(request.getScan()), ProtoBufConverter.fromPBStringList(request.getGroupbyFieldsList()), ProtoBufConverter.fromPBByteArrayList(request.getAggregateFuncTypesList()), ProtoBufConverter.fromPBStringList(request.getAggregatedFieldsList()) ); } catch (IOException e) { ResponseConverter.setControllerException(controller, e); } try { done.run(ProtoBufConverter.toPBAggregateResult(result)); } catch (IOException e) { throw new RuntimeException("Failed to convert result to PB-based message", e); } }
@Override public void aggregate(RpcController controller, AggregateProtos.AggregateRequest request, RpcCallback<AggregateProtos.AggregateResult> done) { AggregateResult result = null; try { result = this.aggregate(ProtoBufConverter.fromPBEntityDefinition(request.getEntityDefinition()), ProtoBufConverter.fromPBScan(request.getScan()), ProtoBufConverter.fromPBStringList(request.getGroupbyFieldsList()), ProtoBufConverter.fromPBByteArrayList(request.getAggregateFuncTypesList()), ProtoBufConverter.fromPBStringList(request.getAggregatedFieldsList()) ); } catch (IOException e) { ResponseConverter.setControllerException(controller, e); } try { done.run(ProtoBufConverter.toPBAggregateResult(result)); } catch (IOException e) { throw new RuntimeException("Failed to convert result to PB-based message",e); } }
@Override public AggregateResult aggregate(EntityDefinition entityDefinition, Scan scan, List<String> groupbyFields, List<byte[]> aggregateFuncTypes, List<String> aggregatedFields, long startTime, long endTime, long intervalMin) throws IOException { checkNotNull(entityDefinition, "entityDefinition"); String serviceName = entityDefinition.getService(); LOG.info(this.getLogHeader() + " time series group aggregate on service: " + serviceName + " by: " + groupbyFields + " func: " + AggregateFunctionType.fromBytesList(aggregateFuncTypes) + " fields: " + aggregatedFields + " intervalMin: " + intervalMin final TimeSeriesAggregator aggregator = new TimeSeriesAggregator(groupbyFields, AggregateFunctionType.fromBytesList(aggregateFuncTypes), aggregatedFields, startTime, endTime, intervalMin); InternalReadReport report = this.asyncStreamRead(entityDefinition, scan, aggregator); List<GroupbyKeyValue> keyValues = aggregator.getGroupbyKeyValues(); this.getLogHeader(), report.getCounter(), keyValues.size(), report.getStartTimestamp(), report.getStopTimestamp(), (_stop - startTimestamp)));
/** * <pre> * Region-unittest,\x82\xB4\x85\xC2\x7F\xFF\xFE\xB6\xC9jNG\xEE!\x5C3\xBB\xAE\xA1:\x05\xA5\xA9x\xB0\xA1"8\x05\xFB(\xD2VY\xDB\x9A\x06\x09\xA9\x98\xC2\xE3\x8D=,1413960230654.aaf2a6c9f2c87c196f43497243bb2424. * RegionID-unittest,1413960230654 * </pre> */ protected String getLogHeader(){ HRegion region = this.getCurrentRegion(); return LOG.isDebugEnabled() ? String.format("Region-%s",region.getRegionNameAsString()): String.format("Region-%s,%d",region.getTableDesc().getNameAsString(),region.getRegionId()); }
@Override public void timeseriesAggregate(RpcController controller, AggregateProtos.TimeSeriesAggregateRequest request, RpcCallback<AggregateProtos.AggregateResult> done) { AggregateResult result = null; try { result = this.aggregate(ProtoBufConverter.fromPBEntityDefinition(request.getEntityDefinition()), ProtoBufConverter.fromPBScan(request.getScan()), ProtoBufConverter.fromPBStringList(request.getGroupbyFieldsList()), ProtoBufConverter.fromPBByteArrayList(request.getAggregateFuncTypesList()), ProtoBufConverter.fromPBStringList(request.getAggregatedFieldsList()), request.getStartTime(), request.getEndTime(), request.getIntervalMin() ); } catch (IOException e) { LOG.error("Failed to convert result to PB-based message", e); ResponseConverter.setControllerException(controller, e); } try { done.run(ProtoBufConverter.toPBAggregateResult(result)); } catch (IOException e) { LOG.error("Failed to convert result to PB-based message", e); ResponseConverter.setControllerException(controller, e); } }
public AggregateResult aggregate(EntityDefinition entityDefinition, Scan scan, List<String> groupbyFields, List<byte[]> aggregateFuncTypes, List<String> aggregatedFields) throws IOException { checkNotNull(entityDefinition, "entityDefinition"); String serviceName = entityDefinition.getService(); LOG.info(this.getLogHeader() +" raw group aggregate on service: " + serviceName + " by: " + groupbyFields + " func: " + AggregateFunctionType.fromBytesList(aggregateFuncTypes) + " fields: " + aggregatedFields); if(LOG.isDebugEnabled()) LOG.debug("SCAN: "+scan.toJSON()); long _start = System.currentTimeMillis(); final RawAggregator aggregator = new RawAggregator(groupbyFields,AggregateFunctionType.fromBytesList(aggregateFuncTypes),aggregatedFields,entityDefinition); InternalReadReport report = this.asyncStreamRead(entityDefinition, scan, aggregator); LOG.info(String.format("%s: scan = %d rows, group = %d keys, startTime = %d, endTime = %d, spend = %d ms", this.getLogHeader(),report.getCounter(),keyValues.size(),report.getStartTimestamp(),report.getStopTimestamp(),(_stop - _start)));
long startTimestamp = 0; long stopTimestamp = 0; InternalScanner scanner = this.getCurrentRegion().getScanner(scan); List<Cell> results = new ArrayList<Cell>(); try {
@Override public void timeseriesAggregate(RpcController controller, AggregateProtos.TimeSeriesAggregateRequest request, RpcCallback<AggregateProtos.AggregateResult> done) { AggregateResult result = null; try { result = this.aggregate(ProtoBufConverter.fromPBEntityDefinition(request.getEntityDefinition()), ProtoBufConverter.fromPBScan(request.getScan()), ProtoBufConverter.fromPBStringList(request.getGroupbyFieldsList()), ProtoBufConverter.fromPBByteArrayList(request.getAggregateFuncTypesList()), ProtoBufConverter.fromPBStringList(request.getAggregatedFieldsList()), request.getStartTime(), request.getEndTime(), request.getIntervalMin() ); } catch (IOException e) { LOG.error("Failed to convert result to PB-based message",e); ResponseConverter.setControllerException(controller, e); } try { done.run(ProtoBufConverter.toPBAggregateResult(result)); } catch (IOException e) { LOG.error("Failed to convert result to PB-based message",e); ResponseConverter.setControllerException(controller, e); } }
public AggregateResult aggregate(EntityDefinition entityDefinition, Scan scan, List<String> groupbyFields, List<byte[]> aggregateFuncTypes, List<String> aggregatedFields, long startTime,long endTime,long intervalMin) throws IOException { checkNotNull(entityDefinition, "entityDefinition"); String serviceName = entityDefinition.getService(); LOG.info(this.getLogHeader() + " time series group aggregate on service: " + serviceName + " by: " + groupbyFields + " func: " + AggregateFunctionType.fromBytesList(aggregateFuncTypes) + " fields: " + aggregatedFields + " intervalMin: " + intervalMin + " from: " + DateTimeUtil.millisecondsToHumanDateWithMilliseconds(startTime) + " to: " + DateTimeUtil.millisecondsToHumanDateWithMilliseconds(endTime)); if(LOG.isDebugEnabled()) LOG.debug("SCAN: "+scan.toJSON()); long _start = System.currentTimeMillis(); final TimeSeriesAggregator aggregator = new TimeSeriesAggregator(groupbyFields,AggregateFunctionType.fromBytesList(aggregateFuncTypes),aggregatedFields,startTime,endTime,intervalMin); InternalReadReport report = this.asyncStreamRead(entityDefinition, scan,aggregator); List<GroupbyKeyValue> keyValues = aggregator.getGroupbyKeyValues(); LOG.info(String.format("%s: scan = %d rows, group = %d keys, startTime = %d, endTime = %d, spend = %d ms", this.getLogHeader(),report.getCounter(),keyValues.size(),report.getStartTimestamp(),report.getStopTimestamp(),(_stop - _start)));
long startTimestamp = 0; long stopTimestamp = 0; InternalScanner scanner = this.getCurrentRegion().getScanner(scan); List<Cell> results = new ArrayList<Cell>(); try{
long stopTimestamp = 0; InternalScanner scanner = this.getCurrentRegion().getScanner(scan); List<Cell> results = new ArrayList<Cell>(); try {
long stopTimestamp = 0; InternalScanner scanner = this.getCurrentRegion().getScanner(scan); List<Cell> results = new ArrayList<Cell>(); try{