Skip to content
Browse files

Multi file support - the start

--HG--
branch : multi
  • Loading branch information...
1 parent b311e79 commit 40c05709e306deb5a29c64450a7c82f2d5186349 @tebeka committed Mar 11, 2013
Showing with 20 additions and 13 deletions.
  1. +20 −13 src/main/java/com/mikitebeka/mapred/ZipLineIterator.java
View
33 src/main/java/com/mikitebeka/mapred/ZipLineIterator.java
@@ -13,23 +13,31 @@
public class ZipLineIterator implements Iterator<String> {
private ZipInputStream zin = null;
- private String name;
+ private String name = null;
+ private String nextLine = null;
+ private BufferedReader reader = null;
private int pos = 0;
- private long size;
- private String nextLine;
- private BufferedReader reader;
public ZipLineIterator(InputStream in) throws IOException {
zin = new ZipInputStream(in);
- ZipEntry entry = zin.getNextEntry();
+
+ nextEntry();
+ }
+
+ private void nextEntry() {
+ nextLine = null;
+
+ if (entry != null) {
+ zin.closeEntry();
+ }
+
+ entry = zin.getNextEntry();
if (entry == null) {
return;
}
- size = entry.getSize();
name = entry.getName();
reader = new BufferedReader(new InputStreamReader(zin));
-
nextLine = reader.readLine();
}
@@ -51,10 +59,12 @@ public boolean hasNext() {
@Override
public String next() {
String line = nextLine;
+ pos += line.length();
+
try {
nextLine = reader.readLine();
} catch (IOException e) {
- nextLine = null;
+ nextEntry();
}
return line;
@@ -85,11 +95,8 @@ public void close() throws IOException {
}
public float getProgress() {
- if (size == 0) {
- return 1.0f;
- }
-
- return (float) (((double) pos) / size);
+ // FIXME
+ return 0.5f;
}
/**

0 comments on commit 40c0570

Please sign in to comment.
Something went wrong with that request. Please try again.