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

How to use
HiveSerDeWrapper
in
org.apache.gobblin.hive

Best Java code snippets using org.apache.gobblin.hive.HiveSerDeWrapper (Showing top 16 results out of 315)

origin: apache/incubator-gobblin

/**
 * Add an Avro {@link Schema} to the given {@link HiveRegistrationUnit}.
 *
 *  <p>
 *    If {@link #USE_SCHEMA_FILE} is true, the schema will be added via {@link #SCHEMA_URL} pointing to
 *    the schema file named {@link #SCHEMA_FILE_NAME}.
 *  </p>
 *
 *  <p>
 *    If {@link #USE_SCHEMA_FILE} is false, the schema will be obtained by {@link #getDirectorySchema(Path)}.
 *    If the length of the schema is less than {@link #SCHEMA_LITERAL_LENGTH_LIMIT}, it will be added via
 *    {@link #SCHEMA_LITERAL}. Otherwise, the schema will be written to {@link #SCHEMA_FILE_NAME} and added
 *    via {@link #SCHEMA_URL}.
 *  </p>
 */
@Override
public void addSerDeProperties(Path path, HiveRegistrationUnit hiveUnit) throws IOException {
 Preconditions.checkArgument(this.fs.getFileStatus(path).isDirectory(), path + " is not a directory.");
 Schema schema;
 try (Timer.Context context = metricContext.timer(HIVE_SPEC_SCHEMA_READING_TIMER).time()) {
  schema = getDirectorySchema(path);
 }
 if (schema == null) {
  return;
 }
 hiveUnit.setSerDeType(this.serDeWrapper.getSerDe().getClass().getName());
 hiveUnit.setInputFormat(this.serDeWrapper.getInputFormatClassName());
 hiveUnit.setOutputFormat(this.serDeWrapper.getOutputFormatClassName());
 addSchemaProperties(path, hiveUnit, schema);
}
origin: apache/incubator-gobblin

/**
 * Get an instance of {@link HiveSerDeWrapper}.
 *
 * @param serDeType The SerDe type. If serDeType is one of the available {@link HiveSerDeWrapper.BuiltInHiveSerDe},
 * the other three parameters are not used. Otherwise, serDeType should be the class name of a {@link SerDe},
 * and the other three parameters must be present.
 */
public static HiveSerDeWrapper get(String serDeType, Optional<String> inputFormatClassName,
  Optional<String> outputFormatClassName) {
 Optional<BuiltInHiveSerDe> hiveSerDe = Enums.getIfPresent(BuiltInHiveSerDe.class, serDeType.toUpperCase());
 if (hiveSerDe.isPresent()) {
  return new HiveSerDeWrapper(hiveSerDe.get());
 }
 Preconditions.checkArgument(inputFormatClassName.isPresent(),
   "Missing input format class name for SerDe " + serDeType);
 Preconditions.checkArgument(outputFormatClassName.isPresent(),
   "Missing output format class name for SerDe " + serDeType);
 return new HiveSerDeWrapper(serDeType, inputFormatClassName.get(), outputFormatClassName.get());
}
origin: apache/incubator-gobblin

/**
 * Get an instance of {@link HiveSerDeWrapper}.
 *
 * @param serDeType The SerDe type. This should be one of the available {@link HiveSerDeWrapper.BuiltInHiveSerDe}s.
 */
public static HiveSerDeWrapper get(String serDeType) {
 return get(serDeType, Optional.<String> absent(), Optional.<String> absent());
}
origin: apache/incubator-gobblin

@Override
public List<WorkUnit> getWorkunits(SourceState state) {
 if (!state.contains(HadoopFileInputSource.FILE_INPUT_FORMAT_CLASS_KEY)) {
  state.setProp(HadoopFileInputSource.FILE_INPUT_FORMAT_CLASS_KEY,
    HiveSerDeWrapper.getDeserializer(state).getInputFormatClassName());
 }
 return super.getWorkunits(state);
}
origin: apache/incubator-gobblin

