This project has retired. For details please refer to its Attic page.
FileBackedDataStoreBase (Apache Gora 0.2 API)

org.apache.gora.store.impl
Class FileBackedDataStoreBase<K,T extends Persistent>

java.lang.Object
  extended by org.apache.gora.store.impl.DataStoreBase<K,T>
      extended by org.apache.gora.store.impl.FileBackedDataStoreBase<K,T>
All Implemented Interfaces:
Closeable, DataStore<K,T>, FileBackedDataStore<K,T>, org.apache.hadoop.conf.Configurable, org.apache.hadoop.io.Writable
Direct Known Subclasses:
AvroStore

public abstract class FileBackedDataStoreBase<K,T extends Persistent>
extends DataStoreBase<K,T>
implements FileBackedDataStore<K,T>

Base implementations for FileBackedDataStore methods.


Field Summary
protected  String inputPath
           
protected  long inputSize
           
protected  InputStream inputStream
           
protected  String outputPath
           
protected  OutputStream outputStream
           
 
Fields inherited from class org.apache.gora.store.impl.DataStoreBase
autoCreateSchema, beanFactory, conf, datumReader, datumWriter, fieldMap, keyClass, persistentClass, properties, schema
 
Constructor Summary
FileBackedDataStoreBase()
           
 
Method Summary
 void close()
          Close the DataStore.
protected  InputStream createInputStream()
          Opens an InputStream for the input Hadoop path
protected  OutputStream createOutputStream()
          Opens an OutputStream for the output Hadoop path
 void createSchema()
          Creates the optional schema or table (or similar) in the datastore to hold the objects.
 void deleteSchema()
          Deletes the underlying schema or table (or similar) in the datastore that holds the objects.
 Result<K,T> execute(Query<K,T> query)
          Executes the given query and returns the results.
protected abstract  Result<K,T> executePartial(FileSplitPartitionQuery<K,T> query)
          Executes a PartitialQuery, reading the data between start and end.
protected abstract  Result<K,T> executeQuery(Query<K,T> query)
          Executes a normal Query reading the whole data.
 void flush()
          Forces the write caches to be flushed.
 String getInputPath()
           
 InputStream getInputStream()
           
protected  InputStream getOrCreateInputStream()
           
protected  OutputStream getOrCreateOutputStream()
           
 String getOutputPath()
           
 OutputStream getOutputStream()
           
 List<PartitionQuery<K,T>> getPartitions(Query<K,T> query)
          Partitions the given query and returns a list of PartitionQuerys, which will execute on local data.
 void initialize(Class<K> keyClass, Class<T> persistentClass, Properties properties)
          Initializes this DataStore.
 void readFields(DataInput in)
           
 boolean schemaExists()
          Returns whether the schema that holds the data exists in the datastore.
 void setInputPath(String inputPath)
           
 void setInputStream(InputStream inputStream)
           
 void setOutputPath(String outputPath)
           
 void setOutputStream(OutputStream outputStream)
           
 void write(DataOutput out)
           
 
Methods inherited from class org.apache.gora.store.impl.DataStoreBase
equals, get, getBeanFactory, getConf, getFieldsToQuery, getKeyClass, getOrCreateConf, getPersistentClass, getSchemaName, newKey, newPersistent, setBeanFactory, setConf, setKeyClass, setPersistentClass, truncateSchema
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.gora.store.DataStore
delete, deleteByQuery, get, get, getBeanFactory, getConf, getKeyClass, getPersistentClass, getSchemaName, newKey, newPersistent, newQuery, put, setBeanFactory, setConf, setKeyClass, setPersistentClass, truncateSchema
 

Field Detail

inputSize

protected long inputSize

inputPath

protected String inputPath

outputPath

protected String outputPath

inputStream

protected InputStream inputStream

outputStream

protected OutputStream outputStream
Constructor Detail

FileBackedDataStoreBase

public FileBackedDataStoreBase()
Method Detail

initialize

public void initialize(Class<K> keyClass,
                       Class<T> persistentClass,
                       Properties properties)
                throws IOException
Description copied from interface: DataStore
Initializes this DataStore.

Specified by:
initialize in interface DataStore<K,T extends Persistent>
Overrides:
initialize in class DataStoreBase<K,T extends Persistent>
Parameters:
keyClass - the class of the keys
persistentClass - the class of the persistent objects
properties - extra metadata
Throws:
IOException

setInputPath

public void setInputPath(String inputPath)
Specified by:
setInputPath in interface FileBackedDataStore<K,T extends Persistent>

setOutputPath

public void setOutputPath(String outputPath)
Specified by:
setOutputPath in interface FileBackedDataStore<K,T extends Persistent>

getInputPath

public String getInputPath()
Specified by:
getInputPath in interface FileBackedDataStore<K,T extends Persistent>

