1
|
package eu.dnetlib.data.collector.plugins.mongo;
|
2
|
|
3
|
import java.io.*;
|
4
|
import java.util.Iterator;
|
5
|
import java.util.zip.GZIPInputStream;
|
6
|
|
7
|
import eu.dnetlib.rmi.data.CollectorServiceException;
|
8
|
|
9
|
// TODO: Auto-generated Javadoc
|
10
|
|
11
|
/**
|
12
|
* The Class MongoDumpIterable.
|
13
|
*/
|
14
|
public class MongoDumpIterable implements Iterable<String> {
|
15
|
|
16
|
/**
|
17
|
* The input stream.
|
18
|
*/
|
19
|
private final BufferedReader inputStream;
|
20
|
|
21
|
/**
|
22
|
* Instantiates a new mongo dump iterable.
|
23
|
*
|
24
|
* @param inputFile the input file
|
25
|
* @throws CollectorServiceException the collection service exception
|
26
|
*/
|
27
|
public MongoDumpIterable(final File inputFile) throws CollectorServiceException {
|
28
|
try {
|
29
|
final GZIPInputStream gzipStream = new GZIPInputStream(new FileInputStream(inputFile));
|
30
|
|
31
|
Reader decoder = new InputStreamReader(gzipStream, "UTF-8");
|
32
|
inputStream = new BufferedReader(decoder);
|
33
|
} catch (Exception e) {
|
34
|
throw new CollectorServiceException("Error unable to open inputStream", e);
|
35
|
}
|
36
|
}
|
37
|
|
38
|
/*
|
39
|
* (non-Javadoc)
|
40
|
*
|
41
|
* @see java.lang.Iterable#iterator()
|
42
|
*/
|
43
|
@Override
|
44
|
public Iterator<String> iterator() {
|
45
|
return new MongoDumpIterator(inputStream);
|
46
|
}
|
47
|
|
48
|
}
|