com.ning.metrics.goodwill.access
Class GoodwillSchemaField

java.lang.Object
  extended by com.ning.metrics.goodwill.access.GoodwillSchemaField

public class GoodwillSchemaField
extends Object

Describe a SchemaField in Goodwill. This is basically the union of a SchemaField and extra metadata for the SQL sink.

See Also:
SchemaField

Nested Class Summary
static class GoodwillSchemaField.Sql
          Extra information for the SQL Sink
 
Field Summary
static String JSON_THRIFT_FIELD_DESCRIPTION
           
static String JSON_THRIFT_FIELD_ID
           
static String JSON_THRIFT_FIELD_NAME
           
static String JSON_THRIFT_FIELD_SQL_KEY
           
static String JSON_THRIFT_FIELD_SQL_LENGTH
           
static String JSON_THRIFT_FIELD_SQL_PRECISION
           
static String JSON_THRIFT_FIELD_SQL_SCALE
           
static String JSON_THRIFT_FIELD_SQL_TYPE
           
static String JSON_THRIFT_FIELD_TYPE
           
 
Constructor Summary
GoodwillSchemaField(com.ning.metrics.serialization.schema.SchemaField field)
           
GoodwillSchemaField(String name, String type, short id, String description, GoodwillSchemaField.Sql sql)
          Jackson constructor

{ "name": "myField", "type": "string", "position": 1, "description": "string", "sql": { "type": "nvarchar", "length": 255, "scale": null, "precision": null }

GoodwillSchemaField(String name, String type, short id, String description, String sqlType, Integer sqlLength, Integer sqlScale, Integer sqlPrecision)
          Manual constructor, typically used by Goodwill stores.
 
Method Summary
static GoodwillSchemaField decode(String thriftItemJson)
           
 String getDescription()
           
 String getFullSQLType()
          Pretty print the SQL type.
 short getId()
           
 String getName()
           
 GoodwillSchemaField.Sql getSql()
           
 com.ning.metrics.serialization.schema.SchemaFieldType getType()
           
 ByteArrayOutputStream toJSON()
          Create a JSON representation of the GoodwillSchemaField.
 com.google.common.collect.ImmutableMap toMap()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

JSON_THRIFT_FIELD_NAME

public static final String JSON_THRIFT_FIELD_NAME
See Also:
Constant Field Values

JSON_THRIFT_FIELD_TYPE

public static final String JSON_THRIFT_FIELD_TYPE
See Also:
Constant Field Values

JSON_THRIFT_FIELD_ID

public static final String JSON_THRIFT_FIELD_ID
See Also:
Constant Field Values

JSON_THRIFT_FIELD_DESCRIPTION

public static final String JSON_THRIFT_FIELD_DESCRIPTION
See Also:
Constant Field Values

JSON_THRIFT_FIELD_SQL_KEY

public static final String JSON_THRIFT_FIELD_SQL_KEY
See Also:
Constant Field Values

JSON_THRIFT_FIELD_SQL_TYPE

public static final String JSON_THRIFT_FIELD_SQL_TYPE
See Also:
Constant Field Values

JSON_THRIFT_FIELD_SQL_LENGTH

public static final String JSON_THRIFT_FIELD_SQL_LENGTH
See Also:
Constant Field Values

JSON_THRIFT_FIELD_SQL_SCALE

public static final String JSON_THRIFT_FIELD_SQL_SCALE
See Also:
Constant Field Values

JSON_THRIFT_FIELD_SQL_PRECISION

public static final String JSON_THRIFT_FIELD_SQL_PRECISION
See Also:
Constant Field Values
Constructor Detail

GoodwillSchemaField

public GoodwillSchemaField(String name,
                           String type,
                           short id,
                           String description,
                           GoodwillSchemaField.Sql sql)
Jackson constructor

{ "name": "myField", "type": "string", "position": 1, "description": "string", "sql": { "type": "nvarchar", "length": 255, "scale": null, "precision": null }

Parameters:
name - Schema field name
type - Schema field type. This is not necessarily a Thrift type. @see SchemaFieldType
id - field position
description - Short description of the field
sql - SQL object (used by the sink)

GoodwillSchemaField

public GoodwillSchemaField(String name,
                           String type,
                           short id,
                           String description,
                           String sqlType,
                           Integer sqlLength,
                           Integer sqlScale,
                           Integer sqlPrecision)
Manual constructor, typically used by Goodwill stores.

Parameters:
name - Schema field name
type - Schema field type. This is not necessarily a Thrift type. @see SchemaFieldType
id - field position
description - Short description of the field
sqlType - SQL type (varchar, int, ...)
sqlLength - SQL type length
sqlScale - SQL type scale
sqlPrecision - SQL type precision

GoodwillSchemaField

public GoodwillSchemaField(com.ning.metrics.serialization.schema.SchemaField field)
Method Detail

decode

public static GoodwillSchemaField decode(String thriftItemJson)
                                  throws IOException
Throws:
IOException

toMap

public com.google.common.collect.ImmutableMap toMap()

getName

public String getName()

getType

public com.ning.metrics.serialization.schema.SchemaFieldType getType()

getId

public short getId()

getSql

public GoodwillSchemaField.Sql getSql()

getDescription

public String getDescription()

toString

public String toString()
Overrides:
toString in class Object

toJSON

public ByteArrayOutputStream toJSON()
                             throws IOException
Create a JSON representation of the GoodwillSchemaField. It will always contain the name, type and position. Description and SQL attributes are however optional.

Returns:
JSONObject containing all fields
Throws:
IOException - if a serialization exception occurs
org.codehaus.jackson.JsonGenerationException - if a serialization exception occurs

getFullSQLType

public String getFullSQLType()
Pretty print the SQL type. TODO: add layer of abstraction, too Netezza specific

Returns:
a human readable representation of the SQL type


Copyright © 2010-2011 Ning, Inc.. All Rights Reserved.