edu.yale.cs.hadoopdb.util
Class ParseSchema
java.lang.Object
edu.yale.cs.hadoopdb.util.ParseSchema
public class ParseSchema
- extends java.lang.Object
This class accepts a schema represented as "field_name_1 field_type_1, ..."
and parses the result set according to the given schema. This avoids
other methods from having complete schema awareness. It also provides
helper methods to serialize values from the result set into a string.
Other helper methods include generating a create table with the given schema SQL
and inserting a row into the table after deserializing the values from a string.
Constructor Summary |
ParseSchema(java.lang.String schema)
|
Method Summary |
void |
deserializeRow(java.lang.String row,
java.sql.PreparedStatement ps)
|
java.lang.String |
getAsString(int index,
java.sql.ResultSet rs)
|
java.lang.String |
getAsString(java.lang.String label,
java.sql.ResultSet rs)
|
java.lang.String |
getCreateTableQuery(java.lang.String relation_id)
|
java.lang.String |
getInsertRowQuery(java.lang.String relation_id)
|
private java.lang.String |
getLabels()
|
java.lang.Class<? extends java.lang.Object> |
getType(int index)
|
java.lang.Class<? extends java.lang.Object> |
getType(java.lang.String label)
|
void |
insert(int colId,
java.lang.String value,
java.sql.PreparedStatement ps)
|
java.lang.String |
serializeRow(java.sql.ResultSet rs)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
cols
int cols
DELIMITER
public static final java.lang.String DELIMITER
- See Also:
- Constant Field Values
DELIMITER_REGEX
private static final java.lang.String DELIMITER_REGEX
- See Also:
- Constant Field Values
indexLabelMap
java.util.ArrayList<java.lang.String> indexLabelMap
indexTypeMap
java.util.ArrayList<java.lang.String> indexTypeMap
insert_query
java.lang.String insert_query
schema
java.lang.String schema
SPACE_REGEX
private static final java.lang.String SPACE_REGEX
- See Also:
- Constant Field Values
ParseSchema
public ParseSchema(java.lang.String schema)
deserializeRow
public void deserializeRow(java.lang.String row,
java.sql.PreparedStatement ps)
throws java.sql.SQLException
- Throws:
java.sql.SQLException
getAsString
public java.lang.String getAsString(int index,
java.sql.ResultSet rs)
throws java.sql.SQLException
- Throws:
java.sql.SQLException
getAsString
public java.lang.String getAsString(java.lang.String label,
java.sql.ResultSet rs)
throws java.sql.SQLException
- Throws:
java.sql.SQLException
getCreateTableQuery
public java.lang.String getCreateTableQuery(java.lang.String relation_id)
getInsertRowQuery
public java.lang.String getInsertRowQuery(java.lang.String relation_id)
getLabels
private java.lang.String getLabels()
getType
public java.lang.Class<? extends java.lang.Object> getType(int index)
getType
public java.lang.Class<? extends java.lang.Object> getType(java.lang.String label)
insert
public void insert(int colId,
java.lang.String value,
java.sql.PreparedStatement ps)
throws java.sql.SQLException
- Throws:
java.sql.SQLException
serializeRow
public java.lang.String serializeRow(java.sql.ResultSet rs)
throws java.sql.SQLException
- Throws:
java.sql.SQLException