Modifier and Type | Class and Description |
---|---|
static class |
Schema.ColumnSchema
Column Schema in Schema
|
static class |
Schema.ParsedName
Helper class to parse a column name string one section at a time and find
the required type for the parsed part.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
COLUMN_DELIMITER |
Constructor and Description |
---|
Schema()
Constructor - schema for empty schema (zero-column) .
|
Schema(boolean projection)
Constructor - schema for empty projection/schema (zero-column) .
|
Schema(Schema.ColumnSchema fs) |
Schema(java.lang.String schema)
Constructor - create a schema from a string representation.
|
Schema(java.lang.String[] columns)
Constructor - create a schema from an array of column names.
|
Schema(java.lang.String schema,
boolean projection) |
Modifier and Type | Method and Description |
---|---|
void |
add(Schema.ColumnSchema f)
add a column
|
int |
compareTo(Schema other) |
boolean |
equals(java.lang.Object obj) |
Schema.ColumnSchema |
getColumn(int index)
Get a particular column's schema
|
Schema.ColumnSchema |
getColumn(java.lang.String name)
get a column by name
|
int |
getColumnIndex(java.lang.String name)
Get the index of the column for the input column name.
|
java.lang.String |
getColumnName(int index) |
java.lang.String[] |
getColumns()
Get the names of the individual columns.
|
Schema.ColumnSchema |
getColumnSchema(Schema.ParsedName pn)
find the most fitting subcolumn containing the name: the parsed name is set
after the field name plus any possible separator of '.' or '#'.
|
Schema.ColumnSchema |
getColumnSchema(java.lang.String name)
Get a column's schema
|
Schema.ColumnSchema |
getColumnSchemaOnParsedName(Schema.ParsedName pn)
Get a subcolumn's schema and move the name just parsed into the next subtype
|
int |
getNumColumns()
Get the number of columns as defined in the schema.
|
Schema |
getProjectionSchema(java.lang.String[] projcols,
java.util.HashMap<Schema.ColumnSchema,java.util.HashSet<java.lang.String>> keysmap)
Get a projection's schema
|
java.lang.String[] |
getTypedColumns()
Get the names and types of the individual columns.
|
static java.lang.String |
normalize(java.lang.String value)
Normalize the schema string.
|
static Schema |
parse(java.lang.String schema)
Parse a schema string and create a schema object.
|
void |
readFields(java.io.DataInput in) |
java.lang.String |
toProjectionString()
return untyped schema string for projection
|
java.lang.String |
toString()
Convert the schema to a String.
|
void |
unionSchema(Schema other)
union compatible schemas.
|
void |
write(java.io.DataOutput out) |
public static final java.lang.String COLUMN_DELIMITER
public Schema()
public Schema(boolean projection)
projection
- A projection schema or notpublic Schema(java.lang.String schema) throws org.apache.hadoop.zebra.parser.ParseException
schema
- A string representation of the schema. For this version, the
schema string is simply a comma separated list of column names. Of
course, comma (,) and space characters are illegal in column
names. To maintain forward compatibility, please use only
alpha-numeric characters in column names.org.apache.hadoop.zebra.parser.ParseException
public Schema(java.lang.String schema, boolean projection) throws org.apache.hadoop.zebra.parser.ParseException
org.apache.hadoop.zebra.parser.ParseException
public Schema(Schema.ColumnSchema fs) throws org.apache.hadoop.zebra.parser.ParseException
org.apache.hadoop.zebra.parser.ParseException
public Schema(java.lang.String[] columns) throws org.apache.hadoop.zebra.parser.ParseException
columns
- An array of column names. To maintain forward compatibility,
please use only alpha-numeric characters in column names.org.apache.hadoop.zebra.parser.ParseException
public void add(Schema.ColumnSchema f) throws org.apache.hadoop.zebra.parser.ParseException
f
- Column to be added to the schemaorg.apache.hadoop.zebra.parser.ParseException
public Schema.ColumnSchema getColumn(java.lang.String name)
public java.lang.String[] getColumns()
public Schema.ColumnSchema getColumn(int index)
public java.lang.String getColumnName(int index)
public java.lang.String[] getTypedColumns()
public int getColumnIndex(java.lang.String name)
name
- input column name.public int getNumColumns()
public static Schema parse(java.lang.String schema) throws org.apache.hadoop.zebra.parser.ParseException
schema
- comma separated schema string.org.apache.hadoop.zebra.parser.ParseException
public java.lang.String toString()
toString
in class java.lang.Object
public static java.lang.String normalize(java.lang.String value)
value
- the input string representation of the schema.public int compareTo(Schema other)
compareTo
in interface java.lang.Comparable<Schema>
Comparable.compareTo(Object)
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
Object.equals(Object)
public void readFields(java.io.DataInput in) throws java.io.IOException
readFields
in interface org.apache.hadoop.io.Writable
java.io.IOException
Writable.readFields(DataInput)
public void write(java.io.DataOutput out) throws java.io.IOException
write
in interface org.apache.hadoop.io.Writable
java.io.IOException
Writable.write(DataOutput)
public Schema getProjectionSchema(java.lang.String[] projcols, java.util.HashMap<Schema.ColumnSchema,java.util.HashSet<java.lang.String>> keysmap) throws org.apache.hadoop.zebra.parser.ParseException
org.apache.hadoop.zebra.parser.ParseException
public Schema.ColumnSchema getColumnSchema(java.lang.String name) throws org.apache.hadoop.zebra.parser.ParseException
name
- column nameorg.apache.hadoop.zebra.parser.ParseException
public Schema.ColumnSchema getColumnSchemaOnParsedName(Schema.ParsedName pn) throws org.apache.hadoop.zebra.parser.ParseException
pn
- The name of subcolumn to be parsed. On return it contains the
subcolumn at the next level after parsingorg.apache.hadoop.zebra.parser.ParseException
public Schema.ColumnSchema getColumnSchema(Schema.ParsedName pn) throws org.apache.hadoop.zebra.parser.ParseException
pn
- The name of subcolumn to be parsed. On return it contains the
subcolumn at the next level after parsingorg.apache.hadoop.zebra.parser.ParseException
public void unionSchema(Schema other) throws org.apache.hadoop.zebra.parser.ParseException
org.apache.hadoop.zebra.parser.ParseException
public java.lang.String toProjectionString()
Copyright © 2007-2012 The Apache Software Foundation