Tabnine Logo
AsyncAggregationClient
Code IndexAdd Tabnine to your IDE (free)

How to use
AsyncAggregationClient
in
org.apache.hadoop.hbase.client.coprocessor

Best Java code snippets using org.apache.hadoop.hbase.client.coprocessor.AsyncAggregationClient (Showing top 20 results out of 315)

origin: apache/hbase

@Test
public void testAvg() throws InterruptedException, ExecutionException {
 assertEquals((COUNT - 1) / 2.0, AsyncAggregationClient
   .avg(TABLE, new LongColumnInterpreter(), new Scan().addColumn(CF, CQ)).get().doubleValue(),
  DELTA);
}
origin: apache/hbase

 public static <R, S, P extends Message, Q extends Message, T extends Message>
     CompletableFuture<R> median(AsyncTable<AdvancedScanResultConsumer> table,
     ColumnInterpreter<R, S, P, Q, T> ci, Scan scan) {
  CompletableFuture<R> future = new CompletableFuture<>();
  sumByRegion(table, ci, scan).whenComplete((sumByRegion, error) -> {
   if (error != null) {
    future.completeExceptionally(error);
   } else if (sumByRegion.isEmpty()) {
    future.completeExceptionally(new NoSuchElementException());
   } else {
    findMedian(future, table, ci, ReflectionUtils.newInstance(scan.getClass(), scan),
     sumByRegion);
   }
  });
  return future;
 }
}
origin: apache/hbase

@Test
public void testMax() throws InterruptedException, ExecutionException {
 assertEquals(COUNT - 1, AsyncAggregationClient
   .max(TABLE, new LongColumnInterpreter(), new Scan().addColumn(CF, CQ)).get().longValue());
}
origin: apache/hbase

  .<AggregateService, AggregateResponse> coprocessorService(AggregateService::newStub,
   (stub, controller, rpcCallback) -> stub.getMedian(controller, req, rpcCallback), callback)
  .fromRow(nullToEmpty(scan.getStartRow()), scan.includeStartRow())
  .toRow(nullToEmpty(scan.getStopRow()), scan.includeStopRow()).execute();
return future;
origin: apache/hbase

@Test
public void testMedian() throws InterruptedException, ExecutionException {
 long halfSum = COUNT * (COUNT - 1) / 4;
 long median = 0L;
 long sum = 0L;
 for (int i = 0; i < COUNT; i++) {
  sum += i;
  if (sum > halfSum) {
   median = i - 1;
   break;
  }
 }
 assertEquals(median,
  AsyncAggregationClient
    .median(TABLE, new LongColumnInterpreter(), new Scan().addColumn(CF, CQ)).get()
    .longValue());
}
origin: apache/hbase

@Test
public void testStd() throws InterruptedException, ExecutionException {
 double avgSq =
   LongStream.range(0, COUNT).map(l -> l * l).reduce((l1, l2) -> l1 + l2).getAsLong()
     / (double) COUNT;
 double avg = (COUNT - 1) / 2.0;
 double std = Math.sqrt(avgSq - avg * avg);
 assertEquals(std, AsyncAggregationClient
   .std(TABLE, new LongColumnInterpreter(), new Scan().addColumn(CF, CQ)).get().doubleValue(),
  DELTA);
}
origin: apache/hbase

@Test
public void testRowCount() throws InterruptedException, ExecutionException {
 assertEquals(COUNT,
  AsyncAggregationClient
    .rowCount(TABLE, new LongColumnInterpreter(), new Scan().addColumn(CF, CQ)).get()
    .longValue());
}
origin: apache/hbase

@Test
public void testSum() throws InterruptedException, ExecutionException {
 assertEquals(COUNT * (COUNT - 1) / 2, AsyncAggregationClient
   .sum(TABLE, new LongColumnInterpreter(), new Scan().addColumn(CF, CQ)).get().longValue());
}
origin: apache/hbase

@Test
public void testMin() throws InterruptedException, ExecutionException {
 assertEquals(0, AsyncAggregationClient
   .min(TABLE, new LongColumnInterpreter(), new Scan().addColumn(CF, CQ)).get().longValue());
}
origin: apache/hbase

  .<AggregateService, AggregateResponse> coprocessorService(AggregateService::newStub,
   (stub, controller, rpcCallback) -> stub.getStd(controller, req, rpcCallback), callback)
  .fromRow(nullToEmpty(scan.getStartRow()), scan.includeStartRow())
  .toRow(nullToEmpty(scan.getStopRow()), scan.includeStopRow()).execute();
return future;
origin: apache/hbase

 @Test
 public void testMedianWithWeight() throws InterruptedException, ExecutionException {
  long halfSum =
    LongStream.range(0, COUNT).map(l -> l * l).reduce((l1, l2) -> l1 + l2).getAsLong() / 2;
  long median = 0L;
  long sum = 0L;
  for (int i = 0; i < COUNT; i++) {
   sum += i * i;
   if (sum > halfSum) {
    median = i - 1;
    break;
   }
  }
  assertEquals(median, AsyncAggregationClient
    .median(TABLE, new LongColumnInterpreter(), new Scan().addColumn(CF, CQ).addColumn(CF, CQ2))
    .get().longValue());
 }
}
origin: org.apache.hbase/hbase-endpoint

@Test
public void testStd() throws InterruptedException, ExecutionException {
 double avgSq =
   LongStream.range(0, COUNT).map(l -> l * l).reduce((l1, l2) -> l1 + l2).getAsLong()
     / (double) COUNT;
 double avg = (COUNT - 1) / 2.0;
 double std = Math.sqrt(avgSq - avg * avg);
 assertEquals(std, AsyncAggregationClient
   .std(TABLE, new LongColumnInterpreter(), new Scan().addColumn(CF, CQ)).get().doubleValue(),
  DELTA);
}
origin: org.apache.hbase/hbase-endpoint

@Test
public void testRowCount() throws InterruptedException, ExecutionException {
 assertEquals(COUNT,
  AsyncAggregationClient
    .rowCount(TABLE, new LongColumnInterpreter(), new Scan().addColumn(CF, CQ)).get()
    .longValue());
}
origin: org.apache.hbase/hbase-endpoint

@Test
public void testSum() throws InterruptedException, ExecutionException {
 assertEquals(COUNT * (COUNT - 1) / 2, AsyncAggregationClient
   .sum(TABLE, new LongColumnInterpreter(), new Scan().addColumn(CF, CQ)).get().longValue());
}
origin: org.apache.hbase/hbase-endpoint

@Test
public void testMin() throws InterruptedException, ExecutionException {
 assertEquals(0, AsyncAggregationClient
   .min(TABLE, new LongColumnInterpreter(), new Scan().addColumn(CF, CQ)).get().longValue());
}
origin: apache/hbase

public static <R, S, P extends Message, Q extends Message, T extends Message>
  CompletableFuture<Long> rowCount(AsyncTable<?> table, ColumnInterpreter<R, S, P, Q, T> ci,
    Scan scan) {
 CompletableFuture<Long> future = new CompletableFuture<>();
 AggregateRequest req;
 try {
  req = validateArgAndGetPB(scan, ci, true);
 } catch (IOException e) {
  future.completeExceptionally(e);
  return future;
 }
 AbstractAggregationCallback<Long> callback = new AbstractAggregationCallback<Long>(future) {
  private long count;
  @Override
  protected void aggregate(RegionInfo region, AggregateResponse resp) throws IOException {
   count += resp.getFirstPart(0).asReadOnlyByteBuffer().getLong();
  }
  @Override
  protected Long getFinalResult() {
   return count;
  }
 };
 table
   .<AggregateService, AggregateResponse> coprocessorService(AggregateService::newStub,
    (stub, controller, rpcCallback) -> stub.getRowNum(controller, req, rpcCallback), callback)
   .fromRow(nullToEmpty(scan.getStartRow()), scan.includeStartRow())
   .toRow(nullToEmpty(scan.getStopRow()), scan.includeStopRow()).execute();
 return future;
}
origin: org.apache.hbase/hbase-endpoint

 public static <R, S, P extends Message, Q extends Message, T extends Message>
     CompletableFuture<R> median(AsyncTable<AdvancedScanResultConsumer> table,
     ColumnInterpreter<R, S, P, Q, T> ci, Scan scan) {
  CompletableFuture<R> future = new CompletableFuture<>();
  sumByRegion(table, ci, scan).whenComplete((sumByRegion, error) -> {
   if (error != null) {
    future.completeExceptionally(error);
   } else if (sumByRegion.isEmpty()) {
    future.completeExceptionally(new NoSuchElementException());
   } else {
    findMedian(future, table, ci, ReflectionUtils.newInstance(scan.getClass(), scan),
     sumByRegion);
   }
  });
  return future;
 }
}
origin: com.aliyun.hbase/alihbase-endpoint

@Test
public void testMedian() throws InterruptedException, ExecutionException {
 long halfSum = COUNT * (COUNT - 1) / 4;
 long median = 0L;
 long sum = 0L;
 for (int i = 0; i < COUNT; i++) {
  sum += i;
  if (sum > halfSum) {
   median = i - 1;
   break;
  }
 }
 assertEquals(median,
  AsyncAggregationClient
    .median(TABLE, new LongColumnInterpreter(), new Scan().addColumn(CF, CQ)).get()
    .longValue());
}
origin: org.apache.hbase/hbase-endpoint

@Test
public void testAvg() throws InterruptedException, ExecutionException {
 assertEquals((COUNT - 1) / 2.0, AsyncAggregationClient
   .avg(TABLE, new LongColumnInterpreter(), new Scan().addColumn(CF, CQ)).get().doubleValue(),
  DELTA);
}
origin: com.aliyun.hbase/alihbase-endpoint

@Test
public void testStd() throws InterruptedException, ExecutionException {
 double avgSq =
   LongStream.range(0, COUNT).map(l -> l * l).reduce((l1, l2) -> l1 + l2).getAsLong()
     / (double) COUNT;
 double avg = (COUNT - 1) / 2.0;
 double std = Math.sqrt(avgSq - avg * avg);
 assertEquals(std, AsyncAggregationClient
   .std(TABLE, new LongColumnInterpreter(), new Scan().addColumn(CF, CQ)).get().doubleValue(),
  DELTA);
}
org.apache.hadoop.hbase.client.coprocessorAsyncAggregationClient

Javadoc

This client class is for invoking the aggregate functions deployed on the Region Server side via the AggregateService. This class will implement the supporting functionality for summing/processing the individual results obtained from the AggregateService for each region.

Most used methods

  • avg
  • findMedian
  • max
  • median
  • min
  • nullToEmpty
  • rowCount
  • std
  • sum
  • sumByRegion

Popular in Java

  • Reading from database using SQL prepared statement
  • addToBackStack (FragmentTransaction)
  • getContentResolver (Context)
  • notifyDataSetChanged (ArrayAdapter)
  • Thread (java.lang)
    A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • JButton (javax.swing)
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now