org.apache.nutch.crawl
Class MapWritable

java.lang.Object
  extended by org.apache.nutch.crawl.MapWritable
All Implemented Interfaces:
Writable

public class MapWritable
extends Object
implements Writable

A writable map, with a similar behavior as java.util.HashMap. In addition to the size of key and value writable tuple two additional bytes are stored to identify the Writable classes. This means that a maximum of 255 different class types can be used for key and value objects. A binary-id to class mapping is defined in a static block of this class. However it is possible to use custom implementations of Writable. For these custom Writables we write the byte id - utf class name tuple into the header of each MapWritable that uses these types.

Author:
Stefan Groschupf

Field Summary
static org.apache.commons.logging.Log LOG
           
 
Constructor Summary
MapWritable()
           
MapWritable(MapWritable map)
          Copy constructor.
 
Method Summary
 void clear()
           
 boolean containsKey(Writable key)
           
 boolean containsValue(Writable value)
           
 boolean equals(Object obj)
           
 Writable get(Writable key)
           
 int hashCode()
           
 boolean isEmpty()
           
 Set keySet()
           
 Writable put(Writable key, Writable value)
           
 void putAll(MapWritable map)
           
 void readFields(DataInput in)
          Reads the fields of this object from in.
 Writable remove(Writable key)
           
 int size()
           
 String toString()
           
 Collection values()
           
 void write(DataOutput out)
          Writes the fields of this object to out.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

LOG

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

MapWritable

public MapWritable()

MapWritable

public MapWritable(MapWritable map)
Copy constructor. This constructor makes a deep copy, using serialization / deserialization to break any possible references to contained objects.

Parameters:
map - map to copy from
Method Detail

clear

public void clear()

containsKey

public boolean containsKey(Writable key)

containsValue

public boolean containsValue(Writable value)

get

public Writable get(Writable key)

hashCode

public int hashCode()
Overrides:
hashCode in class Object

isEmpty

public boolean isEmpty()

keySet

public Set keySet()

put

public Writable put(Writable key,
                    Writable value)

putAll

public void putAll(MapWritable map)

remove

public Writable remove(Writable key)

size

public int size()

values

public Collection values()

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object

write

public void write(DataOutput out)
           throws IOException
Description copied from interface: Writable
Writes the fields of this object to out.

Specified by:
write in interface Writable
Throws:
IOException

readFields

public void readFields(DataInput in)
                throws IOException
Description copied from interface: Writable
Reads the fields of this object from in. For efficiency, implementations should attempt to re-use storage in the existing object where possible.

Specified by:
readFields in interface Writable
Throws:
IOException


Copyright © 2007, 2012, Oracle and/or its affiliates. All rights reserved.