Package sizzle.aggregators

Examples of sizzle.aggregators.Table


  /** {@inheritDoc} */
  @Override
  protected void reduce(final EmitKey key, final Iterable<EmitValue> values, final Context context) throws IOException, InterruptedException {
    // get the table named by the emit key
    final Table t = this.tables.get(key.getName());
    // tell it we are not combining
    t.setCombining(false);

    // Counter counter = context.getCounter("Values Emitted",
    // key.toString());
    // LOG.fatal("counter for "+ counter.getDisplayName() + " " +
    // key.toString() + " " + Long.toString(counter.getValue()));

    // initialize the table
    t.start(key);
    // set the reducer context
    t.setContext(context);

    // for each of the values
    for (final EmitValue value : values)
      try {
        // aggregate it
        t.aggregate(value.getData(), value.getMetadata());
      } catch (final FinishedException e) {
        // we are done
        return;
      } catch (final IOException e) {
        // won't be robust to IOException
        throw e;
      } catch (final InterruptedException e) {
        // won't be robust to InterruptedExceptions
        throw e;
      } catch (final RuntimeException e) {
        if (this.robust)
          SizzleReducer.LOG.error(e.getClass().getName() + " caught", e);
        else
          throw e;
      } catch (final Exception e) {
        if (this.robust)
          SizzleReducer.LOG.error(e.getClass().getName() + " caught", e);
        else
          throw new RuntimeException(e.getClass().getName() + " caught", e);
      }

    // finish it!
    t.finish();
  }
View Full Code Here


  /** {@inheritDoc} */
  @Override
  protected void reduce(final EmitKey key, final Iterable<EmitValue> values, final Context context) throws IOException, InterruptedException {
    // get the table named by the emit key
    final Table t = this.tables.get(key.getName());

    // if we are non-associative, just pass the output through
    // TODO: find away to avoid combiner entirely when non-associative
    if (!t.isAssociative()) {
      for (final EmitValue value : values)
        context.write(key, value);

      return;
    }

    // tell it we will be combining
    t.setCombining(true);

    // Counter counter = context.getCounter("Values Emitted",
    // key.toString());
    // LOG.fatal("counter for \"Values Output\"" + key.toString() + " " +
    // Long.toString(counter.getValue()));

    // initialize the table
    t.start(key);
    // set the reducer context
    t.setContext(context);

    for (final EmitValue value : values)
      try {
        t.aggregate(value.getData(), value.getMetadata());
      } catch (final FinishedException e) {
        // we are done
        return;
      } catch (final IOException e) {
        // won't be robust to IOExceptions
        throw e;
      } catch (final InterruptedException e) {
        // won't be robust to InterruptedExceptions
        throw e;
      } catch (final RuntimeException e) {
        if (this.robust)
          SizzleCombiner.LOG.error(e.getClass().getName() + " caught", e);
        else
          throw e;
      } catch (final Exception e) {
        if (this.robust)
          SizzleCombiner.LOG.error(e.getClass().getName() + " caught", e);
        else
          throw new RuntimeException(e.getClass().getName() + " caught", e);
      }

    // finish it!
    t.finish();
  }
View Full Code Here

TOP

Related Classes of sizzle.aggregators.Table

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.