public class DataSchema
extends java.lang.Object
implements java.io.Serializable
Querier
and a Responder
.
The schema comprises a number of elements, each of which has a name, type, and a partitioner. Elements may be declared as arrays of types.
Schemas are typically loaded from XML descriptors.
DataSchemaLoader
,
Serialized FormModifier and Type | Method and Description |
---|---|
boolean |
containsElement(java.lang.String elementName)
Returns true if the data schema contains an element with the given name.
|
java.util.Set<java.lang.String> |
getArrayElements()
Returns the element names that are declared as arrays.
|
java.util.Set<java.lang.String> |
getElementNames()
Returns the set of element names defined by this schema.
|
java.lang.String |
getElementType(java.lang.String elementName)
Returns the name of the Java type associated with the given element name.
|
java.util.Set<java.lang.String> |
getNonArrayElements()
Returns the element names that are declared to not be arrays.
|
DataPartitioner |
getPartitionerForElement(java.lang.String elementName)
Returns the partitioner instance for the given element name.
|
DataPartitioner |
getPartitionerInstance(java.lang.String partitionerTypeName)
Returns the partitioner corresponding to the given partitioner class name.
|
java.lang.String |
getPartitionerTypeName(java.lang.String elementName)
Returns the partitioner type name for a given element name.
|
java.lang.String |
getSchemaName()
Returns the name of this schema.
|
org.apache.hadoop.io.Text |
getTextName(java.lang.String elementName)
Returns the Hadoop text representation of a given element name.
|
boolean |
isArrayElement(java.lang.String element)
Returns true if the given element name is an array type.
|
public boolean containsElement(java.lang.String elementName)
elementName
- The element name to check.public java.util.Set<java.lang.String> getElementNames()
public java.lang.String getElementType(java.lang.String elementName)
The Java type is either a primitive type name, as defined in the PrimitiveTypePartitioner
, or a full canonical class name representing the element
type.
elementName
- The element name whose type is requested.null
if the schema does not define the given element name.PrimitiveTypePartitioner
public java.util.Set<java.lang.String> getArrayElements()
public java.util.Set<java.lang.String> getNonArrayElements()
public DataPartitioner getPartitionerForElement(java.lang.String elementName) throws PIRException
A partitioner for the named type is created on first request, and the same partitioner is returned on subsequent calls.
elementName
- the name of the element whose partitioner is required.null
if the element does not exist.PIRException
- if the partitioner cannot be instantiated.getPartitionerInstance(String)
public DataPartitioner getPartitionerInstance(java.lang.String partitionerTypeName) throws PIRException
A partitioner for the named type is created on first request, and the same partitioner is returned on subsequent calls to this method.
partitionerTypeName
- The class name for a partitioner type.PIRException
- If a problem occurs instantiating a new partitioner of the requested type.public java.lang.String getPartitionerTypeName(java.lang.String elementName)
The partitioner type name is either that of the primitive partitioner, where the element name is a primitive type. For non-primitives it is the fully
qualified name of a Java class that implements the DataPartitioner
interface.
elementName
- The element name whose partitioner type is requested.null
if there is no element of that name.public java.lang.String getSchemaName()
public org.apache.hadoop.io.Text getTextName(java.lang.String elementName)
elementName
- The name of the element whose text representation is requested.public boolean isArrayElement(java.lang.String element)
The method returns false
if the element is not an array type or the schema does not define an element of this type.
element
- The name of the element to test.true
if the element is an array type, and false
otherwise.