Tabnine Logo
Combine$CombineFn.createAccumulator
Code IndexAdd Tabnine to your IDE (free)

How to use
createAccumulator
method
in
org.apache.beam.sdk.transforms.Combine$CombineFn

Best Java code snippets using org.apache.beam.sdk.transforms.Combine$CombineFn.createAccumulator (Showing top 20 results out of 315)

origin: org.apache.beam/beam-sdks-java-core

@Override
public Object[] createAccumulator() {
 Object[] accumsArray = new Object[combineFnCount];
 for (int i = 0; i < combineFnCount; ++i) {
  accumsArray[i] = combineFns.get(i).createAccumulator();
 }
 return accumsArray;
}
origin: org.apache.beam/beam-sdks-java-core

private static <InputT, AccumT, OutputT> List<AccumT> combineInputs(
  CombineFn<InputT, AccumT, OutputT> fn, Iterable<? extends Iterable<InputT>> shards) {
 List<AccumT> accumulators = new ArrayList<>();
 int maybeCompact = 0;
 for (Iterable<InputT> shard : shards) {
  AccumT accumulator = fn.createAccumulator();
  for (InputT elem : shard) {
   accumulator = fn.addInput(accumulator, elem);
  }
  if (maybeCompact++ % 2 == 0) {
   accumulator = fn.compact(accumulator);
  }
  accumulators.add(accumulator);
 }
 return accumulators;
}
origin: org.apache.beam/beam-runners-direct-java

@ProcessElement
public void processElement(ProcessContext context, BoundedWindow window) {
 WindowedStructuralKey<K> key =
   WindowedStructuralKey.create(keyCoder, context.element().getKey(), window);
 AccumT accumulator = accumulators.get(key);
 Instant assignedTs = timestampCombiner.assign(window, context.timestamp());
 if (accumulator == null) {
  accumulator = combineFn.createAccumulator();
  accumulators.put(key, accumulator);
  timestamps.put(key, assignedTs);
 }
 accumulators.put(key, combineFn.addInput(accumulator, context.element().getValue()));
 timestamps.put(key, timestampCombiner.combine(assignedTs, timestamps.get(key)));
}
origin: org.apache.beam/beam-runners-flink_2.10

@Override
public void add(InputT value) {
 try {
  org.apache.flink.api.common.state.ValueState<AccumT> state =
    flinkStateBackend.getPartitionedState(
      namespace.stringKey(),
      StringSerializer.INSTANCE,
      flinkStateDescriptor);
  AccumT current = state.value();
  if (current == null) {
   current = combineFn.createAccumulator();
  }
  current = combineFn.addInput(current, value);
  state.update(current);
 } catch (Exception e) {
  throw new RuntimeException("Error adding to state." , e);
 }
}
origin: org.apache.beam/beam-runners-flink

@Override
public void add(InputT value) {
 try {
  org.apache.flink.api.common.state.ValueState<AccumT> state =
    flinkStateBackend.getPartitionedState(
      namespace.stringKey(), StringSerializer.INSTANCE, flinkStateDescriptor);
  AccumT current = state.value();
  if (current == null) {
   current = combineFn.createAccumulator();
  }
  current = combineFn.addInput(current, value);
  state.update(current);
 } catch (Exception e) {
  throw new RuntimeException("Error adding to state.", e);
 }
}
origin: org.apache.beam/beam-runners-flink

@Override
public OutputT read() {
 try {
  org.apache.flink.api.common.state.ValueState<AccumT> state =
    flinkStateBackend.getPartitionedState(
      namespace.stringKey(), StringSerializer.INSTANCE, flinkStateDescriptor);
  AccumT accum = state.value();
  if (accum != null) {
   return combineFn.extractOutput(accum);
  } else {
   return combineFn.extractOutput(combineFn.createAccumulator());
  }
 } catch (Exception e) {
  throw new RuntimeException("Error reading state.", e);
 }
}
origin: org.apache.beam/beam-runners-flink_2.11

@Override
public void add(InputT value) {
 try {
  org.apache.flink.api.common.state.ValueState<AccumT> state =
    flinkStateBackend.getPartitionedState(
      namespace.stringKey(), StringSerializer.INSTANCE, flinkStateDescriptor);
  AccumT current = state.value();
  if (current == null) {
   current = combineFn.createAccumulator();
  }
  current = combineFn.addInput(current, value);
  state.update(current);
 } catch (Exception e) {
  throw new RuntimeException("Error adding to state.", e);
 }
}
origin: org.apache.beam/beam-sdks-java-core

private static <InputT, AccumT, OutputT> void checkCombineFnShardsIncrementalMerging(
  CombineFn<InputT, AccumT, OutputT> fn,
  List<? extends Iterable<InputT>> shards,
  Matcher<? super OutputT> matcher) {
 AccumT accumulator = shards.isEmpty() ? fn.createAccumulator() : null;
 for (AccumT inputAccum : combineInputs(fn, shards)) {
  if (accumulator == null) {
   accumulator = inputAccum;
  } else {
   accumulator = fn.mergeAccumulators(Arrays.asList(accumulator, inputAccum));
  }
  fn.extractOutput(accumulator); // Extract output to simulate multiple firings
 }
 assertThat(fn.extractOutput(accumulator), matcher);
}
origin: org.apache.beam/beam-sdks-java-core

