org.apache.mahout.common
Class StringTuple

java.lang.Object
  extended by org.apache.mahout.common.StringTuple
All Implemented Interfaces:
Comparable<StringTuple>, org.apache.hadoop.io.Writable, org.apache.hadoop.io.WritableComparable<StringTuple>

public final class StringTuple
extends Object
implements org.apache.hadoop.io.WritableComparable<StringTuple>

An Ordered List of Strings which can be used in a Hadoop Map/Reduce Job


Constructor Summary
StringTuple()
           
StringTuple(Iterable<String> entries)
           
StringTuple(String firstEntry)
           
StringTuple(String[] entries)
           
 
Method Summary
 boolean add(String entry)
          add an entry to the end of the list
 int compareTo(StringTuple otherTuple)
           
 boolean equals(Object obj)
           
 List<String> getEntries()
          Fetch the list of entries from the tuple
 int hashCode()
           
 int length()
          Returns the length of the tuple
 void readFields(DataInput in)
           
 String replaceAt(int index, String newString)
          Replaces the string at the given index with the given newString
 String stringAt(int index)
          Fetches the string at the given location
 String toString()
           
 void write(DataOutput out)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StringTuple

public StringTuple()

StringTuple

public StringTuple(String firstEntry)

StringTuple

public StringTuple(Iterable<String> entries)

StringTuple

public StringTuple(String[] entries)
Method Detail

add

public boolean add(String entry)
add an entry to the end of the list

Parameters:
entry -
Returns:
true if the items get added

stringAt

public String stringAt(int index)
Fetches the string at the given location

Parameters:
index -
Returns:
String value at the given location in the tuple list

replaceAt

public String replaceAt(int index,
                        String newString)
Replaces the string at the given index with the given newString

Parameters:
index -
newString -
Returns:
The previous value at that location

getEntries

public List<String> getEntries()
Fetch the list of entries from the tuple

Returns:
a List containing the strings in the order of insertion

length

public int length()
Returns the length of the tuple

Returns:
length

toString

public String toString()
Overrides:
toString in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

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

readFields

public void readFields(DataInput in)
                throws IOException
Specified by:
readFields in interface org.apache.hadoop.io.Writable
Throws:
IOException

write

public void write(DataOutput out)
           throws IOException
Specified by:
write in interface org.apache.hadoop.io.Writable
Throws:
IOException

compareTo

public int compareTo(StringTuple otherTuple)
Specified by:
compareTo in interface Comparable<StringTuple>


Copyright © 2008–2014 The Apache Software Foundation. All rights reserved.