@Override protected Double getFinalResult() { return ci.divideForAvg(sum, count); } };
@Override protected Double getFinalResult() { double avg = ci.divideForAvg(sum, count); double avgSq = ci.divideForAvg(sumSq, count); return Math.sqrt(avgSq - avg * avg); } };
/** * This is the client side interface/handle for calling the std method for a * given cf-cq combination. It was necessary to add one more call stack as its * return type should be a decimal value, irrespective of what * columninterpreter says. So, this methods collects the necessary parameters * to compute the std and returns the double value. * @param table table to scan. * @param ci the user's ColumnInterpreter implementation * @param scan the HBase scan object to use to read data from HBase * @return <R, S> * @throws Throwable The caller is supposed to handle the exception as they are thrown * & propagated to it. */ public <R, S, P extends Message, Q extends Message, T extends Message> double std( final Table table, ColumnInterpreter<R, S, P, Q, T> ci, Scan scan) throws Throwable { Pair<List<S>, Long> p = getStdArgs(table, ci, scan); double res = 0d; double avg = ci.divideForAvg(p.getFirst().get(0), p.getSecond()); double avgOfSumSq = ci.divideForAvg(p.getFirst().get(1), p.getSecond()); res = avgOfSumSq - (avg) * (avg); // variance res = Math.pow(res, 0.5); return res; }
/** * This is the client side interface/handle for calling the average method for * a given cf-cq combination. It was necessary to add one more call stack as * its return type should be a decimal value, irrespective of what * columninterpreter says. So, this methods collects the necessary parameters * to compute the average and returs the double value. * @param tableName the name of the table to scan * @param ci the user's ColumnInterpreter implementation * @param scan the HBase scan object to use to read data from HBase * @return <R, S> * @throws Throwable The caller is supposed to handle the exception as they are thrown * & propagated to it. */ public <R, S, P extends Message, Q extends Message, T extends Message> double avg(final TableName tableName, final ColumnInterpreter<R, S, P, Q, T> ci, Scan scan) throws Throwable { Pair<S, Long> p = getAvgArgs(tableName, ci, scan); return ci.divideForAvg(p.getFirst(), p.getSecond()); }
/** * This is the client side interface/handle for calling the average method for * a given cf-cq combination. It was necessary to add one more call stack as * its return type should be a decimal value, irrespective of what * columninterpreter says. So, this methods collects the necessary parameters * to compute the average and returs the double value. * @param table table to scan. * @param ci the user's ColumnInterpreter implementation * @param scan the HBase scan object to use to read data from HBase * @return <R, S> * @throws Throwable The caller is supposed to handle the exception as they are thrown * & propagated to it. */ public <R, S, P extends Message, Q extends Message, T extends Message> double avg( final Table table, final ColumnInterpreter<R, S, P, Q, T> ci, Scan scan) throws Throwable { Pair<S, Long> p = getAvgArgs(table, ci, scan); return ci.divideForAvg(p.getFirst(), p.getSecond()); }
private static <R, S, P extends Message, Q extends Message, T extends Message> void findMedian( CompletableFuture<R> future, AsyncTable<AdvancedScanResultConsumer> table, ColumnInterpreter<R, S, P, Q, T> ci, Scan scan, NavigableMap<byte[], S> sumByRegion) { double halfSum = ci.divideForAvg(sumByRegion.values().stream().reduce(ci::add).get(), 2L); S movingSum = null; byte[] startRow = null; startRow = entry.getKey(); S newMovingSum = ci.add(movingSum, entry.getValue()); if (ci.divideForAvg(newMovingSum, 1L) > halfSum) { break;
@Override public void onNext(Result[] results, ScanController controller) { try { for (Result result : results) { Cell weightCell = result.getColumnLatestCell(family, weightQualifier); R weight = ci.getValue(family, weightQualifier, weightCell); sum = ci.add(sum, ci.castToReturnType(weight)); if (ci.divideForAvg(sum, 1L) > halfSum) { if (value != null) { future.complete(value); } else { future.completeExceptionally(new NoSuchElementException()); } controller.terminate(); return; } Cell valueCell = result.getColumnLatestCell(family, valueQualifier); value = ci.getValue(family, valueQualifier, valueCell); } } catch (IOException e) { future.completeExceptionally(e); controller.terminate(); } }
S sumVal = p.getSecond().get(0); S sumWeights = p.getSecond().get(1); double halfSumVal = ci.divideForAvg(sumVal, 2L); double movingSumVal = 0; boolean weighted = false; if (quals.size() > 1) { weighted = true; halfSumVal = ci.divideForAvg(sumWeights, 2L); double newSumVal = movingSumVal + ci.divideForAvg(s, 1L); if (newSumVal > halfSumVal) { R newValue = ci.getValue(colFamily, weightQualifier, kv); S s = ci.castToReturnType(newValue); double newSumVal = movingSumVal + ci.divideForAvg(s, 1L);
@Override protected Double getFinalResult() { return ci.divideForAvg(sum, count); } };
@Override protected Double getFinalResult() { return ci.divideForAvg(sum, count); } };
@Override protected Double getFinalResult() { double avg = ci.divideForAvg(sum, count); double avgSq = ci.divideForAvg(sumSq, count); return Math.sqrt(avgSq - avg * avg); } };
@Override protected Double getFinalResult() { double avg = ci.divideForAvg(sum, count); double avgSq = ci.divideForAvg(sumSq, count); return Math.sqrt(avgSq - avg * avg); } };
/** * This is the client side interface/handle for calling the std method for a * given cf-cq combination. It was necessary to add one more call stack as its * return type should be a decimal value, irrespective of what * columninterpreter says. So, this methods collects the necessary parameters * to compute the std and returns the double value. * @param tableName * @param ci * @param scan * @return <R, S> * @throws Throwable */ public <R, S> double std(final byte[] tableName, ColumnInterpreter<R, S> ci, Scan scan) throws Throwable { Pair<List<S>, Long> p = getStdArgs(tableName, ci, scan); double res = 0d; double avg = ci.divideForAvg(p.getFirst().get(0), p.getSecond()); double avgOfSumSq = ci.divideForAvg(p.getFirst().get(1), p.getSecond()); res = avgOfSumSq - (avg) * (avg); // variance res = Math.pow(res, 0.5); return res; }
/** * This is the client side interface/handle for calling the average method for * a given cf-cq combination. It was necessary to add one more call stack as * its return type should be a decimal value, irrespective of what * columninterpreter says. So, this methods collects the necessary parameters * to compute the average and returs the double value. * @param tableName * @param ci * @param scan * @return <R, S> * @throws Throwable */ public <R, S, P extends Message, Q extends Message, T extends Message> double avg(final TableName tableName, final ColumnInterpreter<R, S, P, Q, T> ci, Scan scan) throws Throwable { Pair<S, Long> p = getAvgArgs(tableName, ci, scan); return ci.divideForAvg(p.getFirst(), p.getSecond()); }
/** * This is the client side interface/handle for calling the average method for * a given cf-cq combination. It was necessary to add one more call stack as * its return type should be a decimal value, irrespective of what * columninterpreter says. So, this methods collects the necessary parameters * to compute the average and returs the double value. * @param tableName * @param ci * @param scan * @return <R, S> * @throws Throwable */ public <R, S> double avg(final byte[] tableName, final ColumnInterpreter<R, S> ci, Scan scan) throws Throwable { Pair<S, Long> p = getAvgArgs(tableName, ci, scan); return ci.divideForAvg(p.getFirst(), p.getSecond()); }
/** * This is the client side interface/handle for calling the average method for * a given cf-cq combination. It was necessary to add one more call stack as * its return type should be a decimal value, irrespective of what * columninterpreter says. So, this methods collects the necessary parameters * to compute the average and returs the double value. * @param table * @param ci * @param scan * @return <R, S> * @throws Throwable */ public <R, S, P extends Message, Q extends Message, T extends Message> double avg( final Table table, final ColumnInterpreter<R, S, P, Q, T> ci, Scan scan) throws Throwable { Pair<S, Long> p = getAvgArgs(table, ci, scan); return ci.divideForAvg(p.getFirst(), p.getSecond()); }
/** * This is the client side interface/handle for calling the average method for * a given cf-cq combination. It was necessary to add one more call stack as * its return type should be a decimal value, irrespective of what * columninterpreter says. So, this methods collects the necessary parameters * to compute the average and returs the double value. * @param table * @param ci * @param scan * @return <R, S> * @throws Throwable */ public <R, S, P extends Message, Q extends Message, T extends Message> double avg( final Table table, final ColumnInterpreter<R, S, P, Q, T> ci, Scan scan) throws Throwable { Pair<S, Long> p = getAvgArgs(table, ci, scan); return ci.divideForAvg(p.getFirst(), p.getSecond()); }
/** * This is the client side interface/handle for calling the average method for * a given cf-cq combination. It was necessary to add one more call stack as * its return type should be a decimal value, irrespective of what * columninterpreter says. So, this methods collects the necessary parameters * to compute the average and returs the double value. * @param tableName the name of the table to scan * @param ci the user's ColumnInterpreter implementation * @param scan the HBase scan object to use to read data from HBase * @return <R, S> * @throws Throwable The caller is supposed to handle the exception as they are thrown * & propagated to it. */ public <R, S, P extends Message, Q extends Message, T extends Message> double avg(final TableName tableName, final ColumnInterpreter<R, S, P, Q, T> ci, Scan scan) throws Throwable { Pair<S, Long> p = getAvgArgs(tableName, ci, scan); return ci.divideForAvg(p.getFirst(), p.getSecond()); }
/** * This is the client side interface/handle for calling the average method for * a given cf-cq combination. It was necessary to add one more call stack as * its return type should be a decimal value, irrespective of what * columninterpreter says. So, this methods collects the necessary parameters * to compute the average and returs the double value. * @param table table to scan. * @param ci the user's ColumnInterpreter implementation * @param scan the HBase scan object to use to read data from HBase * @return <R, S> * @throws Throwable The caller is supposed to handle the exception as they are thrown * & propagated to it. */ public <R, S, P extends Message, Q extends Message, T extends Message> double avg( final Table table, final ColumnInterpreter<R, S, P, Q, T> ci, Scan scan) throws Throwable { Pair<S, Long> p = getAvgArgs(table, ci, scan); return ci.divideForAvg(p.getFirst(), p.getSecond()); }
/** * This is the client side interface/handle for calling the average method for * a given cf-cq combination. It was necessary to add one more call stack as * its return type should be a decimal value, irrespective of what * columninterpreter says. So, this methods collects the necessary parameters * to compute the average and returs the double value. * @param tableName * @param ci * @param scan * @return <R, S> * @throws Throwable */ public <R, S, P extends Message, Q extends Message, T extends Message> double avg(final TableName tableName, final ColumnInterpreter<R, S, P, Q, T> ci, Scan scan) throws Throwable { Pair<S, Long> p = getAvgArgs(tableName, ci, scan); return ci.divideForAvg(p.getFirst(), p.getSecond()); }