private void probeWrite(int pid, ByteBuffer buff) throws HyracksDataException {
   RunFileWriter pWriter = probeRFWriters[pid];
   if (pWriter == null) {
     FileReference file = ctx.getJobletContext().createManagedWorkspaceFile(rel1Name);
     pWriter = new RunFileWriter(file, ctx.getIOManager());
     pWriter.open();
     probeRFWriters[pid] = pWriter;
   }
   pWriter.nextFrame(buff);
 }
 private void buildWrite(int pid, ByteBuffer buff) throws HyracksDataException {
   RunFileWriter writer = buildRFWriters[pid];
   if (writer == null) {
     FileReference file = ctx.getJobletContext().createManagedWorkspaceFile(rel0Name);
     writer = new RunFileWriter(file, ctx.getIOManager());
     writer.open();
     buildRFWriters[pid] = writer;
   }
   writer.nextFrame(buff);
 }
  private void loadPartitionInMem(int pid, RunFileWriter wr, int[] buffs)
      throws HyracksDataException {
    RunFileReader r = wr.createReader();
    r.open();
    int counter = 0;
    ByteBuffer mBuff = null;
    reloadBuffer.clear();
    while (r.nextFrame(reloadBuffer)) {
      mBuff = memBuffs[buffs[counter]];
      if (mBuff == null) {
        mBuff = ctx.allocateFrame();
        memBuffs[buffs[counter]] = mBuff;
      }
      FrameUtils.copy(reloadBuffer, mBuff);
      counter++;
      reloadBuffer.clear();
    }

    int curNext = nextBuff[buffs[buffs.length - 1]];
    nextBuff[buffs[buffs.length - 1]] = END_OF_PARTITION;
    nextFreeBuffIx = curNext;

    r.close();
    pStatus.set(pid, false);
    buildRFWriters[pid] = null;
  }
 private void closeProbeWriter(int pid) throws HyracksDataException {
   RunFileWriter writer = probeRFWriters[pid];
   if (writer != null) {
     writer.close();
   }
 }