Class JsonHadoopBridge

java.lang.Object
net.sansa_stack.hadoop.util.JsonHadoopBridge

public class JsonHadoopBridge extends Object
Jackson-based mapper that can read/write java beans from/to a hadoop configuration object (essentially a Map<String, String>). The java bean is first converted to a (possibly nested) json object structure - only strings and objects allowed! Afterwards, the json keys are converted to strings and appended to a given prefix. For example, a java bean with a json serialization of { "foo": {"bar": "baz" }} and a prefix my.hadoop.configuration.prefix leads to the setting: my.hadoop.configuration.prefix.foo.bar = baz
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected org.aksw.commons.path.core.Path<String>
     
    protected com.fasterxml.jackson.databind.JsonNode
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    JsonHadoopBridge(org.aksw.commons.path.core.Path<String> basePath, com.fasterxml.jackson.databind.JsonNode prototype)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    This method takes as argument an object that serves as a prototype: It is converted to json (null values retained) and the obtained (nested) keys are used as attributes
    static void
    main(String[] args)
     
    static <T> T
    merge(T dst, Object src)
    Merge the state of src into dst via json serialization
    static <T> T
    read(com.fasterxml.jackson.databind.JsonNode node, T bean)
     
    com.fasterxml.jackson.databind.JsonNode
    read(org.apache.hadoop.conf.Configuration conf)
     
    <T> T
    read(org.apache.hadoop.conf.Configuration conf, T bean)
     
    static com.fasterxml.jackson.databind.JsonNode
    readRecursively(com.fasterxml.jackson.databind.JsonNode prototype, com.fasterxml.jackson.databind.JsonNode dst, org.aksw.commons.path.core.Path<String> path, Function<org.aksw.commons.path.core.Path<String>,String> getter)
    If dst is non-null, then the return value will be dst; otherwise, the return value is either and object or textual node matching the prototype
    static com.fasterxml.jackson.databind.JsonNode
    write(Object bean)
     
    void
    write(org.apache.hadoop.conf.Configuration conf, com.fasterxml.jackson.databind.JsonNode src)
     
    void
    write(org.apache.hadoop.conf.Configuration conf, Object bean)
     
    static void
    writeRecursively(com.fasterxml.jackson.databind.JsonNode prototype, com.fasterxml.jackson.databind.JsonNode src, org.aksw.commons.path.core.Path<String> path, BiConsumer<org.aksw.commons.path.core.Path<String>,String> setter)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • basePath

      protected org.aksw.commons.path.core.Path<String> basePath
    • prototype

      protected com.fasterxml.jackson.databind.JsonNode prototype
  • Constructor Details

    • JsonHadoopBridge

      public JsonHadoopBridge(org.aksw.commons.path.core.Path<String> basePath, com.fasterxml.jackson.databind.JsonNode prototype)
  • Method Details

    • read

      public <T> T read(org.apache.hadoop.conf.Configuration conf, T bean)
    • merge

      public static <T> T merge(T dst, Object src)
      Merge the state of src into dst via json serialization
    • read

      public static <T> T read(com.fasterxml.jackson.databind.JsonNode node, T bean)
    • read

      public com.fasterxml.jackson.databind.JsonNode read(org.apache.hadoop.conf.Configuration conf)
    • write

      public static com.fasterxml.jackson.databind.JsonNode write(Object bean)
    • write

      public void write(org.apache.hadoop.conf.Configuration conf, Object bean)
    • write

      public void write(org.apache.hadoop.conf.Configuration conf, com.fasterxml.jackson.databind.JsonNode src)
    • readRecursively

      public static com.fasterxml.jackson.databind.JsonNode readRecursively(com.fasterxml.jackson.databind.JsonNode prototype, com.fasterxml.jackson.databind.JsonNode dst, org.aksw.commons.path.core.Path<String> path, Function<org.aksw.commons.path.core.Path<String>,String> getter)
      If dst is non-null, then the return value will be dst; otherwise, the return value is either and object or textual node matching the prototype
    • writeRecursively

      public static void writeRecursively(com.fasterxml.jackson.databind.JsonNode prototype, com.fasterxml.jackson.databind.JsonNode src, org.aksw.commons.path.core.Path<String> path, BiConsumer<org.aksw.commons.path.core.Path<String>,String> setter)
    • createFromPrototype

      public static JsonHadoopBridge createFromPrototype(Object o, String prefix)
      This method takes as argument an object that serves as a prototype: It is converted to json (null values retained) and the obtained (nested) keys are used as attributes
    • main

      public static void main(String[] args) throws com.fasterxml.jackson.core.JsonProcessingException
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException