com.cloudera.sqoop.io
Class LobReaderCache

java.lang.Object
  extended by com.cloudera.sqoop.io.LobReaderCache

public final class LobReaderCache
extends java.lang.Object

A cache of open LobFile.Reader objects. This maps from filenames to the open Reader, if any. This uses the Singleton pattern. While nothing prevents multiple LobReaderCache instances, it is most useful to have a single global cache. This cache is internally synchronized; only one thread can insert or retrieve a reader from the cache at a time.


Field Summary
static org.apache.commons.logging.Log LOG
           
 
Method Summary
protected  void finalize()
           
 LobFile.Reader get(org.apache.hadoop.fs.Path path, org.apache.hadoop.conf.Configuration conf)
          Open a LobFile for read access, returning a cached reader if one is available, or a new reader otherwise.
static LobReaderCache getCache()
           
static org.apache.hadoop.fs.Path qualify(org.apache.hadoop.fs.Path path, org.apache.hadoop.conf.Configuration conf)
          Created a fully-qualified path object.
 void recycle(LobFile.Reader reader)
          Return a reader back to the cache.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

public static final org.apache.commons.logging.Log LOG
Method Detail

getCache

public static LobReaderCache getCache()
Returns:
the singleton LobReaderCache instance.

qualify

public static org.apache.hadoop.fs.Path qualify(org.apache.hadoop.fs.Path path,
                                                org.apache.hadoop.conf.Configuration conf)
                                         throws java.io.IOException
Created a fully-qualified path object.

Parameters:
path - the path to fully-qualify with its fs URI.
conf - the current Hadoop FS configuration.
Returns:
a new path representing the same location as the input 'path', but with a fully-qualified URI.
Throws:
java.io.IOException

get

public LobFile.Reader get(org.apache.hadoop.fs.Path path,
                          org.apache.hadoop.conf.Configuration conf)
                   throws java.io.IOException
Open a LobFile for read access, returning a cached reader if one is available, or a new reader otherwise.

Parameters:
path - the path to the LobFile to open
conf - the configuration to use to access the FS.
Throws:
java.io.IOException - if there's an error opening the file.

recycle

public void recycle(LobFile.Reader reader)
             throws java.io.IOException
Return a reader back to the cache. If there's already a reader for this path, then the current reader is closed.

Parameters:
reader - the opened reader. Any record-specific subreaders should be closed.
Throws:
java.io.IOException - if there's an error accessing the path's filesystem.

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable


Copyright © 2010 Cloudera, Inc.