org.apache.hadoop.zebra.io
Class BasicTable.Writer

java.lang.Object
  extended by org.apache.hadoop.zebra.io.BasicTable.Writer
All Implemented Interfaces:
Closeable
Enclosing class:
BasicTable

public static class BasicTable.Writer
extends Object
implements Closeable

BasicTable writer.


Constructor Summary
BasicTable.Writer(org.apache.hadoop.fs.Path path, org.apache.hadoop.conf.Configuration conf)
          Reopen an already created BasicTable for writing.
BasicTable.Writer(org.apache.hadoop.fs.Path path, String btSchemaString, String btStorageString, org.apache.hadoop.conf.Configuration conf)
          a wrapper to support backward compatible constructor
BasicTable.Writer(org.apache.hadoop.fs.Path path, String btSchemaString, String btStorageString, String sortColumns, String comparator, org.apache.hadoop.conf.Configuration conf)
          Create a BasicTable writer.
 
Method Summary
 void close()
          Close the BasicTable for writing.
 DataOutputStream createMetaBlock(String name)
          Obtain an output stream for creating a Meta Block with the specific name.
 void finish()
          Release resources used by the object.
 TableInserter getInserter(String name, boolean finishWriter)
          Get a inserter with a given name.
 TableInserter getInserter(String name, boolean finishWriter, boolean checkType)
          Get a inserter with a given name.
 Schema getSchema()
          Get the schema of the table.
 SortInfo getSortInfo()
          Get the list of sorted columns.
 boolean isSorted()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicTable.Writer

public BasicTable.Writer(org.apache.hadoop.fs.Path path,
                         String btSchemaString,
                         String btStorageString,
                         String sortColumns,
                         String comparator,
                         org.apache.hadoop.conf.Configuration conf)
                  throws IOException
Create a BasicTable writer. The semantics are as follows:
  1. If path does not exist:
    • create the path directory, and initialize the directory for future row insertion..
  2. If path exists and the directory is empty: initialize the directory for future row insertion.
  3. If path exists and contains what look like a complete BasicTable, IOException will be thrown.
This constructor never removes a valid/complete BasicTable.

Parameters:
path - The path to the Basic Table, either not existent or must be a directory.
btSchemaString - The schema of the Basic Table. For this version of implementation, the schema of a table is a comma or semicolon-separated list of column names, such as "FirstName, LastName; Sex, Department".
sortColumns - String of comma-separated sorted columns: null for unsorted tables
comparator - Name of the comparator used in sorted tables
conf - Optional Configuration objects.
Throws:
IOException
See Also:
Schema

BasicTable.Writer

public BasicTable.Writer(org.apache.hadoop.fs.Path path,
                         String btSchemaString,
                         String btStorageString,
                         org.apache.hadoop.conf.Configuration conf)
                  throws IOException
a wrapper to support backward compatible constructor

Throws:
IOException

BasicTable.Writer

public BasicTable.Writer(org.apache.hadoop.fs.Path path,
                         org.apache.hadoop.conf.Configuration conf)
                  throws IOException
Reopen an already created BasicTable for writing. Exception will be thrown if the table is already closed, or is in the process of being closed.

Throws:
IOException
Method Detail

finish

public void finish()
            throws IOException
Release resources used by the object. Unlike close(), finish() does not make the table immutable.

Throws:
IOException

close

public void close()
           throws IOException
Close the BasicTable for writing. No more inserters can be obtained after close().

Specified by:
close in interface Closeable
Throws:
IOException

getSchema

public Schema getSchema()
Get the schema of the table.

Returns:
the Schema object.

isSorted

public boolean isSorted()
Returns:
sortness

getSortInfo

public SortInfo getSortInfo()
Get the list of sorted columns.

Returns:
the list of sorted columns

getInserter

public TableInserter getInserter(String name,
                                 boolean finishWriter)
                          throws IOException
Get a inserter with a given name.

Parameters:
name - the name of the inserter. If multiple calls to getInserter with the same name has been called, we expect they are the result of speculative execution and at most one of them will succeed.
finishWriter - finish the underlying Writer object upon the close of the Inserter. Should be set to true if there is only one inserter operate on the table, so we should call finish() after the Inserter is closed.
Returns:
A inserter object.
Throws:
IOException

getInserter

public TableInserter getInserter(String name,
                                 boolean finishWriter,
                                 boolean checkType)
                          throws IOException
Get a inserter with a given name.

Parameters:
name - the name of the inserter. If multiple calls to getInserter with the same name has been called, we expect they are the result of speculative execution and at most one of them will succeed.
finishWriter - finish the underlying Writer object upon the close of the Inserter. Should be set to true if there is only one inserter operate on the table, so we should call finish() after the Inserter is closed.
checktype - whether or not do type check.
Returns:
A inserter object.
Throws:
IOException

createMetaBlock

public DataOutputStream createMetaBlock(String name)
                                 throws MetaBlockAlreadyExists,
                                        IOException
Obtain an output stream for creating a Meta Block with the specific name. This method can only be called after we insert all rows into the table. All Meta Blocks must be created by a single process prior to closing the table. No more inserter can be created after this call.

Parameters:
name - The name of the Meta Block
Returns:
The output stream. Close the stream to conclude the writing.
Throws:
IOException
MetaBlockAlreadyExists


Copyright © 2012 The Apache Software Foundation