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

How to use
CopyableGenericRecord
in
org.apache.gobblin.fork

Best Java code snippets using org.apache.gobblin.fork.CopyableGenericRecord (Showing top 4 results out of 315)

origin: apache/incubator-gobblin

 /**
  * Returns a {@link org.apache.gobblin.fork.CopyableGenericRecord} wrapper around the given {@link GenericRecord}.
  * {@inheritDoc}
  * @see org.apache.gobblin.converter.Converter#convertRecord(java.lang.Object, java.lang.Object, org.apache.gobblin.configuration.WorkUnitState)
  */
 @Override
 public Iterable<CopyableGenericRecord> convertRecord(CopyableSchema outputSchema, GenericRecord inputRecord,
   WorkUnitState workUnit) throws DataConversionException {
  return new SingleRecordIterable<>(new CopyableGenericRecord(inputRecord));
 }
}
origin: apache/incubator-gobblin

 @Test
 public void testCopy() throws CopyNotSupportedException {
  GenericRecord record = new GenericData.Record(new Schema.Parser().parse(AVRO_SCHEMA));
  record.put("name", "foo");
  record.put("favorite_number", 68);
  record.put("favorite_colors", Arrays.asList("blue", "black", "red"));
  CopyableGenericRecord copyableGenericRecord = new CopyableGenericRecord(record);
  GenericRecord copy = copyableGenericRecord.copy();
  Assert.assertEquals(record, copy);
  copy.put("name", "bar");
  Assert.assertNotEquals(record, copy);

 }
}
origin: apache/incubator-gobblin

 @Override
 public Iterable<CopyableGenericRecord> convertRecord(CopyableSchema schema, String inputRecord,
   WorkUnitState workUnit)
   throws DataConversionException {

  JsonElement element = GSON.fromJson(inputRecord, JsonElement.class);
  Map<String, Object> fields = GSON.fromJson(element, FIELD_ENTRY_TYPE);
  try {
   Schema avroSchema = schema.copy();
   GenericRecord record = new GenericData.Record(avroSchema);
   for (Map.Entry<String, Object> entry : fields.entrySet()) {
    if (entry.getValue() instanceof Double) {
     // Gson reads the integers in the input Json documents as doubles, so we have
     // to convert doubles to integers here as the Avro schema specifies integers.
     record.put(entry.getKey(), ((Double) entry.getValue()).intValue());
    } else {
     record.put(entry.getKey(), entry.getValue());
    }
   }

   return new SingleRecordIterable<CopyableGenericRecord>(new CopyableGenericRecord(record));
  } catch (CopyNotSupportedException cnse) {
   throw new DataConversionException(cnse);
  }
 }
}
origin: org.apache.gobblin/gobblin-core

 /**
  * Returns a {@link org.apache.gobblin.fork.CopyableGenericRecord} wrapper around the given {@link GenericRecord}.
  * {@inheritDoc}
  * @see org.apache.gobblin.converter.Converter#convertRecord(java.lang.Object, java.lang.Object, org.apache.gobblin.configuration.WorkUnitState)
  */
 @Override
 public Iterable<CopyableGenericRecord> convertRecord(CopyableSchema outputSchema, GenericRecord inputRecord,
   WorkUnitState workUnit) throws DataConversionException {
  return new SingleRecordIterable<>(new CopyableGenericRecord(inputRecord));
 }
}
org.apache.gobblin.forkCopyableGenericRecord

Javadoc

A wrapper class for org.apache.avro.generic.GenericRecordthat is also Copyable.

Most used methods

  • <init>
  • copy

Popular in Java

  • Running tasks concurrently on multiple threads
  • scheduleAtFixedRate (Timer)
  • startActivity (Activity)
  • findViewById (Activity)
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • ServerSocket (java.net)
    This class represents a server-side socket that waits for incoming client connections. A ServerSocke
  • URLConnection (java.net)
    A connection to a URL for reading or writing. For HTTP connections, see HttpURLConnection for docume
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • BoxLayout (javax.swing)
  • CodeWhisperer alternatives
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