org.metastatic.rsync
Class MappedRebuilderStream

java.lang.Object
  |
  +--org.metastatic.rsync.RebuilderStream
        |
        +--org.metastatic.rsync.MappedRebuilderStream

public class MappedRebuilderStream
extends RebuilderStream

A version of RebuilderStream that maps large files to memory using the NIO API. Small files are not mapped and automatically use the superclass's implementation.


Field Summary
static int MAP_LIMIT
          The default lower bound for files to map.
protected  long mapLimit
          The lower bound file length to map; files smaller than this will not be mapped.
protected  long mapOffset
          The current offset in the file where the region is mapped.
protected  MappedByteBuffer mappedFile
          The mapped file, if any.
protected  long mapSize
          The size of the map.
 
Fields inherited from class org.metastatic.rsync.RebuilderStream
basisFile, listeners
 
Constructor Summary
MappedRebuilderStream()
          Create a new memory mapped rebuilder, with the default map limit and a maximum map size of Integer.MAX_VALUE.
MappedRebuilderStream(long mapLimit)
          Create a new memory mapped rebuilder with the given map limit and a maximum map size of Integer.MAX_VALUE.
MappedRebuilderStream(long mapSize, long mapLimit)
          Create a new memory mapped rebuilder with the given map limit and maximum map size.
 
Method Summary
 void setBasisFile(File file)
          Set the basis file.
 void setBasisFile(String filename)
          Set the basis file.
 void update(Delta delta)
          Update this rebuilder with a delta.
 
Methods inherited from class org.metastatic.rsync.RebuilderStream
addListener, doFinal, removeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAP_LIMIT

public static final int MAP_LIMIT
The default lower bound for files to map.

See Also:
Constant Field Values

mapSize

protected long mapSize
The size of the map. If not specified, the entire file is mapped.


mapLimit

protected long mapLimit
The lower bound file length to map; files smaller than this will not be mapped.


mappedFile

protected MappedByteBuffer mappedFile
The mapped file, if any.


mapOffset

protected long mapOffset
The current offset in the file where the region is mapped.

Constructor Detail

MappedRebuilderStream

public MappedRebuilderStream()
Create a new memory mapped rebuilder, with the default map limit and a maximum map size of Integer.MAX_VALUE.


MappedRebuilderStream

public MappedRebuilderStream(long mapLimit)
Create a new memory mapped rebuilder with the given map limit and a maximum map size of Integer.MAX_VALUE.

Parameters:
mapLimit - The smallest file size to map.

MappedRebuilderStream

public MappedRebuilderStream(long mapSize,
                             long mapLimit)
Create a new memory mapped rebuilder with the given map limit and maximum map size.

Parameters:
mapSize - The maximum size of map to create.
mapLimit - The smallest file size to map.
Method Detail

setBasisFile

public void setBasisFile(File file)
                  throws IOException
Description copied from class: RebuilderStream
Set the basis file.

Overrides:
setBasisFile in class RebuilderStream
Parameters:
file - The basis file.
Throws:
IOException - If the file is not readable.

setBasisFile

public void setBasisFile(String filename)
                  throws IOException
Description copied from class: RebuilderStream
Set the basis file.

Overrides:
setBasisFile in class RebuilderStream
Parameters:
filename - The basis file name.
Throws:
IOException - If the file name is not the name of a readable file.

update

public void update(Delta delta)
            throws IOException,
                   ListenerException
Description copied from class: RebuilderStream
Update this rebuilder with a delta.

Overrides:
update in class RebuilderStream
Parameters:
delta - The delta to apply.
Throws:
IOException - If there is an error reading from the basis file, or if no basis file has been specified.
ListenerException