com.ning.metrics.goodwill.access
Class GoodwillSchema

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

public class GoodwillSchema
extends Object

Describe a Schema in Goodwill. This is basically a union of a Schema and extra metadata for the Sink.

See Also:
Schema

Field Summary
static String JSON_THRIFT_TYPE_NAME
           
static String JSON_THRIFT_TYPE_SCHEMA
           
static String JSON_THRIFT_TYPE_SINK_ADD_INFO
           
 
Constructor Summary
GoodwillSchema(String name, List<GoodwillSchemaField> items)
          Manual constructor, typically used by Goodwill stores.
GoodwillSchema(String name, List<GoodwillSchemaField> items, String sinkAddInfo)
          Jackson constructor

{ "sinkAddInfo": null, "name": "hello", "schema": [ { "name": "my hello attribute", "type": "string", "position": 1, "description": "awesome attribute", "sql": { "type": "nvarchar", "length": null, "scale": null, "precision": null } }, { "name": "dsfdfsfds", "type": "bool", "position": 2, "description": "dfsfdsfds", "sql": { "type": "boolean", "length": null, "scale": null, "precision": null } }, { "name": "wer", "type": "double", "position": 3, "description": "wer", "sql": { "type": "numeric", "length": null, "scale": 12, "precision": 42 } } ] }

 
Method Summary
 void addThriftField(GoodwillSchemaField goodwillSchemaField)
          Add a field in the Thrift.
static GoodwillSchema decode(String thriftJson)
           
 GoodwillSchemaField getFieldByName(String name)
          Given a name, return the field matching the name.
 GoodwillSchemaField getFieldByPosition(short i)
          Given a position, return the field at that position.
 String getName()
           
 ArrayList<GoodwillSchemaField> getSchema()
          Get the schema as a collection of fields.
 void setSinkAddInfo(String sinkAddInfo)
           
 ByteArrayOutputStream toJSON()
          Deprecated. Use 'toJSONBytes()' instead
 byte[] toJSONBytes()
           
 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_TYPE_NAME

public static final String JSON_THRIFT_TYPE_NAME
See Also:
Constant Field Values

JSON_THRIFT_TYPE_SCHEMA

public static final String JSON_THRIFT_TYPE_SCHEMA
See Also:
Constant Field Values

JSON_THRIFT_TYPE_SINK_ADD_INFO

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

GoodwillSchema

public GoodwillSchema(String name,
                      List<GoodwillSchemaField> items,
                      String sinkAddInfo)
Jackson constructor

{ "sinkAddInfo": null, "name": "hello", "schema": [ { "name": "my hello attribute", "type": "string", "position": 1, "description": "awesome attribute", "sql": { "type": "nvarchar", "length": null, "scale": null, "precision": null } }, { "name": "dsfdfsfds", "type": "bool", "position": 2, "description": "dfsfdsfds", "sql": { "type": "boolean", "length": null, "scale": null, "precision": null } }, { "name": "wer", "type": "double", "position": 3, "description": "wer", "sql": { "type": "numeric", "length": null, "scale": 12, "precision": 42 } } ] }

Parameters:
name - Schema name
items - List of fields
sinkAddInfo - extra information for the Sink

GoodwillSchema

public GoodwillSchema(String name,
                      List<GoodwillSchemaField> items)
Manual constructor, typically used by Goodwill stores.

Parameters:
name - Schema name
items - List of fields
Method Detail

decode

public static GoodwillSchema decode(String thriftJson)
                             throws IOException
Throws:
IOException

toMap

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

addThriftField

public void addThriftField(GoodwillSchemaField goodwillSchemaField)
Add a field in the Thrift. The code does not enforce sanity w.r.t. field positions.

Parameters:
goodwillSchemaField - field to add

getName

public String getName()

getSchema

public ArrayList<GoodwillSchemaField> getSchema()
Get the schema as a collection of fields. We guarantee the ordering by field id.

Returns:
the sorted collection of fields

setSinkAddInfo

public void setSinkAddInfo(String sinkAddInfo)

getFieldByPosition

public GoodwillSchemaField getFieldByPosition(short i)
Given a position, return the field at that position.

Parameters:
i - position in the Thrift (start with 1)
Returns:
the GoodwillSchemaField object

getFieldByName

public GoodwillSchemaField getFieldByName(String name)
Given a name, return the field matching the name.

Parameters:
name - GoodwillSchemaField name
Returns:
the GoodwillSchemaField object

toString

public String toString()
Overrides:
toString in class Object

toJSONBytes

public byte[] toJSONBytes()
                   throws IOException
Throws:
IOException

toJSON

@Deprecated
public ByteArrayOutputStream toJSON()
                             throws IOException
Deprecated. Use 'toJSONBytes()' instead

Throws:
IOException


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