private MergeReadRes read(int id) throws Exception {
    MergeReadRes res = new MergeReadRes();
    while (curKey1 < id && (buf1 = dr1.read()) != null) {
      // buf1 = dr1.read();
      curKey1 = Integer.parseInt(buf1[key1]);
    }
    while (curKey2 < id && (buf2 = dr2.read()) != null) {
      // buf1 = dr1.read();
      curKey2 = Integer.parseInt(buf2[key2]);
    }
    // if(buf1 == null || buf2 == null) return null;
    setCurKey();

    if (curKey1 == id && curKey2 == id) {
      res.key_value = id;
      do {
        if (buf1 == null) continue;
        String[] temp = new String[buf1.length];
        System.arraycopy(buf1, 0, temp, 0, buf1.length);
        res.line1_list.add(temp);
      } while ((buf1 = dr1.read()) != null && Integer.parseInt(buf1[key1]) == id);

      do {
        if (buf2 == null) continue;
        String[] temp = new String[buf2.length];
        System.arraycopy(buf2, 0, temp, 0, buf2.length);
        res.line2_list.add(temp);
      } while ((buf2 = dr2.read()) != null && Integer.parseInt(buf2[key2]) == id);
    } else {
      res.key_value = Integer.MIN_VALUE;
    }
    setCurKey();

    return res;
  }
 public MergeRead(String file1, String file2, int key1, int key2) throws Exception {
   dr1 = new DelimitedReader(file1);
   dr2 = new DelimitedReader(file2);
   this.key1 = key1;
   this.key2 = key2;
   buf1 = dr1.read();
   curKey1 = Integer.parseInt(buf1[key1]);
   buf2 = dr2.read();
   curKey2 = Integer.parseInt(buf2[key2]);
 }