Tabnine Logo
AvroIO.read
Code IndexAdd Tabnine to your IDE (free)

How to use
read
method
in
org.apache.beam.sdk.io.AvroIO

Best Java code snippets using org.apache.beam.sdk.io.AvroIO.read (Showing top 11 results out of 315)

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

@Test
@Category(NeedsRunner.class)
public void testWriteThenReadGeneratedClassWithClass() throws Throwable {
 testWriteThenReadGeneratedClass(
   AvroIO.write(AvroGeneratedUser.class), AvroIO.read(AvroGeneratedUser.class));
}
origin: org.apache.beam/beam-sdks-java-core

PAssert.that(
    readPipeline.apply(
      "Read", AvroIO.read(GenericClass.class).from(outputFile.getAbsolutePath())))
  .containsInAnyOrder(values);
PAssert.that(
    readPipeline.apply(
      "Read withHintMatchesManyFiles",
      AvroIO.read(GenericClass.class)
        .from(outputFile.getAbsolutePath())
        .withHintMatchesManyFiles()))
origin: org.apache.beam/beam-sdks-java-core

@Test
public void testReadDisplayData() {
 AvroIO.Read<String> read = AvroIO.read(String.class).from("/foo.*");
 DisplayData displayData = DisplayData.from(read);
 assertThat(displayData, hasDisplayItem("filePattern", "/foo.*"));
}
origin: org.apache.beam/beam-sdks-java-core

