|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jruby.RubyBasicObject
org.jruby.RubyObject
org.apache.pig.scripting.jruby.RubySchema
public class RubySchema
This class encapsulated a native Schema object, and provides a more convenient
interface for manipulating Schemas. It hides the Schema/FieldSchema distinction
from the user, and tries to present a cleaner, more Ruby-esque API to the user.
For general information on JRuby's API definition annotations,
see RubyDataBag
.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.jruby.RubyObject |
---|
org.jruby.RubyObject.Data |
Nested classes/interfaces inherited from class org.jruby.RubyBasicObject |
---|
org.jruby.RubyBasicObject.Finalizer |
Field Summary |
---|
Fields inherited from class org.jruby.RubyObject |
---|
OBJECT_ALLOCATOR, REIFYING_OBJECT_ALLOCATOR |
Fields inherited from class org.jruby.RubyBasicObject |
---|
ALL_F, BASICOBJECT_ALLOCATOR, COMPARE_BY_IDENTITY_F, ERR_INSECURE_SET_INST_VAR, FALSE_F, FL_USHIFT, flags, FROZEN_F, metaClass, NEVER, NIL_F, TAINTED_F, UNDEF, UNTRUSTED_F, USER0_F, USER1_F, USER2_F, USER3_F, USER4_F, USER5_F, USER6_F, USER7_F, USER8_F |
Fields inherited from interface org.jruby.runtime.builtin.IRubyObject |
---|
NULL_ARRAY |
Constructor Summary | |
---|---|
protected |
RubySchema(org.jruby.Ruby ruby,
org.jruby.RubyClass rc)
|
protected |
RubySchema(org.jruby.Ruby ruby,
org.jruby.RubyClass rc,
Schema s)
This constructor sets the encapsulated Schema to be equal to the given Schema. |
protected |
RubySchema(org.jruby.Ruby ruby,
org.jruby.RubyClass rc,
Schema s,
boolean copy)
This constructor sets the encapsulated Schema to be equal to the given Schema. |
protected |
RubySchema(org.jruby.Ruby ruby,
org.jruby.RubyClass rc,
String s)
This constructor is provided for convenience and sets the internal Schema equal to the result of a call to Utils.getSchemaFromString(java.lang.String) . |
Method Summary | |
---|---|
RubySchema |
add(org.jruby.runtime.ThreadContext context,
org.jruby.runtime.builtin.IRubyObject[] args)
This method provides addition semantics, without modifying the original Schema. |
void |
addInPlace(org.jruby.runtime.ThreadContext context,
org.jruby.runtime.builtin.IRubyObject[] args)
This method provides addition semantics, modifying the original Schema in place. |
static RubySchema |
bag(org.jruby.runtime.ThreadContext context,
org.jruby.runtime.builtin.IRubyObject self,
org.jruby.runtime.builtin.IRubyObject arg)
This is a ruby method which takes an array of arguments and constructs a Bag schema from them. |
static RubySchema |
bag(org.jruby.runtime.ThreadContext context,
org.jruby.runtime.builtin.IRubyObject self,
org.jruby.runtime.builtin.IRubyObject arg1,
org.jruby.runtime.builtin.IRubyObject arg2)
This is a ruby method which takes a name and an array of arguments and constructs a Bag schema from them. |
RubySchema |
clone(org.jruby.runtime.ThreadContext context)
|
static org.jruby.RubyClass |
define(org.jruby.Ruby runtime)
This method registers the class with the given runtime. |
RubySchema |
find(org.jruby.runtime.ThreadContext context,
org.jruby.runtime.builtin.IRubyObject arg)
Given a field name this string will search the RubySchema for a FieldSchema with that name and return it encapsulated in a Schema. |
RubySchema |
get(org.jruby.runtime.ThreadContext context)
This method allows access into the Schema nested in the encapsulated Schema. |
RubySchema |
get(org.jruby.runtime.ThreadContext context,
org.jruby.runtime.builtin.IRubyObject arg)
This is the ruby method which allows people to access elements of the RubySchema object. |
RubySchema |
get(org.jruby.runtime.ThreadContext context,
org.jruby.runtime.builtin.IRubyObject arg1,
org.jruby.runtime.builtin.IRubyObject arg2)
This is a version of [] which allows the range to be specified as such: [1,2]. |
Schema |
getInternalSchema()
This is a helper method to pull out the native Java type from the ruby object. |
org.jruby.RubyString |
getName(org.jruby.runtime.ThreadContext context)
This method allows the user to see the name of the alias of the FieldSchema of the encapsulated Schema. |
org.jruby.RubyFixnum |
index(org.jruby.runtime.ThreadContext context,
org.jruby.runtime.builtin.IRubyObject arg)
Given a field name, this will return the index of it in the schema. |
RubySchema |
initialize(org.jruby.runtime.builtin.IRubyObject[] args)
The ruby initializer accepts any number of arguments. |
static RubySchema |
map(org.jruby.runtime.ThreadContext context,
org.jruby.runtime.builtin.IRubyObject self,
org.jruby.runtime.builtin.IRubyObject arg)
This is a ruby method which takes an array of arguments and constructs a Map schema from them. |
static RubySchema |
map(org.jruby.runtime.ThreadContext context,
org.jruby.runtime.builtin.IRubyObject self,
org.jruby.runtime.builtin.IRubyObject arg1,
org.jruby.runtime.builtin.IRubyObject arg2)
This is a ruby method which takes a name and an array of arguments and constructs a Map schema from them. |
static RubySchema |
nullBag(org.jruby.runtime.ThreadContext context,
org.jruby.runtime.builtin.IRubyObject self)
This is a static helper method to create a null aliased bag Schema. |
static RubySchema |
nullBoolean(org.jruby.runtime.ThreadContext context,
org.jruby.runtime.builtin.IRubyObject self)
This is a static helper method to create a null aliased Boolean Schema. |
static RubySchema |
nullBytearray(org.jruby.runtime.ThreadContext context,
org.jruby.runtime.builtin.IRubyObject self)
This is a static helper method to create a null aliased bytearray Schema. |
static RubySchema |
nullChararray(org.jruby.runtime.ThreadContext context,
org.jruby.runtime.builtin.IRubyObject self)
This is a static helper method to create a null aliased chararray Schema. |
static RubySchema |
nullDateTime(org.jruby.runtime.ThreadContext context,
org.jruby.runtime.builtin.IRubyObject self)
This is a static helper method to create a null aliased datetime Schema. |
static RubySchema |
nullDouble(org.jruby.runtime.ThreadContext context,
org.jruby.runtime.builtin.IRubyObject self)
This is a static helper method to create a null aliased double Schema. |
static RubySchema |
nullFloate(org.jruby.runtime.ThreadContext context,
org.jruby.runtime.builtin.IRubyObject self)
This is a static helper method to create a null aliased float Schema. |
static RubySchema |
nullInt(org.jruby.runtime.ThreadContext context,
org.jruby.runtime.builtin.IRubyObject self)
This is a static helper method to create a null aliased int Schema. |
static RubySchema |
nullLong(org.jruby.runtime.ThreadContext context,
org.jruby.runtime.builtin.IRubyObject self)
This is a static helper method to create a null aliased long Schema. |
static RubySchema |
nullMap(org.jruby.runtime.ThreadContext context,
org.jruby.runtime.builtin.IRubyObject self)
This is a static helper method to create a null aliased map Schema. |
static RubySchema |
nullTuple(org.jruby.runtime.ThreadContext context,
org.jruby.runtime.builtin.IRubyObject self)
This is a static helper method to create a null aliased tuple Schema. |
static Schema |
rubyArgToSchema(Object arg)
This is a helper function which converts objects into Schema objects. |
RubySchema |
set(org.jruby.runtime.ThreadContext context,
org.jruby.runtime.builtin.IRubyObject[] args)
This allows the users to set an index or a range of values to a specified RubySchema. |
org.jruby.RubyString |
setName(org.jruby.runtime.builtin.IRubyObject arg)
This method allows the user to set the name of the alias of the FieldSchema of the encapsulated Schema. |
org.jruby.RubyFixnum |
size(org.jruby.runtime.ThreadContext context)
|
org.jruby.RubyString |
toString(org.jruby.runtime.ThreadContext context)
The toString method just leverages Schema's printing. |
static RubySchema |
tuple(org.jruby.runtime.ThreadContext context,
org.jruby.runtime.builtin.IRubyObject self,
org.jruby.runtime.builtin.IRubyObject arg)
This is a ruby method which takes an array of arguments and constructs a Tuple schema from them. |
static RubySchema |
tuple(org.jruby.runtime.ThreadContext context,
org.jruby.runtime.builtin.IRubyObject self,
org.jruby.runtime.builtin.IRubyObject arg1,
org.jruby.runtime.builtin.IRubyObject arg2)
This is a ruby method which takes a name and an array of arguments and constructs a Tuple schema from them. |
Methods inherited from class org.jruby.RubyObject |
---|
attachToObjectSpace, callInit, callInit, callInit, callInit, callInit, convertToType, createObjectClass, eqlInternal, equalInternal, equals, getNativeTypeIndex, hashCode, initialize, initialize, op_eqq, puts, specificEval, toString |
Methods inherited from class org.jruby.RubyBasicObject |
---|
addFinalizer, anyToString, asJavaString, asString, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callSuper, checkArrayType, checkCallMethod, checkFrozen, checkStringType, checkStringType19, compareTo, convertToArray, convertToFloat, convertToHash, convertToInteger, convertToInteger, convertToInteger, convertToString, copyInstanceVariablesInto, copySpecialInstanceVariables, createBasicObjectClass, dataGetStruct, dataGetStructChecked, dataWrapStruct, display, dup, ensureInstanceVariablesSettable, eql_p, eql, equal_p, equal_p19, evalUnder, extend, fastGetInstanceVariable, fastGetInternalVariable, fastHasInstanceVariable, fastHasInternalVariable, fastSetInstanceVariable, fastSetInternalVariable, freeze, frozen_p, getFlag, getInstanceEvalClass, getInstanceVariable, getInstanceVariableList, getInstanceVariableNameList, getInstanceVariables, getInternalVariable, getInternalVariables, getJavaClass, getMetaClass, getObjectId, getRuntime, getSingletonClass, getSingletonClassClone, getType, getVariable, getVariableCount, getVariableList, getVariableNameList, getVariableTableForRead, getVariableTableForWrite, hash, hashyInspect, hasInstanceVariable, hasInternalVariable, hasVariables, id_deprecated, id, infectBy, initialize_copy, initialize19, initialize19, initialize19, initialize19, initialize19, initObjectId, inspect, inspectHashCode, instance_eval, instance_eval, instance_eval, instance_eval, instance_eval19, instance_eval19, instance_eval19, instance_eval19, instance_exec, instance_exec19, instance_of_p, instance_variable_defined_p, instance_variable_get, instance_variable_set, instance_variables, instance_variables19, isBuiltin, isClass, isFalse, isFrozen, isImmediate, isModule, isNil, isTaint, isTrue, isUntrusted, kind_of_p, makeMetaClass, method_missing19, method, method19, methods, methods, methods19, nil_p, op_cmp, op_equal_19, op_equal, op_match, op_match19, op_not_equal, op_not_match, op_not, private_methods, private_methods19, protected_methods, protected_methods19, public_methods, public_methods19, rbClone, remove_instance_variable, removeFinalizers, removeInstanceVariable, removeInternalVariable, respond_to_p, respond_to_p, respond_to_p19, respond_to_p19, respondsTo, respondsToMissing, respondsToMissing, send, send, send, send, send, send19, send19, send19, send19, send19, setFlag, setFrozen, setInstanceVariable, setInternalVariable, setMetaClass, setTaint, setUntrusted, setVariable, singleton_method_added19, singleton_method_removed19, singleton_method_undefined19, singleton_methods, singleton_methods19, specificEval, specificEval, specificEval, specificEval, syncVariables, syncVariables, taint, taint, tainted_p, testFrozen, testFrozen, to_a, to_s, toJava, trust, type_deprecated, type, untaint, untrust, untrusted_p, validateInstanceVariable, variableTableContains, variableTableFastContains, variableTableFastFetch, variableTableFastStore, variableTableFetch, variableTableRemove, variableTableStore, variableTableSync, yieldUnder, yieldUnder |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
protected RubySchema(org.jruby.Ruby ruby, org.jruby.RubyClass rc)
protected RubySchema(org.jruby.Ruby ruby, org.jruby.RubyClass rc, Schema s, boolean copy)
ruby
- an instance of the ruby runtimerc
- an instance of the class object with meatadatas
- a Schema to encapsulatecopy
- a boolean value. If true, s will be copied and the copy
will be encapsulated. If false, it will be encapsulated
directly.protected RubySchema(org.jruby.Ruby ruby, org.jruby.RubyClass rc, Schema s)
ruby
- an instance of the ruby runtimerc
- an instance of the class object with meatadatas
- a Schema to encapsulateprotected RubySchema(org.jruby.Ruby ruby, org.jruby.RubyClass rc, String s)
Utils.getSchemaFromString(java.lang.String)
.
ruby
- an instance of the ruby runtimerc
- an instance of the class object with meatadatas
- a String which will be passed to
Utils.getSchemaFromString(java.lang.String)
Method Detail |
---|
public static org.jruby.RubyClass define(org.jruby.Ruby runtime)
runtime
- an instance of the Ruby runtime
public RubySchema initialize(org.jruby.runtime.builtin.IRubyObject[] args)
rubyArgToSchema(java.lang.Object)
.
args
- a varargs which can take any number of valid arguments to
rubyArgToSchema(java.lang.Object)
public static RubySchema nullBytearray(org.jruby.runtime.ThreadContext context, org.jruby.runtime.builtin.IRubyObject self)
Utils.getSchemaFromString(java.lang.String)
will assign.
context
- the context the method is being executed inself
- an instance of the RubyClass with metadata on
the Ruby class object this method is being
statically invoked against
public static RubySchema nullBoolean(org.jruby.runtime.ThreadContext context, org.jruby.runtime.builtin.IRubyObject self)
Utils.getSchemaFromString(java.lang.String)
will assign.
context
- the context the method is being executed inself
- an instance of the RubyClass with metadata on
the Ruby class object this method is being
statically invoked against
public static RubySchema nullChararray(org.jruby.runtime.ThreadContext context, org.jruby.runtime.builtin.IRubyObject self)
Utils.getSchemaFromString(java.lang.String)
will assign.
context
- the context the method is being executed inself
- an instance of the RubyClass with metadata on
the Ruby class object this method is being
statically invoked against
public static RubySchema nullLong(org.jruby.runtime.ThreadContext context, org.jruby.runtime.builtin.IRubyObject self)
Utils.getSchemaFromString(java.lang.String)
will assign.
context
- the context the method is being executed inself
- an instance of the RubyClass with metadata on
the Ruby class object this method is being
statically invoked against
public static RubySchema nullInt(org.jruby.runtime.ThreadContext context, org.jruby.runtime.builtin.IRubyObject self)
Utils.getSchemaFromString(java.lang.String)
will assign.
context
- the context the method is being executed inself
- an instance of the RubyClass with metadata on
the Ruby class object this method is being
statically invoked against
public static RubySchema nullDouble(org.jruby.runtime.ThreadContext context, org.jruby.runtime.builtin.IRubyObject self)
Utils.getSchemaFromString(java.lang.String)
will assign.
context
- the context the method is being executed inself
- an instance of the RubyClass with metadata on
the Ruby class object this method is being
statically invoked against
public static RubySchema nullFloate(org.jruby.runtime.ThreadContext context, org.jruby.runtime.builtin.IRubyObject self)
Utils.getSchemaFromString(java.lang.String)
will assign.
context
- the context the method is being executed inself
- an instance of the RubyClass with metadata on
the Ruby class object this method is being
statically invoked against
public static RubySchema nullDateTime(org.jruby.runtime.ThreadContext context, org.jruby.runtime.builtin.IRubyObject self)
Utils.getSchemaFromString(java.lang.String)
will assign.
context
- the context the method is being executed inself
- an instance of the RubyClass with metadata on
the Ruby class object this method is being
statically invoked against
public static RubySchema nullTuple(org.jruby.runtime.ThreadContext context, org.jruby.runtime.builtin.IRubyObject self)
Utils.getSchemaFromString(java.lang.String)
will assign.
context
- the context the method is being executed inself
- an instance of the RubyClass with metadata on
the Ruby class object this method is being
statically invoked against
public static RubySchema nullBag(org.jruby.runtime.ThreadContext context, org.jruby.runtime.builtin.IRubyObject self)
Utils.getSchemaFromString(java.lang.String)
will assign.
context
- the context the method is being executed inself
- an instance of the RubyClass with metadata on
the Ruby class object this method is being
statically invoked against
public static RubySchema nullMap(org.jruby.runtime.ThreadContext context, org.jruby.runtime.builtin.IRubyObject self)
Utils.getSchemaFromString(java.lang.String)
will assign.
context
- the context the method is being executed inself
- an instance of the RubyClass with metadata on
the Ruby class object this method is being
statically invoked against
public static Schema rubyArgToSchema(Object arg)
A RubyString, which will have Utils.getSchemaFromString(java.lang.String)
called on it, and
it will be added.
A RubySchema, which will be added directly. IMPORTANT NOTE: since this API abstracts away from the distinction between Schema/FieldSchema, its important to understand how a Schema is added to another. In this case, the FieldSchema is pulled directly out of the given Schema. Thus, where in Pig a Schema.FieldSchema might be passed around, internally to this class, generally a Schema will be passed around encapsulating it.
A list will create the Schema for a Tuple whose elements will be the elements of the list. Each element will be subjected to the same rules applied here.
A hash in the form of:
{"name:tuple"=>["x:int","y:int,z:int"], "name2:bag"=>["a:chararray"]}
The keys must be a tuple, bag, or map, and the value must be an array.
arg
- an object (generally an IRubyObject or String) to convert. See above for
the rules on valid arguments
public static RubySchema tuple(org.jruby.runtime.ThreadContext context, org.jruby.runtime.builtin.IRubyObject self, org.jruby.runtime.builtin.IRubyObject arg1, org.jruby.runtime.builtin.IRubyObject arg2)
context
- the context the method is being executed inself
- the RubyClass for the Class object this was invoked onarg1
- the name for the RubySchemaarg2
- a list of arguments to instantiate the new RubySchema
public static RubySchema tuple(org.jruby.runtime.ThreadContext context, org.jruby.runtime.builtin.IRubyObject self, org.jruby.runtime.builtin.IRubyObject arg)
context
- the context the method is being executed inself
- the RubyClass for the Class object this was invoked onarg
- a list of arguments to instantiate the new RubySchema
public static RubySchema map(org.jruby.runtime.ThreadContext context, org.jruby.runtime.builtin.IRubyObject self, org.jruby.runtime.builtin.IRubyObject arg1, org.jruby.runtime.builtin.IRubyObject arg2)
context
- the context the method is being executed inself
- the RubyClass for the Class object this was invoked onarg1
- the name for the RubySchemaarg2
- a list of arguments to instantiate the new RubySchema
public static RubySchema map(org.jruby.runtime.ThreadContext context, org.jruby.runtime.builtin.IRubyObject self, org.jruby.runtime.builtin.IRubyObject arg)
context
- the context the method is being executed inself
- the RubyClass for the Class object this was invoked onarg
- a list of arguments to instantiate the new RubySchema
public static RubySchema bag(org.jruby.runtime.ThreadContext context, org.jruby.runtime.builtin.IRubyObject self, org.jruby.runtime.builtin.IRubyObject arg1, org.jruby.runtime.builtin.IRubyObject arg2)
context
- the context the method is being executed inself
- the RubyClass for the Class object this was invoked onarg1
- the name for the RubySchemaarg2
- a list of arguments to instantiate the new RubySchema
public static RubySchema bag(org.jruby.runtime.ThreadContext context, org.jruby.runtime.builtin.IRubyObject self, org.jruby.runtime.builtin.IRubyObject arg)
context
- the context the method is being executed inself
- the RubyClass for the Class object this was invoked onarg
- a list of arguments to instantiate the new RubySchema
public org.jruby.RubyString toString(org.jruby.runtime.ThreadContext context)
context
- the context the method is being executed in
public RubySchema get(org.jruby.runtime.ThreadContext context, org.jruby.runtime.builtin.IRubyObject arg)
context
- the context the method is being executed inarg
- a Fixnum index, Range object to specify a range of values to return, or
a String to look up by alias name
public RubySchema get(org.jruby.runtime.ThreadContext context, org.jruby.runtime.builtin.IRubyObject arg1, org.jruby.runtime.builtin.IRubyObject arg2)
context
- the context the method is being executed inarg1
- a Fixnum start indexarg2
- a Fixnum end index
public RubySchema set(org.jruby.runtime.ThreadContext context, org.jruby.runtime.builtin.IRubyObject[] args)
context
- the contextthe method is being executed inargs
- a varargs which has to be at least length two.
public RubySchema add(org.jruby.runtime.ThreadContext context, org.jruby.runtime.builtin.IRubyObject[] args)
context
- the context the method is being executed inargs
- a varargs which can be any valid set of arguments that
can initialize a RubySchema
public void addInPlace(org.jruby.runtime.ThreadContext context, org.jruby.runtime.builtin.IRubyObject[] args)
context
- the context the method is being executed inargs
- a varargs which can be any valid set of arguments that
can initialize a RubySchemapublic RubySchema clone(org.jruby.runtime.ThreadContext context)
context
- the context the method is being executed in
public RubySchema find(org.jruby.runtime.ThreadContext context, org.jruby.runtime.builtin.IRubyObject arg)
context
- the context the method is being executed inarg
- a RubyString serving as an alias to look
for in the Schema
public org.jruby.RubyFixnum index(org.jruby.runtime.ThreadContext context, org.jruby.runtime.builtin.IRubyObject arg)
context
- the context the method is being executed inarg
- a field name to look for
public org.jruby.RubyFixnum size(org.jruby.runtime.ThreadContext context)
context
- the context the method is being executed in
public Schema getInternalSchema()
public RubySchema get(org.jruby.runtime.ThreadContext context)
context
- the context the method is being executed in
public org.jruby.RubyString getName(org.jruby.runtime.ThreadContext context)
context
- the context the method is being executed in
public org.jruby.RubyString setName(org.jruby.runtime.builtin.IRubyObject arg)
arg
- a RubyString to set the name to
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |