com.datasalt.pangool.io
Class Mutator

java.lang.Object
  extended by com.datasalt.pangool.io.Mutator

public class Mutator
extends Object

Miscellaneous utilities for mutating Pangool schemas. One can use these to easily create supersets or subsets of a Schema, or joint Schemas between two Schemas. The details of each method is documented below:


Field Summary
static int COUNTER
           
 
Constructor Summary
Mutator()
           
 
Method Summary
static Schema jointSchema(Schema leftSchema, Schema rightSchema)
          Creates a joint schema between two Schemas.
static Schema jointSchema(String newName, Schema leftSchema, Schema rightSchema)
          Creates a joint schema between two Schemas.
static Schema minusFields(Schema schema, String... minusFields)
          Creates a new schema which has exactly the same fields as the input Schema minus the field names that are specified as "minusFields".
static Schema minusFields(String newName, Schema schema, String... minusFields)
          Creates a new schema which has exactly the same fields as the input Schema minus the field names that are specified as "minusFields".
static Schema subSetOf(Schema schema, String... subSetFields)
          Creates a subset of the input Schema exactly with the fields whose names are specified.
static Schema subSetOf(String newName, Schema schema, String... subSetFields)
          Creates a subset of the input Schema exactly with the fields whose names are specified.
static Schema superSetOf(Schema schema, Schema.Field... newFields)
          Creates a superset of the input Schema, taking all the Fields in the input schema and adding some new ones.
static Schema superSetOf(String newName, Schema schema, Schema.Field... newFields)
          Creates a superset of the input Schema, taking all the Fields in the input schema and adding some new ones.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COUNTER

public static int COUNTER
Constructor Detail

Mutator

public Mutator()
Method Detail

minusFields

public static Schema minusFields(Schema schema,
                                 String... minusFields)
Creates a new schema which has exactly the same fields as the input Schema minus the field names that are specified as "minusFields". This is equivalent to calling subSetOf(Schema, String...) with the list of Fields that must remain, but instead here we specify the fields that should NOT remain.

The name of the schema is auto-generated with a static counter.


minusFields

public static Schema minusFields(String newName,
                                 Schema schema,
                                 String... minusFields)
Creates a new schema which has exactly the same fields as the input Schema minus the field names that are specified as "minusFields". This is equivalent to calling subSetOf(Schema, String...) with the list of Fields that must remain, but instead here we specify the fields that should NOT remain.

The name of the schema is also specified as a parameter.


subSetOf

public static Schema subSetOf(Schema schema,
                              String... subSetFields)
Creates a subset of the input Schema exactly with the fields whose names are specified. The name of the schema is auto-generated with a static counter.


subSetOf

public static Schema subSetOf(String newName,
                              Schema schema,
                              String... subSetFields)
Creates a subset of the input Schema exactly with the fields whose names are specified. The name of the schema is also specified as a parameter.


superSetOf

public static Schema superSetOf(Schema schema,
                                Schema.Field... newFields)
Creates a superset of the input Schema, taking all the Fields in the input schema and adding some new ones. The new fields are fully specified in a Field class. The name of the schema is auto-generated with a static counter.


superSetOf

public static Schema superSetOf(String newName,
                                Schema schema,
                                Schema.Field... newFields)
Creates a superset of the input Schema, taking all the Fields in the input schema and adding some new ones. The new fields are fully specified in a Field class. The name of the schema is also specified as a parameter.


jointSchema

public static Schema jointSchema(Schema leftSchema,
                                 Schema rightSchema)
Creates a joint schema between two Schemas. All Fields from both schema are deduplicated and combined into a single Schema. The left Schema has priority so if both Schemas have the same Field with the same name but different Types, the Type from the left Schema will be taken.

The name of the schema is auto-generated with a static counter.


jointSchema

public static Schema jointSchema(String newName,
                                 Schema leftSchema,
                                 Schema rightSchema)
Creates a joint schema between two Schemas. All Fields from both schema are deduplicated and combined into a single Schema. The left Schema has priority so if both Schemas have the same Field with the same name but different Types, the Type from the left Schema will be taken.

The name of the schema is also specified as a parameter.



Copyright © –2014 Datasalt Systems S.L.. All rights reserved.