readPipeline.apply(
  "Read",
  AvroIO.read(GenericClass.class)
    .from(tmpFolder.getRoot().getAbsolutePath() + "/first*")
    .watchForNewFiles(
origin: GoogleCloudPlatform/DataflowTemplates

public static PipelineResult run(Options options) {
 Pipeline pipeline = Pipeline.create(options);
 BigtableIO.Write write =
   BigtableIO.write()
     .withProjectId(options.getBigtableProjectId())
     .withInstanceId(options.getBigtableInstanceId())
     .withTableId(options.getBigtableTableId());
 pipeline
   .apply("Read from Avro", AvroIO.read(BigtableRow.class).from(options.getInputFilePattern()))
   .apply("Transform to Bigtable", MapElements.via(new AvroToBigtableFn()))
   .apply("Write to Bigtable", write);
 return pipeline.run();
}
origin: org.apache.beam/beam-sdks-java-core

@Test
public void testAvroIOGetName() {
 assertEquals("AvroIO.Read", AvroIO.read(String.class).from("/tmp/foo*/baz").getName());
 assertEquals("AvroIO.Write", AvroIO.write(String.class).to("/tmp/foo/baz").getName());
}
origin: org.apache.beam/beam-sdks-java-core

@Test
@SuppressWarnings("unchecked")
@Category(NeedsRunner.class)
public void testCompressedWriteAndReadASingleFile() throws Throwable {
 List<GenericClass> values =
   ImmutableList.of(new GenericClass(3, "hi"), new GenericClass(5, "bar"));
 File outputFile = tmpFolder.newFile("output.avro");
 writePipeline
   .apply(Create.of(values))
   .apply(
     AvroIO.write(GenericClass.class)
       .to(outputFile.getAbsolutePath())
       .withoutSharding()
       .withCodec(CodecFactory.deflateCodec(9)));
 writePipeline.run();
 PAssert.that(
     readPipeline.apply(AvroIO.read(GenericClass.class).from(outputFile.getAbsolutePath())))
   .containsInAnyOrder(values);
 readPipeline.run();
 try (DataFileStream dataFileStream =
   new DataFileStream(new FileInputStream(outputFile), new GenericDatumReader())) {
  assertEquals("deflate", dataFileStream.getMetaString("avro.codec"));
 }
}
origin: org.apache.beam/beam-sdks-java-core

@Test
@SuppressWarnings("unchecked")
@Category(NeedsRunner.class)
public void testWriteThenReadASingleFileWithNullCodec() throws Throwable {
 List<GenericClass> values =
   ImmutableList.of(new GenericClass(3, "hi"), new GenericClass(5, "bar"));
 File outputFile = tmpFolder.newFile("output.avro");
 writePipeline
   .apply(Create.of(values))
   .apply(
     AvroIO.write(GenericClass.class)
       .to(outputFile.getAbsolutePath())
       .withoutSharding()
       .withCodec(CodecFactory.nullCodec()));
 writePipeline.run();
 PAssert.that(
     readPipeline.apply(AvroIO.read(GenericClass.class).from(outputFile.getAbsolutePath())))
   .containsInAnyOrder(values);
 readPipeline.run();
 try (DataFileStream dataFileStream =
   new DataFileStream(new FileInputStream(outputFile), new GenericDatumReader())) {
  assertEquals("null", dataFileStream.getMetaString("avro.codec"));
 }
}
origin: org.apache.beam/beam-sdks-java-core

@Test
@Category(NeedsRunner.class)
public void testWriteThenReadJavaClass() throws Throwable {
 List<GenericClass> values =
   ImmutableList.of(new GenericClass(3, "hi"), new GenericClass(5, "bar"));
 File outputFile = tmpFolder.newFile("output.avro");
 writePipeline
   .apply(Create.of(values))
   .apply(
     AvroIO.write(GenericClass.class)
       .to(writePipeline.newProvider(outputFile.getAbsolutePath()))
       .withoutSharding());
 writePipeline.run();
 PAssert.that(
     readPipeline.apply(
       "Read",
       AvroIO.read(GenericClass.class)
         .from(readPipeline.newProvider(outputFile.getAbsolutePath()))))
   .containsInAnyOrder(values);
 readPipeline.run();
}
origin: org.apache.beam/beam-sdks-java-core

.apply(
  "Read",
  AvroIO.read(GenericClass.class)
    .from(readPipeline.newProvider(outputFile.getAbsolutePath())))
.apply(
origin: org.apache.beam/beam-sdks-java-core

/**
 * Tests that {@code AvroIO} can read an upgraded version of an old class, as long as the schema
 * resolution process succeeds. This test covers the case when a new, {@code @Nullable} field has
 * been added.
 *
 * <p>For more information, see http://avro.apache.org/docs/1.7.7/spec.html#Schema+Resolution
 */
@Test
@Category(NeedsRunner.class)
public void testWriteThenReadSchemaUpgrade() throws Throwable {
 List<GenericClass> values =
   ImmutableList.of(new GenericClass(3, "hi"), new GenericClass(5, "bar"));
 File outputFile = tmpFolder.newFile("output.avro");
 writePipeline
   .apply(Create.of(values))
   .apply(AvroIO.write(GenericClass.class).to(outputFile.getAbsolutePath()).withoutSharding());
 writePipeline.run();
 List<GenericClassV2> expected =
   ImmutableList.of(new GenericClassV2(3, "hi", null), new GenericClassV2(5, "bar", null));
 PAssert.that(
     readPipeline.apply(
       AvroIO.read(GenericClassV2.class).from(outputFile.getAbsolutePath())))
   .containsInAnyOrder(expected);
 readPipeline.run();
}
org.apache.beam.sdk.ioAvroIOread

Javadoc

Reads records of the given type from an Avro file (or multiple Avro files matching a pattern).

The schema must be specified using one of the withSchema functions.

Popular methods of AvroIO

  • readGenericRecords
    Reads Avro file(s) containing records of the specified schema.
  • writeGenericRecords
    Writes Avro records of the specified schema.
  • constantDestinations
    Returns a DynamicAvroDestinations that always returns the same FilenamePolicy, schema, metadata, and
  • parseAllGenericRecords
    Like #parseGenericRecords(SerializableFunction), but reads each filepattern in the input PCollection
  • readAll
    Like #read, but reads each filepattern in the input PCollection.
  • write
    Writes a PCollection to an Avro file (or multiple Avro files matching a sharding pattern).
  • writeCustomTypeToGenericRecords
    Similar to #writeCustomType(), but specialized for the case where the output type is GenericRecord.
  • defaultWriteBuilder
  • parseGenericRecords
    Reads Avro file(s) containing records of an unspecified schema and converting each record to a custo
  • readAllGenericRecords
    Like #readGenericRecords(Schema), but reads each filepattern in the input PCollection.
  • sink
    A Sink for use with FileIO#write and FileIO#writeDynamic, writing elements of the given generated cl
  • sinkViaGenericRecords
    A Sink for use with FileIO#write and FileIO#writeDynamic, writing elements by converting each one to
  • sink,
  • sinkViaGenericRecords,
  • writeCustomType

Popular in Java

  • Start an intent from android
  • scheduleAtFixedRate (Timer)
  • setScale (BigDecimal)
  • putExtra (Intent)
  • VirtualMachine (com.sun.tools.attach)
    A Java virtual machine. A VirtualMachine represents a Java virtual machine to which this Java vir
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.> This module, both source code and documentation, is in t
  • Top plugins for Android Studio
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