Skip to content

Commit

Permalink
Fixed warnings in Javadoc target
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvainhalle committed Jan 16, 2015
1 parent 42103ac commit 4c8b38a
Show file tree
Hide file tree
Showing 10 changed files with 524 additions and 519 deletions.
244 changes: 122 additions & 122 deletions Source/MapReduce/src/ca/uqac/dim/mapreduce/Collector.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,134 +22,134 @@
* Data source used both as the input and output of the map and reduce
* phases. A Collector can be used to:
* <ol>
* <li>Store data tuples using the {@link collect} method</li>
* <li>Enumerate data tuples using the {@link hasNext} and {@link next}
* methods, like an {@link Iterator}</li>
* <li>Store data tuples using the {@link Collector#collect(Tuple)} method</li>
* <li>Enumerate data tuples using the {@link Collector#hasNext()}
* and {@link Collector#next()} methods, like an {@link Iterator}</li>
* <li>Partition the set of tuples into a set of Collectors, grouping
* tuples by their key, using the {@link subCollector} and
* {@link subCollectors} methods</li>
* tuples by their key, using the {@link Collector#subCollector(Object)} and
* {@link Collector#subCollectors()} methods</li>
* </ol>
* @author Sylvain Hallé
* @version 1.1
*
*/
public class Collector<K,V> implements InCollector<K,V>, OutCollector<K,V>
{
private List<Tuple<K,V>> m_tuples = new LinkedList<Tuple<K,V>>();
private Iterator<Tuple<K,V>> m_it = null;
/**
* Return the Collector's contents as a list of tuples
* @return The list of tuples
*/
public List<Tuple<K,V>> toList()
{
return m_tuples;
}
/**
* Add a collection of tuples to the Collector
* @param list A collection of {@link Tuple}
*/
public void addAll(Collection<Tuple<K,V>> list)
{
synchronized (this) {
m_tuples.addAll(list);
}
}
/**
* Add a new tuple to the Collector in a synchronized mode
* @param t The {@link Tuple} to add
*/
public void collect(Tuple<K,V> t)
{
synchronized (this) {
m_tuples.add(t);
}
}
/**
* Returns a new Collector whose content is made of all tuples with
* given key
* @param key The key to find
* @return A new {@link Collector}
*/
public Collector<K,V> subCollector(K key)
{
Collector<K,V> c = new Collector<K,V>();
synchronized (this) {
for (Tuple<K,V> t : m_tuples)
{
if (t.getKey().equals(key))
c.m_tuples.add(t);
}
}
return c;
}
public int count()
{
synchronized (this) {
return m_tuples.size();
}
}
/**
* Partitions the set of tuples into new collectors, each containing all
* tuples with the same key
* @return A map from keys to Collectors
*/
public Map<K,Collector<K,V>> subCollectors()
{
Map<K,Collector<K,V>> out = new HashMap<K,Collector<K,V>>();
synchronized (this) {
for ( Tuple<K,V> t : m_tuples)
{
K key = t.getKey();
Collector<K,V> c = out.get(key);
if (c == null)
c = new Collector<K,V>();
c.collect(t);
out.put(key, c);
}
}
return out;
}

@Override
public boolean hasNext()
{
if (m_it == null)
m_it = m_tuples.iterator();
return m_it.hasNext();
}

@Override
public Tuple<K,V> next()
{
return m_it.next();
}

@Override
public void remove()
{
m_it.remove();
}
@Override
public String toString()
{
return m_tuples.toString();
}

@Override
public void rewind()
{
m_it = null;
}
private List<Tuple<K,V>> m_tuples = new LinkedList<Tuple<K,V>>();
private Iterator<Tuple<K,V>> m_it = null;

/**
* Return the Collector's contents as a list of tuples
* @return The list of tuples
*/
public List<Tuple<K,V>> toList()
{
return m_tuples;
}

/**
* Add a collection of tuples to the Collector
* @param list A collection of {@link Tuple}
*/
public void addAll(Collection<Tuple<K,V>> list)
{
synchronized (this) {
m_tuples.addAll(list);
}
}

/**
* Add a new tuple to the Collector in a synchronized mode
* @param t The {@link Tuple} to add
*/
public void collect(Tuple<K,V> t)
{
synchronized (this) {
m_tuples.add(t);
}
}

/**
* Returns a new Collector whose content is made of all tuples with
* given key
* @param key The key to find
* @return A new {@link Collector}
*/
public Collector<K,V> subCollector(K key)
{
Collector<K,V> c = new Collector<K,V>();
synchronized (this) {
for (Tuple<K,V> t : m_tuples)
{
if (t.getKey().equals(key))
c.m_tuples.add(t);
}
}
return c;

}

public int count()
{
synchronized (this) {
return m_tuples.size();
}
}

/**
* Partitions the set of tuples into new collectors, each containing all
* tuples with the same key
* @return A map from keys to Collectors
*/
public Map<K,Collector<K,V>> subCollectors()
{
Map<K,Collector<K,V>> out = new HashMap<K,Collector<K,V>>();

synchronized (this) {
for ( Tuple<K,V> t : m_tuples)
{
K key = t.getKey();
Collector<K,V> c = out.get(key);

if (c == null)
c = new Collector<K,V>();

c.collect(t);
out.put(key, c);
}
}
return out;
}

@Override
public boolean hasNext()
{
if (m_it == null)
m_it = m_tuples.iterator();
return m_it.hasNext();
}

@Override
public Tuple<K,V> next()
{
return m_it.next();
}

@Override
public void remove()
{
m_it.remove();
}

@Override
public String toString()
{
return m_tuples.toString();
}

@Override
public void rewind()
{
m_it = null;
}
}
4 changes: 2 additions & 2 deletions Source/MapReduce/src/ca/uqac/dim/mapreduce/InCollector.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
/**
* Data source used as the input of the map and reduce
* phases. An InCollector can be used to enumerate data
* tuples using the {@link hasNext} and {@link next}
* methods, like an {@link Iterator}.
* tuples using the {@link Collector#hasNext()} and
* {@link Collector#next()} methods, like an {@link Iterator}.
*
* @author Sylvain Hallé
* @version 1.0
Expand Down
2 changes: 1 addition & 1 deletion Source/MapReduce/src/ca/uqac/dim/mapreduce/Mapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public interface Mapper<K,V>
{
/**
* Map function
* @param out A {@link OutCollector} that will be used to write output tuples
* @param c A {@link OutCollector} that will be used to write output tuples
* @param t A {@link Tuple} to process
*/
public void map(OutCollector<K,V> c, Tuple<K,V> t);
Expand Down
3 changes: 2 additions & 1 deletion Source/MapReduce/src/ca/uqac/dim/mapreduce/OutCollector.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
/**
* Data source used as the output of the map and reduce
* phases. An OutCollector can be used to
* store data tuples using the {@link collect} method.
* store data tuples using the {@link OutCollector#collect(Tuple)}
* method.
*
* @author Sylvain Hallé
* @version 1.1
Expand Down
Loading

0 comments on commit 4c8b38a

Please sign in to comment.