super(id, left, right, buf);
mTC = TachyonFS.get(sMasterAddress);
}
public void readPartition() throws IOException {
TachyonByteBuffer buf;
if (sDebugMode) {
LOG.info("Verifying the reading data...");
for (int pId = mLeft; pId < mRight; pId ++) {
TachyonFile file = mTC.getFile(new TachyonURI(sFileName + (pId + sBaseFileNumber)));
buf = file.readByteBuffer(0);
IntBuffer intBuf;
intBuf = buf.mData.order(ByteOrder.nativeOrder()).asIntBuffer();
for (int i = 0; i < sBlocskPerFile; i ++) {
for (int k = 0; k < sBlockSizeBytes / 4; k ++) {
int tmp = intBuf.get();
if ((k == 0 && tmp == (i + mWorkerId)) || (k != 0 && tmp == k)) {
LOG.debug("Partition at {} is {}", k, tmp);
} else {
throw new IllegalStateException("WHAT? " + tmp + " " + k);
}
}
}
buf.close();
}
}
long sum = 0;
if (sTachyonStreamingRead) {
for (int pId = mLeft; pId < mRight; pId ++) {
final long startTimeMs = System.currentTimeMillis();
TachyonFile file = mTC.getFile(new TachyonURI(sFileName + (pId + sBaseFileNumber)));
InputStream is = file.getInStream(ReadType.CACHE);
long len = sBlocskPerFile * sBlockSizeBytes;
while (len > 0) {
int r = is.read(mBuf.array());
len -= r;
Preconditions.checkState(r != -1, "R == -1");
}
is.close();
logPerIteration(startTimeMs, pId, "th ReadTachyonFile @ Worker ", pId);
}
} else {
for (int pId = mLeft; pId < mRight; pId ++) {
final long startTimeMs = System.currentTimeMillis();
TachyonFile file = mTC.getFile(new TachyonURI(sFileName + (pId + sBaseFileNumber)));
buf = file.readByteBuffer(0);
for (int i = 0; i < sBlocskPerFile; i ++) {
buf.mData.get(mBuf.array());
}
sum += mBuf.get(pId % 16);
if (sDebugMode) {
buf.mData.order(ByteOrder.nativeOrder()).flip();
CommonUtils.printByteBuffer(LOG, buf.mData);
}
buf.mData.clear();
logPerIteration(startTimeMs, pId, "th ReadTachyonFile @ Worker ", pId);
buf.close();
}
}
sResults[mWorkerId] = sum;
}