getOutputPath

public String getOutputPath()
Specified by:
getOutputPath in interface FileBackedDataStore<K,T extends Persistent>

setInputStream

public void setInputStream(InputStream inputStream)
Specified by:
setInputStream in interface FileBackedDataStore<K,T extends Persistent>

setOutputStream

public void setOutputStream(OutputStream outputStream)
Specified by:
setOutputStream in interface FileBackedDataStore<K,T extends Persistent>

getInputStream

public InputStream getInputStream()
Specified by:
getInputStream in interface FileBackedDataStore<K,T extends Persistent>

getOutputStream

public OutputStream getOutputStream()
Specified by:
getOutputStream in interface FileBackedDataStore<K,T extends Persistent>

createInputStream

protected InputStream createInputStream()
                                 throws IOException
Opens an InputStream for the input Hadoop path

Throws:
IOException

createOutputStream

protected OutputStream createOutputStream()
                                   throws IOException
Opens an OutputStream for the output Hadoop path

Throws:
IOException

getOrCreateInputStream

protected InputStream getOrCreateInputStream()
                                      throws IOException
Throws:
IOException

getOrCreateOutputStream

protected OutputStream getOrCreateOutputStream()
                                        throws IOException
Throws:
IOException

getPartitions

public List<PartitionQuery<K,T>> getPartitions(Query<K,T> query)
                                                           throws IOException
Description copied from interface: DataStore
Partitions the given query and returns a list of PartitionQuerys, which will execute on local data.

Specified by:
getPartitions in interface DataStore<K,T extends Persistent>
Parameters:
query - the base query to create the partitions for. If the query is null, then the data store returns the partitions for the default query (returning every object)
Returns:
a List of PartitionQuery's
Throws:
IOException

execute

public Result<K,T> execute(Query<K,T> query)
                                       throws IOException
Description copied from interface: DataStore
Executes the given query and returns the results.

Specified by:
execute in interface DataStore<K,T extends Persistent>
Parameters:
query - the query to execute.
Returns:
the results as a Result object.
Throws:
IOException

executeQuery

protected abstract Result<K,T> executeQuery(Query<K,T> query)
                                                        throws IOException
Executes a normal Query reading the whole data. #execute() calls this function for non-PartitionQuery's.

Throws:
IOException

executePartial

protected abstract Result<K,T> executePartial(FileSplitPartitionQuery<K,T> query)
                                                          throws IOException
Executes a PartitialQuery, reading the data between start and end.

Throws:
IOException

flush

public void flush()
           throws IOException
Description copied from interface: DataStore
Forces the write caches to be flushed. DataStore implementations may optimize their writing by deferring the actual put / delete operations until this moment. See also the note on visibility.

Specified by:
flush in interface DataStore<K,T extends Persistent>
Throws:
IOException

createSchema

public void createSchema()
                  throws IOException
Description copied from interface: DataStore
Creates the optional schema or table (or similar) in the datastore to hold the objects. If the schema is already created previously, or the underlying data model does not support or need this operation, the operation is ignored.

Specified by:
createSchema in interface DataStore<K,T extends Persistent>
Throws:
IOException

deleteSchema

public void deleteSchema()
                  throws IOException
Description copied from interface: DataStore
Deletes the underlying schema or table (or similar) in the datastore that holds the objects. This also deletes all the data associated with the schema.

Specified by:
deleteSchema in interface DataStore<K,T extends Persistent>
Throws:
IOException

schemaExists

public boolean schemaExists()
                     throws IOException
Description copied from interface: DataStore
Returns whether the schema that holds the data exists in the datastore.

Specified by:
schemaExists in interface DataStore<K,T extends Persistent>
Returns:
whether schema exists
Throws:
IOException

write

public void write(DataOutput out)
           throws IOException
Specified by:
write in interface DataStore<K,T extends Persistent>
Specified by:
write in interface org.apache.hadoop.io.Writable
Overrides:
write in class DataStoreBase<K,T extends Persistent>
Throws:
IOException

readFields

public void readFields(DataInput in)
                throws IOException
Specified by:
readFields in interface DataStore<K,T extends Persistent>
Specified by:
readFields in interface org.apache.hadoop.io.Writable
Overrides:
readFields in class DataStoreBase<K,T extends Persistent>
Throws:
IOException

close

public void close()
           throws IOException
Description copied from interface: DataStore
Close the DataStore. This should release any resources held by the implementation, so that the instance is ready for GC. All other DataStore methods cannot be used after this method was called. Subsequent calls of this method are ignored.

Specified by:
close in interface Closeable
Specified by:
close in interface DataStore<K,T extends Persistent>
Throws:
IOException


Copyright © 2010-2013 The Apache Software Foundation. All Rights Reserved.