@SuppressWarnings("deprecation")
@Override
public DataWriter<Writable> build() throws IOException {
 Preconditions.checkNotNull(this.destination);
 Preconditions.checkArgument(!Strings.isNullOrEmpty(this.writerId));
 State properties = this.destination.getProperties();
 if (!properties.contains(WRITER_WRITABLE_CLASS) || !properties.contains(WRITER_OUTPUT_FORMAT_CLASS)) {
  HiveSerDeWrapper serializer = HiveSerDeWrapper.getSerializer(properties);
  properties.setProp(WRITER_WRITABLE_CLASS, serializer.getSerDe().getSerializedClass().getName());
  properties.setProp(WRITER_OUTPUT_FORMAT_CLASS, serializer.getOutputFormatClassName());
 }
 return new HiveWritableHdfsDataWriter(this, properties);
}
origin: apache/incubator-gobblin

@Override
public HiveSerDeConverter init(WorkUnitState state) {
 super.init(state);
 Configuration conf = HadoopUtils.getConfFromState(state);
 try {
  this.serializer = HiveSerDeWrapper.getSerializer(state).getSerDe();
  this.deserializer = HiveSerDeWrapper.getDeserializer(state).getSerDe();
  this.deserializer.initialize(conf, state.getProperties());
  setColumnsIfPossible(state);
  this.serializer.initialize(conf, state.getProperties());
 } catch (IOException e) {
  log.error("Failed to instantiate serializer and deserializer", e);
  throw Throwables.propagate(e);
 } catch (SerDeException e) {
  log.error("Failed to initialize serializer and deserializer", e);
  throw Throwables.propagate(e);
 }
 return this;
}
origin: org.apache.gobblin/gobblin-core

@SuppressWarnings("deprecation")
@Override
public DataWriter<Writable> build() throws IOException {
 Preconditions.checkNotNull(this.destination);
 Preconditions.checkArgument(!Strings.isNullOrEmpty(this.writerId));
 State properties = this.destination.getProperties();
 if (!properties.contains(WRITER_WRITABLE_CLASS) || !properties.contains(WRITER_OUTPUT_FORMAT_CLASS)) {
  HiveSerDeWrapper serializer = HiveSerDeWrapper.getSerializer(properties);
  properties.setProp(WRITER_WRITABLE_CLASS, serializer.getSerDe().getSerializedClass().getName());
  properties.setProp(WRITER_OUTPUT_FORMAT_CLASS, serializer.getOutputFormatClassName());
 }
 return new HiveWritableHdfsDataWriter(this, properties);
}
origin: org.apache.gobblin/gobblin-core

@Override
public HiveSerDeConverter init(WorkUnitState state) {
 super.init(state);
 Configuration conf = HadoopUtils.getConfFromState(state);
 try {
  this.serializer = HiveSerDeWrapper.getSerializer(state).getSerDe();
  this.deserializer = HiveSerDeWrapper.getDeserializer(state).getSerDe();
  this.deserializer.initialize(conf, state.getProperties());
  setColumnsIfPossible(state);
  this.serializer.initialize(conf, state.getProperties());
 } catch (IOException e) {
  log.error("Failed to instantiate serializer and deserializer", e);
  throw Throwables.propagate(e);
 } catch (SerDeException e) {
  log.error("Failed to initialize serializer and deserializer", e);
  throw Throwables.propagate(e);
 }
 return this;
}
origin: org.apache.gobblin/gobblin-core

@Override
public List<WorkUnit> getWorkunits(SourceState state) {
 if (!state.contains(HadoopFileInputSource.FILE_INPUT_FORMAT_CLASS_KEY)) {
  state.setProp(HadoopFileInputSource.FILE_INPUT_FORMAT_CLASS_KEY,
    HiveSerDeWrapper.getDeserializer(state).getInputFormatClassName());
 }
 return super.getWorkunits(state);
}
origin: org.apache.gobblin/gobblin-hive-registration

