title: What is the difference between DoFn.Setup and DoFn.StartBundle?
body: <h2>What is the difference between these two annotations?</h2>
  
  <p><a href="https://beam.apache.org/documentation/sdks/javadoc/2.1.0/org/apache/beam/sdk/transforms/DoFn.Setup.html" rel="noreferrer"><code>DoFn.Setup</code></a> Annotation for the method to use to prepare an instance for processing bundles of elements.</p>
  
  <p>Uses the word "bundle", takes zero arguments.</p>
  
  <p><a href="https://beam.apache.org/documentation/sdks/javadoc/2.1.0/org/apache/beam/sdk/transforms/DoFn.StartBundle.html" rel="noreferrer"><code>DoFn.StartBundle</code></a> Annotation for the method to use to prepare an instance for processing a batch of elements.</p>
  
  <p>Uses the word "batch", takes zero <em>or one</em> arguments (<a href="https://beam.apache.org/documentation/sdks/javadoc/2.1.0/org/apache/beam/sdk/transforms/DoFn.StartBundleContext.html" rel="noreferrer"><code>StartBundleContext</code></a>, a way to access <code>PipelineOptions</code>).</p>
  
  <h2>What I'm trying to do</h2>
  
  <p>I need to initialize a library within the DoFn instance, then use that library for every element in the "batch" or "bundle". I wouldn't normally split hairs with these two words, but in a pipeline, there might be some difference?</p>