Package net.sansa_stack.hadoop.util
Class JsonHadoopBridge
java.lang.Object
net.sansa_stack.hadoop.util.JsonHadoopBridge
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 -
Constructor Summary
ConstructorsConstructorDescriptionJsonHadoopBridge(org.aksw.commons.path.core.Path<String> basePath, com.fasterxml.jackson.databind.JsonNode prototype) -
Method Summary
Modifier and TypeMethodDescriptionstatic JsonHadoopBridgecreateFromPrototype(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 attributesstatic voidstatic <T> TMerge the state of src into dst via json serializationstatic <T> Tread(com.fasterxml.jackson.databind.JsonNode node, T bean) com.fasterxml.jackson.databind.JsonNoderead(org.apache.hadoop.conf.Configuration conf) <T> Tread(org.apache.hadoop.conf.Configuration conf, T bean) static com.fasterxml.jackson.databind.JsonNodereadRecursively(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 prototypestatic com.fasterxml.jackson.databind.JsonNodevoidwrite(org.apache.hadoop.conf.Configuration conf, com.fasterxml.jackson.databind.JsonNode src) voidstatic voidwriteRecursively(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)
-
Field Details
-
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
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
-
write
-
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
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
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-