/**
 * Add an Avro {@link Schema} to the given {@link HiveRegistrationUnit}.
 *
 *  <p>
 *    If {@link #USE_SCHEMA_FILE} is true, the schema will be added via {@link #SCHEMA_URL} pointing to
 *    the schema file named {@link #SCHEMA_FILE_NAME}.
 *  </p>
 *
 *  <p>
 *    If {@link #USE_SCHEMA_FILE} is false, the schema will be obtained by {@link #getDirectorySchema(Path)}.
 *    If the length of the schema is less than {@link #SCHEMA_LITERAL_LENGTH_LIMIT}, it will be added via
 *    {@link #SCHEMA_LITERAL}. Otherwise, the schema will be written to {@link #SCHEMA_FILE_NAME} and added
 *    via {@link #SCHEMA_URL}.
 *  </p>
 */
@Override
public void addSerDeProperties(Path path, HiveRegistrationUnit hiveUnit) throws IOException {
 Preconditions.checkArgument(this.fs.getFileStatus(path).isDirectory(), path + " is not a directory.");
 Schema schema;
 try (Timer.Context context = metricContext.timer(HIVE_SPEC_SCHEMA_READING_TIMER).time()) {
  schema = getDirectorySchema(path);
 }
 if (schema == null) {
  return;
 }
 hiveUnit.setSerDeType(this.serDeWrapper.getSerDe().getClass().getName());
 hiveUnit.setInputFormat(this.serDeWrapper.getInputFormatClassName());
 hiveUnit.setOutputFormat(this.serDeWrapper.getOutputFormatClassName());
 addSchemaProperties(path, hiveUnit, schema);
}
origin: apache/incubator-gobblin

/**
 * Get an instance of {@link HiveSerDeWrapper} from a {@link State}.
 *
 * @param state The state should contain property {@link #SERDE_SERIALIZER_TYPE}, and optionally contain properties
 * {@link #SERDE_SERIALIZER_INPUT_FORMAT_TYPE}, {@link #SERDE_SERIALIZER_OUTPUT_FORMAT_TYPE} and
 */
public static HiveSerDeWrapper getSerializer(State state) {
 Preconditions.checkArgument(state.contains(SERDE_SERIALIZER_TYPE),
   "Missing required property " + SERDE_SERIALIZER_TYPE);
 return get(state.getProp(SERDE_SERIALIZER_TYPE),
   Optional.fromNullable(state.getProp(SERDE_SERIALIZER_INPUT_FORMAT_TYPE)),
   Optional.fromNullable(state.getProp(SERDE_SERIALIZER_OUTPUT_FORMAT_TYPE)));
}
origin: org.apache.gobblin/gobblin-hive-registration

/**
 * Get an instance of {@link HiveSerDeWrapper}.
 *
 * @param serDeType The SerDe type. If serDeType is one of the available {@link HiveSerDeWrapper.BuiltInHiveSerDe},
 * the other three parameters are not used. Otherwise, serDeType should be the class name of a {@link SerDe},
 * and the other three parameters must be present.
 */
public static HiveSerDeWrapper get(String serDeType, Optional<String> inputFormatClassName,
  Optional<String> outputFormatClassName) {
 Optional<BuiltInHiveSerDe> hiveSerDe = Enums.getIfPresent(BuiltInHiveSerDe.class, serDeType.toUpperCase());
 if (hiveSerDe.isPresent()) {
  return new HiveSerDeWrapper(hiveSerDe.get());
 }
 Preconditions.checkArgument(inputFormatClassName.isPresent(),
   "Missing input format class name for SerDe " + serDeType);
 Preconditions.checkArgument(outputFormatClassName.isPresent(),
   "Missing output format class name for SerDe " + serDeType);
 return new HiveSerDeWrapper(serDeType, inputFormatClassName.get(), outputFormatClassName.get());
}
origin: apache/incubator-gobblin

 /**
  * Get an instance of {@link HiveSerDeWrapper} from a {@link State}.
  *
  * @param state The state should contain property {@link #SERDE_DESERIALIZER_TYPE}, and optionally contain properties
  * {@link #SERDE_DESERIALIZER_INPUT_FORMAT_TYPE}, {@link #SERDE_DESERIALIZER_OUTPUT_FORMAT_TYPE} and
  */
 public static HiveSerDeWrapper getDeserializer(State state) {
  Preconditions.checkArgument(state.contains(SERDE_DESERIALIZER_TYPE),
    "Missing required property " + SERDE_DESERIALIZER_TYPE);
  return get(state.getProp(SERDE_DESERIALIZER_TYPE),
    Optional.fromNullable(state.getProp(SERDE_DESERIALIZER_INPUT_FORMAT_TYPE)),
    Optional.fromNullable(state.getProp(SERDE_DESERIALIZER_OUTPUT_FORMAT_TYPE)));
 }
}
origin: org.apache.gobblin/gobblin-hive-registration

