public class ColumnMappingParser extends Object
ColumnMapping. Will parse the mapping annotation from
Avro schemas, and will parse the ColumnMapping JSON format. An
example of that is:
[
{ "source": "field1", "type": "column", "value": "cf:field1" },
{ "source": "field2", "type": "keyAsColumn", "value": "kac:" },
{ "source": "field3", "type": "occVersion" }
]
| Constructor and Description |
|---|
ColumnMappingParser() |
| Modifier and Type | Method and Description |
|---|---|
static Schema |
embedColumnMapping(Schema schema,
ColumnMapping mapping) |
static boolean |
hasEmbeddedColumnMapping(Schema schema) |
static boolean |
hasEmbeddedFieldMappings(Schema schema) |
static ColumnMapping |
parse(File file)
Parses the Mapping Descriptor from a File
|
static ColumnMapping |
parse(InputStream in)
Parses the Mapping Descriptor from an input stream
|
static ColumnMapping |
parse(String mappingDescriptor)
Parses the Mapping Descriptor as a JSON string.
|
static FieldMapping |
parseFieldMapping(com.fasterxml.jackson.databind.JsonNode mappingNode)
Parses the FieldMapping from an annotated schema field.
|
static FieldMapping |
parseFieldMapping(String source,
com.fasterxml.jackson.databind.JsonNode mappingNode)
Parses the FieldMapping from an annotated schema field.
|
static ColumnMapping |
parseFromSchema(Schema schema) |
static ColumnMapping |
parseFromSchemaFields(Schema schema) |
static Map<Integer,FieldMapping> |
parseKeyMappingsFromSchemaFields(Schema schema) |
static Schema |
removeEmbeddedMapping(Schema schema) |
static String |
toString(ColumnMapping mapping,
boolean pretty) |
static String |
toString(FieldMapping mapping) |
public static ColumnMapping parse(String mappingDescriptor)
mappingDescriptor - The mapping descriptor as a JSON stringpublic static ColumnMapping parse(File file)
file - The File that contains the Mapping Descriptor in JSON format.public static ColumnMapping parse(InputStream in)
in - The input stream that contains the Mapping Descriptor in JSON
format.public static boolean hasEmbeddedColumnMapping(Schema schema)
public static ColumnMapping parseFromSchema(Schema schema)
public static boolean hasEmbeddedFieldMappings(Schema schema)
public static ColumnMapping parseFromSchemaFields(Schema schema)
public static Schema embedColumnMapping(Schema schema, ColumnMapping mapping)
public static Map<Integer,FieldMapping> parseKeyMappingsFromSchemaFields(Schema schema)
public static FieldMapping parseFieldMapping(com.fasterxml.jackson.databind.JsonNode mappingNode)
mappingNode - The value of the "mapping" nodepublic static FieldMapping parseFieldMapping(String source, com.fasterxml.jackson.databind.JsonNode mappingNode)
source - The source field name for this mappingmappingNode - The value of the "mapping" nodepublic static String toString(FieldMapping mapping)
public static String toString(ColumnMapping mapping, boolean pretty)
Copyright © 2013–2015. All rights reserved.