1
|
package eu.dnetlib.data.mapreduce.hbase.propagation;
|
2
|
|
3
|
import eu.dnetlib.data.proto.OafProtos;
|
4
|
import org.apache.hadoop.io.Text;
|
5
|
|
6
|
import java.util.Iterator;
|
7
|
import java.util.List;
|
8
|
|
9
|
|
10
|
public abstract class ResultIterator implements Iterator<List<OafProtos.Oaf>>{
|
11
|
|
12
|
protected Iterator<Text> it;
|
13
|
protected int key;
|
14
|
protected String keyb;
|
15
|
protected String resultId;
|
16
|
protected boolean propagate = true;
|
17
|
protected final static String TERMINATOR = "FINITO";
|
18
|
protected String trust = null;
|
19
|
|
20
|
public ResultIterator(final Iterable<Text> values, int key) throws NotValidResultSequenceException {
|
21
|
it = values.iterator();
|
22
|
this.key = key;
|
23
|
checkSequence();
|
24
|
}
|
25
|
|
26
|
public ResultIterator(final Iterable<Text> values, final String key) throws NotValidResultSequenceException {
|
27
|
it = values.iterator();
|
28
|
this.keyb = key;
|
29
|
checkSequence();
|
30
|
}
|
31
|
|
32
|
protected abstract void checkSequence() throws NotValidResultSequenceException ;
|
33
|
public abstract List<OafProtos.Oaf> next() ;
|
34
|
|
35
|
public boolean hasNext(){
|
36
|
return (!resultId.equals(TERMINATOR) && propagate);
|
37
|
}
|
38
|
|
39
|
public boolean getPropagate(){
|
40
|
return propagate;
|
41
|
}
|
42
|
|
43
|
public String getResultId(){
|
44
|
return resultId;
|
45
|
}
|
46
|
|
47
|
}
|
48
|
|