/**
 * Get an instance of {@link HiveSerDeWrapper}.
 *
 * @param serDeType The SerDe type. This should be one of the available {@link HiveSerDeWrapper.BuiltInHiveSerDe}s.
 */
public static HiveSerDeWrapper get(String serDeType) {
 return get(serDeType, Optional.<String> absent(), Optional.<String> absent());
}
origin: org.apache.gobblin/gobblin-hive-registration

/**
 * Get an instance of {@link HiveSerDeWrapper} from a {@link State}.
 *
 * @param state The state should contain property {@link #SERDE_SERIALIZER_TYPE}, and optionally contain properties
 * {@link #SERDE_SERIALIZER_INPUT_FORMAT_TYPE}, {@link #SERDE_SERIALIZER_OUTPUT_FORMAT_TYPE} and
 */
public static HiveSerDeWrapper getSerializer(State state) {
 Preconditions.checkArgument(state.contains(SERDE_SERIALIZER_TYPE),
   "Missing required property " + SERDE_SERIALIZER_TYPE);
 return get(state.getProp(SERDE_SERIALIZER_TYPE),
   Optional.fromNullable(state.getProp(SERDE_SERIALIZER_INPUT_FORMAT_TYPE)),
   Optional.fromNullable(state.getProp(SERDE_SERIALIZER_OUTPUT_FORMAT_TYPE)));
}
origin: org.apache.gobblin/gobblin-hive-registration

 /**
  * Get an instance of {@link HiveSerDeWrapper} from a {@link State}.
  *
  * @param state The state should contain property {@link #SERDE_DESERIALIZER_TYPE}, and optionally contain properties
  * {@link #SERDE_DESERIALIZER_INPUT_FORMAT_TYPE}, {@link #SERDE_DESERIALIZER_OUTPUT_FORMAT_TYPE} and
  */
 public static HiveSerDeWrapper getDeserializer(State state) {
  Preconditions.checkArgument(state.contains(SERDE_DESERIALIZER_TYPE),
    "Missing required property " + SERDE_DESERIALIZER_TYPE);
  return get(state.getProp(SERDE_DESERIALIZER_TYPE),
    Optional.fromNullable(state.getProp(SERDE_DESERIALIZER_INPUT_FORMAT_TYPE)),
    Optional.fromNullable(state.getProp(SERDE_DESERIALIZER_OUTPUT_FORMAT_TYPE)));
 }
}
org.apache.gobblin.hiveHiveSerDeWrapper

Javadoc

A wrapper around SerDe that bundles input format, output format and file extension with a SerDe, and provides additional functionalities.

Most used methods

  • getInputFormatClassName
    Get the input format class name associated with this HiveSerDeWrapper.
  • getOutputFormatClassName
    Get the output format class name associated with this HiveSerDeWrapper.
  • getSerDe
    Get the SerDe instance associated with this HiveSerDeWrapper. This method performs lazy initializati
  • <init>
  • get
    Get an instance of HiveSerDeWrapper.
  • getDeserializer
    Get an instance of HiveSerDeWrapper from a State.
  • getSerializer
    Get an instance of HiveSerDeWrapper from a State.

Popular in Java

  • Updating database using SQL prepared statement
  • scheduleAtFixedRate (ScheduledExecutorService)
  • startActivity (Activity)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • ImageIO (javax.imageio)
  • Reference (javax.naming)
  • Logger (org.apache.log4j)
    This is the central class in the log4j package. Most logging operations, except configuration, are d
  • 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