Github user tillrohrmann commented on a diff in the pull request:
https://github.com/apache/incubator-flink/pull/53#discussion_r14594163
--- Diff:
stratosphere-runtime/src/main/java/eu/stratosphere/nephele/services/memorymanager/AbstractPagedInputView.java
---
@@ -183,44 +183,69 @@ protected void clear() {
//
--------------------------------------------------------------------------------------------
// Data Input Specific methods
//
--------------------------------------------------------------------------------------------
-
+
@Override
- public void readFully(byte[] b) throws IOException {
- readFully(b, 0, b.length);
+ public int read(byte[] b) throws IOException{
+ return read(b,0,b.length);
}
@Override
- public void readFully(byte[] b, int off, int len) throws IOException {
+ public int read(byte[] b, int off, int len) throws IOException{
if (off < 0 || len < 0 || off + len > b.length) {
throw new IndexOutOfBoundsException();
}
-
+
int remaining = this.limitInSegment - this.positionInSegment;
if (remaining >= len) {
this.currentSegment.get(this.positionInSegment, b, off,
len);
this.positionInSegment += len;
+ return len;
}
else {
if (remaining == 0) {
- advance();
+ try {
+ advance();
+ }catch(EOFException eof){
+ return -1;
+ }
remaining = this.limitInSegment -
this.positionInSegment;
}
-
+
+ int bytesRead = 0;
while (true) {
- int toRead = Math.min(remaining, len);
+ int toRead = Math.min(remaining, len-bytesRead);
this.currentSegment.get(this.positionInSegment,
b, off, toRead);
off += toRead;
- len -= toRead;
-
- if (len > 0) {
- advance();
- remaining = this.limitInSegment -
this.positionInSegment;
+ bytesRead += toRead;
+
+ if (len > bytesRead) {
+ try {
+ advance();
+ }catch(EOFException eof){
+ return bytesRead;
+ }
+ remaining = this.limitInSegment -
this.positionInSegment;
}
else {
this.positionInSegment += toRead;
break;
}
}
+ return len;
+ }
+ }
+
+ @Override
+ public void readFully(byte[] b) throws IOException {
+ readFully(b, 0, b.length);
+ }
+
+ @Override
+ public void readFully(byte[] b, int off, int len) throws IOException {
+ int bytesRead = read(b,off,len);
+
+ if(bytesRead == -1){
--- End diff --
Yes, you are right that's a bug. I'll add the test cases.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---