/**
 * Applies this {@code CombineFn} to a collection of input values to produce a combined output
 * value.
 *
 * <p>Useful when using a {@code CombineFn} separately from a {@code Combine} transform. Does
 * not invoke the {@link #mergeAccumulators} operation.
 */
public OutputT apply(Iterable<? extends InputT> inputs) {
 AccumT accum = createAccumulator();
 for (InputT input : inputs) {
  accum = addInput(accum, input);
 }
 return extractOutput(accum);
}
origin: org.apache.beam/beam-runners-flink_2.11

@Override
public OutputT read() {
 try {
  org.apache.flink.api.common.state.ValueState<AccumT> state =
    flinkStateBackend.getPartitionedState(
      namespace.stringKey(), StringSerializer.INSTANCE, flinkStateDescriptor);
  AccumT accum = state.value();
  if (accum != null) {
   return combineFn.extractOutput(accum);
  } else {
   return combineFn.extractOutput(combineFn.createAccumulator());
  }
 } catch (Exception e) {
  throw new RuntimeException("Error reading state.", e);
 }
}
origin: org.apache.beam/beam-sdks-java-core

@Override
public AccumT createAccumulator() {
 return fn.createAccumulator();
}
origin: org.apache.beam/beam-sdks-java-core

@Override
public AccumT createAccumulator(Context c) {
 return combineFn.createAccumulator();
}
origin: org.apache.beam/beam-sdks-java-extensions-sql

@Override
public Object createAccumulator() {
 return combineFn.createAccumulator();
}
origin: org.apache.beam/beam-sdks-java-core

@Override
public AccumT createAccumulator() {
 return fn.createAccumulator();
}
origin: org.apache.beam/beam-runners-core-java

@Override
public OutputT read() {
 return combineFn.extractOutput(
   combineFn.mergeAccumulators(Arrays.asList(combineFn.createAccumulator(), accum)));
}
origin: org.apache.beam/beam-runners-core-java

@Override
public void clear() {
 // Even though we're clearing we can't remove this from the in-memory state map, since
 // other users may already have a handle on this CombiningValue.
 accum = combineFn.createAccumulator();
 isCleared = true;
}
origin: org.apache.beam/beam-sdks-java-core

/**
 * {@inheritDoc}
 *
 * <p>By default returns the extract output of an empty accumulator.
 */
@Override
public OutputT defaultValue() {
 return extractOutput(createAccumulator());
}
origin: org.apache.beam/beam-runners-core-java

@Override
public AccumT createAccumulator(
  PipelineOptions options,
  SideInputReader sideInputReader,
  Collection<? extends BoundedWindow> windows) {
 return combineFn.createAccumulator();
}
origin: org.apache.beam/beam-sdks-java-core

private static <InputT, AccumT, OutputT> void checkCombineFnShardsWithEmptyAccumulators(
  CombineFn<InputT, AccumT, OutputT> fn,
  Iterable<? extends Iterable<InputT>> shards,
  Matcher<? super OutputT> matcher) {
 List<AccumT> accumulators = combineInputs(fn, shards);
 accumulators.add(0, fn.createAccumulator());
 accumulators.add(fn.createAccumulator());
 AccumT merged = fn.mergeAccumulators(accumulators);
 assertThat(fn.extractOutput(merged), matcher);
}
origin: org.apache.beam/beam-runners-core-java

public InMemoryCombiningState(
  CombineFn<InputT, AccumT, OutputT> combineFn, Coder<AccumT> accumCoder) {
 this.combineFn = combineFn;
 accum = combineFn.createAccumulator();
 this.accumCoder = accumCoder;
}
org.apache.beam.sdk.transformsCombine$CombineFncreateAccumulator

Javadoc

Returns a new, mutable accumulator value, representing the accumulation of zero input values.

Popular methods of Combine$CombineFn

  • getAccumulatorCoder
  • addInput
    Adds the given input value to the given accumulator, returning the new accumulator value.For efficie
  • extractOutput
    Returns the output value that is the result of combining all the input values represented by the giv
  • mergeAccumulators
    Returns an accumulator representing the accumulation of all the input values accumulated in the merg
  • compact
    Returns an accumulator that represents the same logical value as the input accumulator, but may have
  • getOutputType
    Returns a TypeDescriptor capturing what is known statically about the output type of this CombineFn
  • apply
    Applies this CombineFn to a collection of input values to produce a combined output value.Useful whe
  • defaultValue
    By default returns the extract output of an empty accumulator.
  • getDefaultOutputCoder
  • getIncompatibleGlobalWindowErrorMessage
  • populateDisplayData
  • populateDisplayData

Popular in Java

  • Reactive rest calls using spring rest template
  • scheduleAtFixedRate (Timer)
  • startActivity (Activity)
  • setRequestProperty (URLConnection)
  • Color (java.awt)
    The Color class is used to encapsulate colors in the default sRGB color space or colors in arbitrary
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • Vector (java.util)
    Vector is an implementation of List, backed by an array and synchronized. All optional operations in
  • JLabel (javax.swing)
  • Get (org.apache.hadoop.hbase.client)
    Used to perform Get operations on a single row. To get everything for a row, instantiate a Get objec
  • Best IntelliJ plugins
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