/** Suck up tuples from the source file. */
  private Tuple readNextTuple(DataInputStream dis, int slotId) throws NoSuchElementException {
    // if associated bit is not set, read forward to the next tuple, and
    // return null.
    if (!isSlotUsed(slotId)) {
      for (int i = 0; i < td.getSize(); i++) {
        try {
          dis.readByte();
        } catch (IOException e) {
          throw new NoSuchElementException("error reading empty tuple");
        }
      }
      return null;
    }

    // read fields in the tuple
    Tuple t = new Tuple(td);
    RecordId rid = new RecordId(pid, slotId);
    t.setRecordId(rid);
    try {
      for (int j = 0; j < td.numFields(); j++) {
        Field f = td.getFieldType(j).parse(dis);
        t.setField(j, f);
      }
    } catch (java.text.ParseException e) {
      e.printStackTrace();
      throw new NoSuchElementException("parsing error!");
    }

    return t;
  }
  public static Integer durToInteger(String meta, String date, String time) {
    Integer index = 0;
    Long y;
    Integer hh, mm, day, year, mo, interInMinutes;
    String part[] = meta.split(",");

    hh = Integer.valueOf(part[1]);
    mm = Integer.valueOf(part[2]);
    day = Integer.valueOf(part[3]);
    year = Integer.valueOf(part[4]);
    interInMinutes = Integer.valueOf(part[5]);

    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.HOUR_OF_DAY, hh);
    cal.set(Calendar.MINUTE, mm);
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.DAY_OF_YEAR, day);
    cal.set(Calendar.YEAR, year);

    Date d1 = cal.getTime();

    Date t = new Date();
    SimpleDateFormat tf = new SimpleDateFormat("hh:mm a");
    SimpleDateFormat pf = new SimpleDateFormat("HH:mm");
    try {
      t = tf.parse(time);
    } catch (java.text.ParseException e) {
      e.printStackTrace();
    }
    String[] strs = pf.format(t).split(":");

    hh = Integer.valueOf(strs[0]);
    mm = Integer.valueOf(strs[1]);

    String[] spl = date.split(", ");
    String[] spl2 = spl[0].split(" ");

    day = Integer.valueOf(spl2[0]);
    mo = Integer.valueOf(spl2[1]);
    year = Integer.valueOf(spl2[2]);
    Calendar cal2 = Calendar.getInstance();

    cal2.set(Calendar.HOUR_OF_DAY, hh);
    cal2.set(Calendar.MINUTE, mm);
    cal2.set(Calendar.SECOND, 0);
    cal2.set(Calendar.DATE, day);
    cal2.set(Calendar.MONTH, mo - 1);
    cal2.set(Calendar.YEAR, year);

    Date d2 = cal2.getTime();

    date = spl2[0] + " " + new DateFormatSymbols().getMonths()[mo - 1] + ", " + spl[1];
    Map<TimeUnit, Long> DiffMap = Utility.computeDiff(d1, d2);

    y =
        DiffMap.get(TimeUnit.DAYS) * 24 * 60
            + DiffMap.get(TimeUnit.HOURS) * 60
            + DiffMap.get(TimeUnit.MINUTES);
    y = y / interInMinutes + 1;
    index = (int) (long) y;
    return index;
  }