kyotocabinet
Class MapReduce

Object
  extended by MapReduce

public abstract class MapReduce
extends Object

MapReduce framework.


Field Summary
static int XNOCOMP
          execution option: avoid compression of temporary databases
static int XNOLOCK
          execution option: avoid locking against update operations
 
Constructor Summary
MapReduce()
           
 
Method Summary
protected  boolean emit(byte[] key, byte[] value)
          Emit a record from the mapper.
 boolean execute(DB db, String tmppath, int opts)
          Execute the MapReduce process about a database.
 boolean log(String name, String message)
          Process a log message.
abstract  boolean map(byte[] key, byte[] value)
          Map a record data.
 boolean midprocess()
          Mediate between the map and the reduce phases.
 boolean postprocess()
          Postprocess the reduce operations.
 boolean preprocess()
          Preprocess the map operations.
abstract  boolean reduce(byte[] key, ValueIterator iter)
          Reduce a record data.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XNOCOMP

public static final int XNOCOMP
execution option: avoid compression of temporary databases

See Also:
Constant Field Values

XNOLOCK

public static final int XNOLOCK
execution option: avoid locking against update operations

See Also:
Constant Field Values
Constructor Detail

MapReduce

public MapReduce()
Method Detail

emit

protected boolean emit(byte[] key,
                       byte[] value)
Emit a record from the mapper.

Parameters:
key - specifies the key.
value - specifies the value.
Returns:
true on success, or false on failure.

execute

public boolean execute(DB db,
                       String tmppath,
                       int opts)
Execute the MapReduce process about a database.

Parameters:
db - the source database.
tmppath - the path of a directory for the temporary data storage. If it is an empty string, temporary data are handled on memory.
opts - the optional features by bitwise-or: MapReduce::XNOLOCK to avoid locking against update operations by other threads, MapReduce::XNOCOMP to avoid compression of temporary databases.
Returns:
true on success, or false on failure.

log

public boolean log(String name,
                   String message)
Process a log message.

Parameters:
name - the name of the event.
message - a supplement message.
Returns:
true on success, or false on failure.

map

public abstract boolean map(byte[] key,
                            byte[] value)
Map a record data.

Parameters:
key - specifies the key.
value - specifies the value.
Returns:
true on success, or false on failure.
Note:
This method can call the MapReduce::emit method to emit a record. To avoid deadlock, any explicit database operation must not be performed in this method.

midprocess

public boolean midprocess()
Mediate between the map and the reduce phases.

Returns:
true on success, or false on failure.
Note:
This method can call the MapReduce::emit method to emit a record. To avoid deadlock, any explicit database operation must not be performed in this method.

postprocess

public boolean postprocess()
Postprocess the reduce operations.

Returns:
true on success, or false on failure.
Note:
To avoid deadlock, any explicit database operation must not be performed in this method.

preprocess

public boolean preprocess()
Preprocess the map operations.

Returns:
true on success, or false on failure.
Note:
This method can call the MapReduce::emit method to emit a record. To avoid deadlock, any explicit database operation must not be performed in this method.

reduce

public abstract boolean reduce(byte[] key,
                               ValueIterator iter)
Reduce a record data.

Parameters:
key - specifies the key.
iter - the iterator to get the values.
Returns:
true on success, or false on failure.
Note:
To avoid deadlock, any explicit database operation must not be performed in this method.