com.datasalt.pangool.io
Class Schema

java.lang.Object
  extended by com.datasalt.pangool.io.Schema
All Implemented Interfaces:
Serializable

public class Schema
extends Object
implements Serializable

A list of Schema.Field elements that a ITuple instance contains.

See Also:
Serialized Form

Nested Class Summary
static class Schema.Field
          A field is an abstract data type that can be one of this: A 32-bit signed int; A 64-bit signed long; A 32-bit IEEE single-float; or A 64-bit IEEE double-float; or A unicode string; A boolean; or An enum, containing one of a small set of symbols; A byte buffer An arbitrary object, serializable by Hadoop's serialization

A field can be constructed using one of its static createXXX methods.

static class Schema.SchemaParseException
           
 
Constructor Summary
Schema(String name, List<Schema.Field> fields)
           
 
Method Summary
 boolean containsField(String fieldName)
           
static boolean containsFieldUsingAlias(Schema schema, String fieldName, Map<String,String> aliases)
           
 boolean containsNullableFields()
           
 boolean equals(Object o)
           
 Schema.Field getField(int i)
           
 Schema.Field getField(String fieldName)
           
 Integer getFieldPos(String fieldName)
           
static int getFieldPosUsingAliases(Schema schema, String field, Map<String,String> aliases)
           
 List<Schema.Field> getFields()
           
static Schema.Field getFieldUsingAliases(Schema schema, String field, Map<String,String> aliases)
           
 String getName()
           
 List<Integer> getNullableFieldsIdx()
           
 int getNullablePositionFromIndex(int idx)
          Return the position on the array returned by getNullableFieldsIdx() for a given field's index.
 int hashCode()
           
static Schema parse(org.codehaus.jackson.JsonNode schema)
           
static Schema parse(String s)
           
 void toJson(org.codehaus.jackson.JsonGenerator gen)
           
 String toString()
           
 String toString(boolean pretty)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Schema

public Schema(String name,
              List<Schema.Field> fields)
Method Detail

getFields

public List<Schema.Field> getFields()

getName

public String getName()

getFieldPos

public Integer getFieldPos(String fieldName)

getField

public Schema.Field getField(String fieldName)

getField

public Schema.Field getField(int i)

containsField

public boolean containsField(String fieldName)

getNullableFieldsIdx

public List<Integer> getNullableFieldsIdx()
Returns:
A list of indexes to fields that are nullable on that schema

containsNullableFields

public boolean containsNullableFields()
Returns:
true if this schema contains at least one field that is nullable. False otherwise.

getNullablePositionFromIndex

public int getNullablePositionFromIndex(int idx)
Return the position on the array returned by getNullableFieldsIdx() for a given field's index. In other words, the following is always true. getNullablePositionFromIndex(getNullableFieldsIdx().get(i)) == 1.
Be careful, as this is only available for nullable fields. If an index of a non nullable field is given, 0 is returned always.


toString

public String toString()
Overrides:
toString in class Object

toString

public String toString(boolean pretty)

parse

public static Schema parse(String s)

parse

public static Schema parse(org.codehaus.jackson.JsonNode schema)
                    throws IOException
Throws:
IOException

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toJson

public void toJson(org.codehaus.jackson.JsonGenerator gen)
            throws IOException
Throws:
IOException

containsFieldUsingAlias

public static boolean containsFieldUsingAlias(Schema schema,
                                              String fieldName,
                                              Map<String,String> aliases)

getFieldUsingAliases

public static Schema.Field getFieldUsingAliases(Schema schema,
                                                String field,
                                                Map<String,String> aliases)

getFieldPosUsingAliases

public static int getFieldPosUsingAliases(Schema schema,
                                          String field,
                                          Map<String,String> aliases)


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