nus-yam/ex-repair huggingface dataset:
Program: 15839
Project: 15839
Buggy source:
@Override public Value createClob(Reader reader,long maxLength){
  init();
  int type=Value.CLOB;
  if (maxLength < 0) {
    maxLength=Long.MAX_VALUE;
  }
  int max=(int)Math.min(maxLength,database.getMaxLengthInplaceLob());
  try {
    if (max != 0 && max < Integer.MAX_VALUE) {
      BufferedReader b=new BufferedReader(reader,max);
      b.mark(max);
      char[] small=new char[max];
      int len=IOUtils.readFully(b,small,max);
      if (len < max) {
        if (len < small.length) {
          small=Arrays.copyOf(small,len);
        }
        byte[] utf8=new String(small,0,len).getBytes(Constants.UTF8);
        return ValueLobDb.createSmallLob(type,utf8);
      }
      b.reset();
      reader=b;
    }
    CountingReaderInputStream in=new CountingReaderInputStream(reader,maxLength);
    ValueLobDb lob=createLob(in,type);
    lob=ValueLobDb.create(type,database,lob.getTableId(),lob.getLobId(),null,in.getLength());
    return lob;
  }
 catch (  IOException e) {
    throw DbException.convertIOException(e,null);
  }
}

Fixed version (ground truth):
@Override public Value createClob(Reader reader,long maxLength){
  init();
  int type=Value.CLOB;
  if (maxLength < 0) {
    maxLength=Long.MAX_VALUE;
  }
  int max=(int)Math.min(maxLength,database.getMaxLengthInplaceLob());
  try {
    if (max != 0 && max < Integer.MAX_VALUE) {
      BufferedReader b=new BufferedReader(reader,max);
      b.mark(max);
      char[] small=new char[max];
      int len=IOUtils.readFully(b,small,max);
      if (len < max) {
        if (len < small.length) {
          small=Arrays.copyOf(small,len);
        }
        byte[] utf8=new String(small,0,len).getBytes(Constants.UTF8);
        return ValueLobDb.createSmallLob(type,utf8);
      }
      b.reset();
      reader=b;
    }
    CountingReaderInputStream in=new CountingReaderInputStream(reader,maxLength);
    ValueLobDb lob=createLob(in,type);
    lob=ValueLobDb.create(type,database,lob.getTableId(),lob.getLobId(),null,in.getLength());
    return lob;
  }
 catch (  IllegalStateException e) {
    throw DbException.get(ErrorCode.OBJECT_CLOSED);
  }
catch (  IOException e) {
    throw DbException.convertIOException(e,null);
  }
}
Program: 15840
Project: 15840
Buggy source:
@Override public Value createBlob(InputStream in,long maxLength){
  init();
  int type=Value.BLOB;
  if (maxLength < 0) {
    maxLength=Long.MAX_VALUE;
  }
  int max=(int)Math.min(maxLength,database.getMaxLengthInplaceLob());
  try {
    if (max != 0 && max < Integer.MAX_VALUE) {
      BufferedInputStream b=new BufferedInputStream(in,max);
      b.mark(max);
      byte[] small=new byte[max];
      int len=IOUtils.readFully(b,small,max);
      if (len < max) {
        if (len < small.length) {
          small=Arrays.copyOf(small,len);
        }
        return ValueLobDb.createSmallLob(type,small);
      }
      b.reset();
      in=b;
    }
    return createLob(in,type);
  }
 catch (  IOException e) {
    throw DbException.convertIOException(e,null);
  }
}

Fixed version (ground truth):
@Override public Value createBlob(InputStream in,long maxLength){
  init();
  int type=Value.BLOB;
  if (maxLength < 0) {
    maxLength=Long.MAX_VALUE;
  }
  int max=(int)Math.min(maxLength,database.getMaxLengthInplaceLob());
  try {
    if (max != 0 && max < Integer.MAX_VALUE) {
      BufferedInputStream b=new BufferedInputStream(in,max);
      b.mark(max);
      byte[] small=new byte[max];
      int len=IOUtils.readFully(b,small,max);
      if (len < max) {
        if (len < small.length) {
          small=Arrays.copyOf(small,len);
        }
        return ValueLobDb.createSmallLob(type,small);
      }
      b.reset();
      in=b;
    }
    return createLob(in,type);
  }
 catch (  IllegalStateException e) {
    throw DbException.get(ErrorCode.OBJECT_CLOSED);
  }
catch (  IOException e) {
    throw DbException.convertIOException(e,null);
  }
}
Program: 15841
Project: 15841
Buggy source:
@Override public ValueLobDb copyLob(ValueLobDb old,int tableId,long length){
  init();
  int type=old.getType();
  long oldLobId=old.getLobId();
  long oldLength=old.getPrecision();
  if (oldLength != length) {
    throw DbException.throwInternalError("String_Node_Str");
  }
  Object[] value=lobMap.get(oldLobId);
  byte[] streamStoreId=(byte[])value[0];
  long lobId=streamStore.getAndIncrementNextKey();
  value[1]=tableId;
  lobMap.put(lobId,value);
  Object[] key=new Object[]{streamStoreId,lobId};
  refMap.put(key,Boolean.TRUE);
  ValueLobDb lob=ValueLobDb.create(type,database,tableId,lobId,null,length);
  return lob;
}

Fixed version (ground truth):
@Override public ValueLobDb copyLob(ValueLobDb old,int tableId,long length){
  init();
  int type=old.getType();
  long oldLobId=old.getLobId();
  long oldLength=old.getPrecision();
  if (oldLength != length) {
    throw DbException.throwInternalError("String_Node_Str");
  }
  Object[] value=lobMap.get(oldLobId);
  value=Arrays.copyOf(value,value.length);
  byte[] streamStoreId=(byte[])value[0];
  long lobId=generateLobId();
  value[1]=tableId;
  lobMap.put(lobId,value);
  Object[] key=new Object[]{streamStoreId,lobId};
  refMap.put(key,Boolean.TRUE);
  ValueLobDb lob=ValueLobDb.create(type,database,tableId,lobId,null,length);
  if (TRACE) {
    trace("String_Node_Str" + old.getTableId() + "String_Node_Str"+ old.getLobId()+ "String_Node_Str"+ tableId+ "String_Node_Str"+ lobId);
  }
  return lob;
}
Program: 15843
Project: 15843
Buggy source:
DbSchema(DbContents contents,String name,boolean isDefault){
  this.contents=contents;
  this.name=name;
  this.quotedName=contents.quoteIdentifier(name);
  this.isDefault=isDefault;
  if (name.equals("String_Node_Str")) {
    isSystem=true;
  }
 else   if (!contents.isH2() && StringUtils.toUpperEnglish(name).startsWith("String_Node_Str")) {
    isSystem=true;
  }
 else   if (contents.isPostgreSQL() && StringUtils.toUpperEnglish(name).startsWith("String_Node_Str")) {
    isSystem=true;
  }
 else   if (contents.isDerby() && name.startsWith("String_Node_Str")) {
    isSystem=true;
  }
 else {
    isSystem=false;
  }
}

Fixed version (ground truth):
DbSchema(DbContents contents,String name,boolean isDefault){
  this.contents=contents;
  this.name=name;
  this.quotedName=contents.quoteIdentifier(name);
  this.isDefault=isDefault;
  if (name == null) {
    isSystem=true;
  }
 else   if ("String_Node_Str".equals(name)) {
    isSystem=true;
  }
 else   if (!contents.isH2() && StringUtils.toUpperEnglish(name).startsWith("String_Node_Str")) {
    isSystem=true;
  }
 else   if (contents.isPostgreSQL() && StringUtils.toUpperEnglish(name).startsWith("String_Node_Str")) {
    isSystem=true;
  }
 else   if (contents.isDerby() && name.startsWith("String_Node_Str")) {
    isSystem=true;
  }
 else {
    isSystem=false;
  }
}
Program: 15846
Project: 15846
Buggy source:
DbSchema(DbContents contents,String name,boolean isDefault){
  this.contents=contents;
  this.name=name;
  this.quotedName=contents.quoteIdentifier(name);
  this.isDefault=isDefault;
  if (name.equals("String_Node_Str")) {
    isSystem=true;
  }
 else   if (!contents.isH2() && StringUtils.toUpperEnglish(name).startsWith("String_Node_Str")) {
    isSystem=true;
  }
 else   if (contents.isPostgreSQL() && StringUtils.toUpperEnglish(name).startsWith("String_Node_Str")) {
    isSystem=true;
  }
 else   if (contents.isDerby() && name.startsWith("String_Node_Str")) {
    isSystem=true;
  }
 else {
    isSystem=false;
  }
}

Fixed version (ground truth):
DbSchema(DbContents contents,String name,boolean isDefault){
  this.contents=contents;
  this.name=name;
  this.quotedName=contents.quoteIdentifier(name);
  this.isDefault=isDefault;
  if (name == null) {
    isSystem=true;
  }
 else   if ("String_Node_Str".equals(name)) {
    isSystem=true;
  }
 else   if (!contents.isH2() && StringUtils.toUpperEnglish(name).startsWith("String_Node_Str")) {
    isSystem=true;
  }
 else   if (contents.isPostgreSQL() && StringUtils.toUpperEnglish(name).startsWith("String_Node_Str")) {
    isSystem=true;
  }
 else   if (contents.isDerby() && name.startsWith("String_Node_Str")) {
    isSystem=true;
  }
 else {
    isSystem=false;
  }
}
Program: 15850
Project: 15850
Buggy source:
/** 
 * Get the size of the map as seen by this transaction.
 * @return the size
 */
public long sizeAsLong(){
  long size=0;
  Cursor<K,VersionedValue> cursor=map.cursor(null);
  while (cursor.hasNext()) {
    K key=cursor.next();
    VersionedValue data=cursor.getValue();
    if (getValue(key,readLogId,data) != null) {
      size++;
    }
  }
  return size;
}

Fixed version (ground truth):
/** 
 * Get the size of the map as seen by this transaction.
 * @return the size
 */
public long sizeAsLong(){
  long size=0;
  Cursor<K,VersionedValue> cursor=map.cursor(null);
  while (cursor.hasNext()) {
    K key=cursor.next();
    VersionedValue data=cursor.getValue();
    data=getValue(key,readLogId,data);
    if (data != null && data.value != null) {
      size++;
    }
  }
  return size;
}
Program: 15851
Project: 15851
Buggy source:
private void testSavepoint() throws SQLException {
  deleteDb("String_Node_Str");
  Connection conn=getConnection("String_Node_Str");
  Statement stat=conn.createStatement();
  stat.execute("String_Node_Str");
  stat.execute("String_Node_Str");
  conn.setAutoCommit(false);
  int[] count=new int[2];
  int[] countCommitted=new int[2];
  int[] countSave=new int[2];
  int len=getSize(2000,10000);
  Random random=new Random(10);
  Savepoint sp=null;
  for (int i=0; i < len; i++) {
    int tableId=random.nextInt(2);
    String table="String_Node_Str" + tableId;
    int op=random.nextInt(6);
switch (op) {
case 0:
      stat.execute("String_Node_Str" + table + "String_Node_Str"+ i+ "String_Node_Str");
    count[tableId]++;
  break;
case 1:
if (count[tableId] > 0) {
  stat.execute("String_Node_Str" + table + "String_Node_Str"+ table);
  count[tableId]--;
}
break;
case 2:
sp=conn.setSavepoint();
countSave[0]=count[0];
countSave[1]=count[1];
break;
case 3:
if (sp != null) {
conn.rollback(sp);
count[0]=countSave[0];
count[1]=countSave[1];
}
break;
case 4:
conn.commit();
sp=null;
countCommitted[0]=count[0];
countCommitted[1]=count[1];
break;
case 5:
conn.rollback();
sp=null;
count[0]=countCommitted[0];
count[1]=countCommitted[1];
break;
default :
}
checkTableCount(stat,"String_Node_Str",count[0]);
checkTableCount(stat,"String_Node_Str",count[1]);
}
conn.close();
}

Fixed version (ground truth):
private void testSavepoint() throws SQLException {
  deleteDb("String_Node_Str");
  Connection conn=getConnection("String_Node_Str");
  Statement stat=conn.createStatement();
  stat.execute("String_Node_Str");
  stat.execute("String_Node_Str");
  conn.setAutoCommit(false);
  int[] count=new int[2];
  int[] countCommitted=new int[2];
  int[] countSave=new int[2];
  int len=getSize(2000,10000);
  Random random=new Random(10);
  Savepoint sp=null;
  for (int i=0; i < len; i++) {
    int tableId=random.nextInt(2);
    String table="String_Node_Str" + tableId;
    int op=random.nextInt(6);
switch (op) {
case 0:
      stat.execute("String_Node_Str" + table + "String_Node_Str"+ i+ "String_Node_Str");
    count[tableId]++;
  break;
case 1:
if (count[tableId] > 0) {
  int updateCount=stat.executeUpdate("String_Node_Str" + table + "String_Node_Str"+ table);
  assertEquals(1,updateCount);
  count[tableId]--;
}
break;
case 2:
sp=conn.setSavepoint();
countSave[0]=count[0];
countSave[1]=count[1];
break;
case 3:
if (sp != null) {
conn.rollback(sp);
count[0]=countSave[0];
count[1]=countSave[1];
}
break;
case 4:
conn.commit();
sp=null;
countCommitted[0]=count[0];
countCommitted[1]=count[1];
break;
case 5:
conn.rollback();
sp=null;
count[0]=countCommitted[0];
count[1]=countCommitted[1];
break;
default :
}
checkTableCount(stat,"String_Node_Str",count[0]);
checkTableCount(stat,"String_Node_Str",count[1]);
}
conn.close();
}
Program: 15852
Project: 15852
Buggy source:
CountingReaderInputStream(Reader reader,long maxLength){
  this.reader=reader;
  this.remaining=maxLength;
  buffer=Utils.EMPTY_BYTES;
}

Fixed version (ground truth):
CountingReaderInputStream(Reader reader,long maxLength){
  this.reader=reader;
  this.remaining=maxLength;
}
Program: 15853
Project: 15853
Buggy source:
private void fillBuffer() throws IOException {
  int len=(int)Math.min(charBuffer.length,remaining);
  if (len > 0) {
    len=reader.read(charBuffer,0,len);
  }
 else {
    len=-1;
  }
  if (len < 0) {
    buffer=null;
  }
 else {
    buffer=new String(charBuffer,0,len).getBytes(Constants.UTF8);
    length+=len;
    remaining-=len;
  }
  pos=0;
}

Fixed version (ground truth):
private void fillBuffer() throws IOException {
  int len=(int)Math.min(charBuffer.capacity() - charBuffer.position(),remaining);
  if (len > 0) {
    len=reader.read(charBuffer.array(),charBuffer.position(),len);
  }
  if (len > 0) {
    remaining-=len;
  }
 else {
    len=0;
    remaining=0;
  }
  length+=len;
  charBuffer.limit(charBuffer.position() + len);
  charBuffer.rewind();
  byteBuffer=ByteBuffer.allocate(Constants.IO_BUFFER_SIZE);
  boolean end=remaining == 0;
  encoder.encode(charBuffer,byteBuffer,end);
  if (end && byteBuffer.position() == 0) {
    byteBuffer=null;
    return;
  }
  byteBuffer.flip();
  charBuffer.compact();
  charBuffer.flip();
  charBuffer.position(charBuffer.limit());
}
Program: 15854
Project: 15854
Buggy source:
@Override public int read() throws IOException {
  if (buffer == null) {
    return -1;
  }
  if (pos >= buffer.length) {
    fillBuffer();
    if (buffer == null) {
      return -1;
    }
  }
  return buffer[pos++];
}

Fixed version (ground truth):
@Override public int read() throws IOException {
  if (!fetch()) {
    return -1;
  }
  return byteBuffer.get() & 255;
}
Program: 15855
Project: 15855
Buggy source:
public long getLength(){
  return length;
}

Fixed version (ground truth):
/** 
 * The number of characters read so far (but there might still be some bytes in the buffer).
 * @return the number of characters
 */
public long getLength(){
  return length;
}
Program: 15856
Project: 15856
Buggy source:
@Override public Reader getReader(){
  return new InputStreamReader(getInputStream(),Constants.UTF8);
}

Fixed version (ground truth):
@Override public Reader getReader(){
  return IOUtils.getBufferedReader(getInputStream());
}
Program: 15857
Project: 15857
Buggy source:
/** 
 * Create a temporary CLOB value from a stream.
 * @param in the reader
 * @param length the number of characters to read, or -1 for no limit
 * @param handler the data handler
 * @return the lob value
 */
public static ValueLobDb createTempClob(Reader in,long length,DataHandler handler){
  try {
    boolean compress=handler.getLobCompressionAlgorithm(Value.CLOB) != null;
    long remaining=Long.MAX_VALUE;
    if (length >= 0 && length < remaining) {
      remaining=length;
    }
    int len=getBufferSize(handler,compress,remaining);
    char[] buff;
    if (len >= Integer.MAX_VALUE) {
      String data=IOUtils.readStringAndClose(in,-1);
      buff=data.toCharArray();
      len=buff.length;
    }
 else {
      buff=new char[len];
      len=IOUtils.readFully(in,buff,len);
      len=len < 0 ? 0 : len;
    }
    if (len <= handler.getMaxLengthInplaceLob()) {
      byte[] small=new String(buff,0,len).getBytes(Constants.UTF8);
      return ValueLobDb.createSmallLob(Value.CLOB,small,len);
    }
    ValueLobDb lob=new ValueLobDb(handler,buff,len,in,remaining);
    return lob;
  }
 catch (  IOException e) {
    throw DbException.convertIOException(e,null);
  }
}

Fixed version (ground truth):
/** 
 * Create a temporary CLOB value from a stream.
 * @param in the reader
 * @param length the number of characters to read, or -1 for no limit
 * @param handler the data handler
 * @return the lob value
 */
public static ValueLobDb createTempClob(Reader in,long length,DataHandler handler){
  BufferedReader reader;
  if (in instanceof BufferedReader) {
    reader=(BufferedReader)in;
  }
 else {
    reader=new BufferedReader(in,Constants.IO_BUFFER_SIZE);
  }
  try {
    boolean compress=handler.getLobCompressionAlgorithm(Value.CLOB) != null;
    long remaining=Long.MAX_VALUE;
    if (length >= 0 && length < remaining) {
      remaining=length;
    }
    int len=getBufferSize(handler,compress,remaining);
    char[] buff;
    if (len >= Integer.MAX_VALUE) {
      String data=IOUtils.readStringAndClose(reader,-1);
      buff=data.toCharArray();
      len=buff.length;
    }
 else {
      buff=new char[len];
      reader.mark(len);
      len=IOUtils.readFully(reader,buff,len);
      len=len < 0 ? 0 : len;
    }
    if (len <= handler.getMaxLengthInplaceLob()) {
      byte[] small=new String(buff,0,len).getBytes(Constants.UTF8);
      return ValueLobDb.createSmallLob(Value.CLOB,small,len);
    }
    reader.reset();
    ValueLobDb lob=new ValueLobDb(handler,reader,remaining);
    return lob;
  }
 catch (  IOException e) {
    throw DbException.convertIOException(e,null);
  }
}
Program: 15858
Project: 15858
Buggy source:
private void testClobWithRandomUnicodeChars() throws Exception {
  deleteDb("String_Node_Str");
  Connection conn=getConnection("String_Node_Str");
  Statement stat=conn.createStatement();
  stat.execute("String_Node_Str");
  PreparedStatement s1=conn.prepareStatement("String_Node_Str");
  final Random rand=new Random();
  for (int i=1; i <= 100; i++) {
    String data=randomUnicodeString(rand);
    s1.setString(1,data);
    s1.executeUpdate();
    ResultSet rs=stat.executeQuery("String_Node_Str");
    rs.next();
    String read=rs.getString(2);
    assertEquals(read,data);
  }
  conn.close();
}

Fixed version (ground truth):
private void testClobWithRandomUnicodeChars() throws Exception {
  deleteDb("String_Node_Str");
  Connection conn=getConnection("String_Node_Str");
  Statement stat=conn.createStatement();
  stat.execute("String_Node_Str");
  PreparedStatement s1=conn.prepareStatement("String_Node_Str");
  final Random rand=new Random(1);
  for (int i=1; i <= 100; i++) {
    String data=randomUnicodeString(rand);
    s1.setString(1,data);
    s1.executeUpdate();
    ResultSet rs=stat.executeQuery("String_Node_Str");
    rs.next();
    String read=rs.getString(2);
    if (!read.equals(data)) {
      for (int j=0; j < read.length(); j++) {
        assertEquals("String_Node_Str" + j,read.charAt(j),data.charAt(j));
      }
    }
    assertEquals(read,data);
  }
  conn.close();
}
Program: 15859
Project: 15859
Buggy source:
@Override public void test() throws Exception {
  testCommitOnExclusiveConnection();
  testReadManyLobs();
  testLobSkip();
  testLobSkipPastEnd();
  testCreateIndexOnLob();
  testBlobInputStreamSeek(true);
  testBlobInputStreamSeek(false);
  testDeadlock();
  testDeadlock2();
  testCopyManyLobs();
  testCopyLob();
  testConcurrentCreate();
  testLobInLargeResult();
  testUniqueIndex();
  testConvert();
  testCreateAsSelect();
  testDropAllObjects();
  testDelete();
  testTempFilesDeleted(true);
  testTempFilesDeleted(false);
  testAddLobRestart();
  testLobServerMemory();
  testUpdatingLobRow();
  if (config.memory) {
    return;
  }
  testLobCleanupSessionTemporaries();
  testLobUpdateMany();
  testLobDeleteTemp();
  testLobDelete();
  testLobVariable();
  testLobDrop();
  testLobNoClose();
  testLobTransactions(10);
  testLobTransactions(10000);
  testLobRollbackStop();
  testLobCopy();
  testLobHibernate();
  testLobCopy(false);
  testLobCopy(true);
  testLobCompression(false);
  testLobCompression(true);
  testManyLobs();
  testClob();
  testUpdateLob();
  testLobReconnect();
  testLob(false);
  testLob(true);
  testJavaObject();
  testClobWithRandomUnicodeChars();
  deleteDb("String_Node_Str");
  FileUtils.deleteRecursive(TEMP_DIR,true);
}

Fixed version (ground truth):
@Override public void test() throws Exception {
  testClobWithRandomUnicodeChars();
  testCommitOnExclusiveConnection();
  testReadManyLobs();
  testLobSkip();
  testLobSkipPastEnd();
  testCreateIndexOnLob();
  testBlobInputStreamSeek(true);
  testBlobInputStreamSeek(false);
  testDeadlock();
  testDeadlock2();
  testCopyManyLobs();
  testCopyLob();
  testConcurrentCreate();
  testLobInLargeResult();
  testUniqueIndex();
  testConvert();
  testCreateAsSelect();
  testDropAllObjects();
  testDelete();
  testTempFilesDeleted(true);
  testTempFilesDeleted(false);
  testAddLobRestart();
  testLobServerMemory();
  testUpdatingLobRow();
  if (config.memory) {
    return;
  }
  testLobCleanupSessionTemporaries();
  testLobUpdateMany();
  testLobDeleteTemp();
  testLobDelete();
  testLobVariable();
  testLobDrop();
  testLobNoClose();
  testLobTransactions(10);
  testLobTransactions(10000);
  testLobRollbackStop();
  testLobCopy();
  testLobHibernate();
  testLobCopy(false);
  testLobCopy(true);
  testLobCompression(false);
  testLobCompression(true);
  testManyLobs();
  testClob();
  testUpdateLob();
  testLobReconnect();
  testLob(false);
  testLob(true);
  testJavaObject();
  deleteDb("String_Node_Str");
  FileUtils.deleteRecursive(TEMP_DIR,true);
}
Program: 15860
Project: 15860
Buggy source:
/** 
 * Set the amount of memory a page should contain at most, in bytes, before it is split. The default is 16 KB. This is not a limit in the page size, as pages with one entry can get larger. It is just the point where pages that contain more than one entry are split.
 * @param pageSplitSize the page size
 * @return this
 */
public Builder pageSplitSize(int pageSplitSize){
  return set("String_Node_Str",pageSplitSize);
}

Fixed version (ground truth):
/** 
 * Set the amount of memory a page should contain at most, in bytes, before it is split. The default is 16 KB for persistent stores and 4 KB for in-memory stores. This is not a limit in the page size, as pages with one entry can get larger. It is just the point where pages that contain more than one entry are split.
 * @param pageSplitSize the page size
 * @return this
 */
public Builder pageSplitSize(int pageSplitSize){
  return set("String_Node_Str",pageSplitSize);
}
Program: 15862
Project: 15862
Buggy source:
private void testPerformanceComparison(){
  if (!config.big) {
    return;
  }
  int size=1000000;
  Map<Integer,String> map;
  map=new HashMap<Integer,String>(size);
  long hash=testPerformance(map,size);
  map=new TreeMap<Integer,String>();
  long tree=testPerformance(map,size);
  MVStore store=MVStore.open(null);
  map=store.openMap("String_Node_Str");
  long mv=testPerformance(map,size);
  String msg="String_Node_Str" + mv + "String_Node_Str"+ tree+ "String_Node_Str"+ hash;
  assertTrue(msg,hash < tree);
  assertTrue(msg,mv < tree);
}

Fixed version (ground truth):
private void testPerformanceComparison(){
  if (!config.big) {
    return;
  }
  int size=1000000;
  long hash=0, tree=0, mv=0;
  for (int i=0; i < 5; i++) {
    Map<Integer,String> map;
    map=new HashMap<Integer,String>(size);
    hash=testPerformance(map,size);
    map=new TreeMap<Integer,String>();
    tree=testPerformance(map,size);
    MVStore store=MVStore.open(null);
    map=store.openMap("String_Node_Str");
    mv=testPerformance(map,size);
    if (hash < tree && mv < tree) {
      break;
    }
  }
  String msg="String_Node_Str" + mv + "String_Node_Str"+ tree+ "String_Node_Str"+ hash;
  assertTrue(msg,hash < tree);
  assertTrue(msg,mv < tree);
}
Program: 15863
Project: 15863
Buggy source:
VersionedValue getValue(K key,long maxLog,VersionedValue data){
  ;
  for (int i=0; i < 1000; i++) {
    int tx;
    if (data == null) {
      return null;
    }
    long id=data.operationId;
    if (id == 0) {
      return data;
    }
    tx=getTransactionId(id);
    if (tx == transaction.transactionId) {
      if (getLogId(id) < maxLog) {
        return data;
      }
    }
    Object[] d;
synchronized (transaction.store.undoLog) {
      d=transaction.store.undoLog.get(id);
    }
    if (d == null) {
      data=map.get(key);
    }
 else {
      data=(VersionedValue)d[2];
    }
  }
  throw DataUtils.newIllegalStateException(DataUtils.ERROR_TRANSACTION_CORRUPT,"String_Node_Str",key);
}

Fixed version (ground truth):
VersionedValue getValue(K key,long maxLog,VersionedValue data){
  while (true) {
    if (data == null) {
      return null;
    }
    long id=data.operationId;
    if (id == 0) {
      return data;
    }
    int tx=getTransactionId(id);
    if (tx == transaction.transactionId) {
      if (getLogId(id) < maxLog) {
        return data;
      }
    }
    Object[] d;
synchronized (transaction.store.undoLog) {
      d=transaction.store.undoLog.get(id);
    }
    if (d == null) {
      data=map.get(key);
    }
 else {
      data=(VersionedValue)d[2];
    }
    if (data != null) {
      long id2=data.operationId;
      if (id2 != 0) {
        int tx2=getTransactionId(id2);
        if (tx2 != tx) {
          break;
        }
        if (getLogId(id2) > getLogId(id)) {
          break;
        }
      }
    }
  }
  throw DataUtils.newIllegalStateException(DataUtils.ERROR_TRANSACTION_CORRUPT,"String_Node_Str",key);
}
Program: 15864
Project: 15864
Buggy source:
@Override public void test() throws Exception {
  FileUtils.createDirectories(getBaseDir());
  testTransactionAge();
  testStopWhileCommitting();
  testGetModifiedMaps();
  testKeyIterator();
  testMultiStatement();
  testTwoPhaseCommit();
  testSavepoint();
  testConcurrentTransactionsReadCommitted();
  testSingleConnection();
  testCompareWithPostgreSQL();
}

Fixed version (ground truth):
@Override public void test() throws Exception {
  FileUtils.createDirectories(getBaseDir());
  testRepeatedChange();
  testTransactionAge();
  testStopWhileCommitting();
  testGetModifiedMaps();
  testKeyIterator();
  testMultiStatement();
  testTwoPhaseCommit();
  testSavepoint();
  testConcurrentTransactionsReadCommitted();
  testSingleConnection();
  testCompareWithPostgreSQL();
}
Program: 15865
Project: 15865
Buggy source:
@Override public Cursor findFirstOrLast(Session session,boolean first){
  TransactionMap<Value,Value> map=getMap(session);
  ValueLong v=(ValueLong)(first ? map.firstKey() : map.lastKey());
  if (v == null) {
    return new MVStoreCursor(Collections.<Entry<Value,Value>>emptyList().iterator(),null);
  }
  Value value=map.get(v);
  Entry<Value,Value> e=new DataUtils.MapEntry<Value,Value>(v,value);
  @SuppressWarnings("String_Node_Str") List<Entry<Value,Value>> list=Arrays.asList(e);
  return new MVStoreCursor(list.iterator(),v);
}

Fixed version (ground truth):
@Override public Cursor findFirstOrLast(Session session,boolean first){
  TransactionMap<Value,Value> map=getMap(session);
  ValueLong v=(ValueLong)(first ? map.firstKey() : map.lastKey());
  if (v == null) {
    return new MVStoreCursor(Collections.<Entry<Value,Value>>emptyList().iterator(),null);
  }
  Value value=map.get(v);
  Entry<Value,Value> e=new DataUtils.MapEntry<Value,Value>(v,value);
  @SuppressWarnings("String_Node_Str") List<Entry<Value,Value>> list=Arrays.asList(e);
  MVStoreCursor c=new MVStoreCursor(list.iterator(),v);
  c.next();
  return c;
}
Program: 15866
Project: 15866
Buggy source:
/** 
 * Shrink the file if possible, and if at least a given percentage can be saved.
 * @param minPercent the minimum percentage to save
 */
private void shrinkFileIfPossible(int minPercent){
  long end=getEndPosition();
  long fileSize=fileStore.size();
  if (end >= fileSize) {
    return;
  }
  if (minPercent > 0 && fileSize - end < BLOCK_SIZE) {
    return;
  }
  int savedPercent=(int)(100 - (end * 100 / fileSize));
  if (savedPercent < minPercent) {
    return;
  }
  fileStore.truncate(end);
}

Fixed version (ground truth):
/** 
 * Shrink the file if possible, and if at least a given percentage can be saved.
 * @param minPercent the minimum percentage to save
 */
private void shrinkFileIfPossible(int minPercent){
  long end=getFileLengthInUse();
  long fileSize=fileStore.size();
  if (end >= fileSize) {
    return;
  }
  if (minPercent > 0 && fileSize - end < BLOCK_SIZE) {
    return;
  }
  int savedPercent=(int)(100 - (end * 100 / fileSize));
  if (savedPercent < minPercent) {
    return;
  }
  fileStore.truncate(end);
}
Program: 15867
Project: 15867
Buggy source:
/** 
 * Set the size of the write buffer, in MB (for file-based stores). Unless auto-commit is disabled, changes are automatically saved if there are more than this amount of changes. <p> The default is 4 MB. <p> When the value is set to 0 or lower, data is not automatically stored.
 * @param mb the write buffer size, in megabytes
 * @return this
 */
public Builder autoCommitBufferSize(int mb){
  return set("String_Node_Str",mb);
}

Fixed version (ground truth):
/** 
 * Set the size of the write buffer, in KB (for file-based stores). Unless auto-commit is disabled, changes are automatically saved if there are more than this amount of changes. <p> The default is 512 KB. <p> When the value is set to 0 or lower, data is not automatically stored.
 * @param kb the write buffer size, in kilobytes
 * @return this
 */
public Builder autoCommitBufferSize(int kb){
  return set("String_Node_Str",kb);
}
Program: 15871
Project: 15871
Buggy source:
@Override public void remove(Session session){
  if (!treeMap.isClosed()) {
    treeMap.removeMap();
  }
}

Fixed version (ground truth):
@Override public void remove(Session session){
  if (!treeMap.isClosed()) {
    MVStore store=session.getDatabase().getMvStore().getStore();
    store.removeMap(treeMap);
  }
}
Program: 15873
Project: 15873
Buggy source:
/** 
 * Rename a map.
 * @param map the map
 * @param newName the new name
 */
void renameMap(MVMap<?,?> map,String newName){
  checkOpen();
  DataUtils.checkArgument(map != meta,"String_Node_Str");
  int id=map.getId();
  String oldName=getMapName(id);
  if (oldName.equals(newName)) {
    return;
  }
  DataUtils.checkArgument(!meta.containsKey("String_Node_Str" + newName),"String_Node_Str",newName);
  markMetaChanged();
  meta.remove("String_Node_Str" + oldName);
  meta.put("String_Node_Str" + id,map.asString(newName));
  meta.put("String_Node_Str" + newName,Integer.toString(id));
}

Fixed version (ground truth):
/** 
 * Rename a map.
 * @param map the map
 * @param newName the new name
 */
public void renameMap(MVMap<?,?> map,String newName){
  checkOpen();
  DataUtils.checkArgument(map != meta,"String_Node_Str");
  int id=map.getId();
  String oldName=getMapName(id);
  if (oldName.equals(newName)) {
    return;
  }
  DataUtils.checkArgument(!meta.containsKey("String_Node_Str" + newName),"String_Node_Str",newName);
  markMetaChanged();
  meta.remove("String_Node_Str" + oldName);
  meta.put("String_Node_Str" + id,map.asString(newName));
  meta.put("String_Node_Str" + newName,Integer.toString(id));
}
Program: 15875
Project: 15875
Buggy source:
/** 
 * Remove a map.
 * @param id the map id
 */
void removeMap(int id){
  String name=getMapName(id);
  markMetaChanged();
  meta.remove("String_Node_Str" + id);
  meta.remove("String_Node_Str" + name);
  meta.remove("String_Node_Str" + id);
  maps.remove(id);
}

Fixed version (ground truth):
/** 
 * Remove a map.
 * @param map the map
 */
public void removeMap(MVMap<?,?> map){
  checkOpen();
  DataUtils.checkArgument(map != meta,"String_Node_Str");
  map.clear();
  int id=map.getId();
  String name=getMapName(id);
  markMetaChanged();
  meta.remove("String_Node_Str" + id);
  meta.remove("String_Node_Str" + name);
  meta.remove("String_Node_Str" + id);
  maps.remove(id);
}
Program: 15876
Project: 15876
Buggy source:
@Override public void remove(Session session){
  TransactionMap<Value,Value> map=getMap(session);
  if (!map.isClosed()) {
    map.removeMap();
  }
}

Fixed version (ground truth):
@Override public void remove(Session session){
  TransactionMap<Value,Value> map=getMap(session);
  if (!map.isClosed()) {
    Transaction t=mvTable.getTransaction(session);
    t.removeMap(map);
  }
}
Program: 15877
Project: 15877
Buggy source:
public MVPrimaryIndex(Database db,MVTable table,int id,IndexColumn[] columns,IndexType indexType){
  this.mvTable=table;
  initBaseIndex(table,id,table.getName() + "String_Node_Str",columns,indexType);
  int[] sortTypes=new int[columns.length];
  for (int i=0; i < columns.length; i++) {
    sortTypes[i]=SortOrder.ASCENDING;
  }
  ValueDataType keyType=new ValueDataType(null,null,null);
  ValueDataType valueType=new ValueDataType(db.getCompareMode(),db,sortTypes);
  mapName="String_Node_Str" + getId();
  MVMap.Builder<Value,Value> mapBuilder=new MVMap.Builder<Value,Value>().keyType(keyType).valueType(valueType);
  dataMap=mvTable.getTransaction(null).openMap(mapName,mapBuilder);
  Value k=dataMap.lastKey();
  lastKey=k == null ? 0 : k.getLong();
}

Fixed version (ground truth):
public MVPrimaryIndex(Database db,MVTable table,int id,IndexColumn[] columns,IndexType indexType){
  this.mvTable=table;
  initBaseIndex(table,id,table.getName() + "String_Node_Str",columns,indexType);
  int[] sortTypes=new int[columns.length];
  for (int i=0; i < columns.length; i++) {
    sortTypes[i]=SortOrder.ASCENDING;
  }
  ValueDataType keyType=new ValueDataType(null,null,null);
  ValueDataType valueType=new ValueDataType(db.getCompareMode(),db,sortTypes);
  mapName="String_Node_Str" + getId();
  dataMap=mvTable.getTransaction(null).openMap(mapName,keyType,valueType);
  Value k=dataMap.lastKey();
  lastKey=k == null ? 0 : k.getLong();
}
Program: 15878
Project: 15878
Buggy source:
public MVSecondaryIndex(Database db,MVTable table,int id,String indexName,IndexColumn[] columns,IndexType indexType){
  this.mvTable=table;
  initBaseIndex(table,id,indexName,columns,indexType);
  if (!database.isStarting()) {
    checkIndexColumnTypes(columns);
  }
  keyColumns=columns.length + 1;
  int[] sortTypes=new int[keyColumns];
  for (int i=0; i < columns.length; i++) {
    sortTypes[i]=columns[i].sortType;
  }
  sortTypes[keyColumns - 1]=SortOrder.ASCENDING;
  mapName="String_Node_Str" + getId();
  ValueDataType keyType=new ValueDataType(db.getCompareMode(),db,sortTypes);
  ValueDataType valueType=new ValueDataType(null,null,null);
  MVMap.Builder<Value,Value> mapBuilder=new MVMap.Builder<Value,Value>().keyType(keyType).valueType(valueType);
  dataMap=mvTable.getTransaction(null).openMap(mapName,mapBuilder);
  if (keyType != dataMap.map.getKeyType()) {
    throw DbException.throwInternalError("String_Node_Str");
  }
}

Fixed version (ground truth):
public MVSecondaryIndex(Database db,MVTable table,int id,String indexName,IndexColumn[] columns,IndexType indexType){
  this.mvTable=table;
  initBaseIndex(table,id,indexName,columns,indexType);
  if (!database.isStarting()) {
    checkIndexColumnTypes(columns);
  }
  keyColumns=columns.length + 1;
  int[] sortTypes=new int[keyColumns];
  for (int i=0; i < columns.length; i++) {
    sortTypes[i]=columns[i].sortType;
  }
  sortTypes[keyColumns - 1]=SortOrder.ASCENDING;
  mapName="String_Node_Str" + getId();
  ValueDataType keyType=new ValueDataType(db.getCompareMode(),db,sortTypes);
  ValueDataType valueType=new ValueDataType(null,null,null);
  dataMap=mvTable.getTransaction(null).openMap(mapName,keyType,valueType);
  if (keyType != dataMap.map.getKeyType()) {
    throw DbException.throwInternalError("String_Node_Str");
  }
}
Program: 15879
Project: 15879
Buggy source:
@Override public void remove(Session session){
  TransactionMap<Value,Value> map=getMap(session);
  if (!map.isClosed()) {
    map.removeMap();
  }
}

Fixed version (ground truth):
@Override public void remove(Session session){
  TransactionMap<Value,Value> map=getMap(session);
  if (!map.isClosed()) {
    Transaction t=mvTable.getTransaction(session);
    t.removeMap(map);
  }
}
Program: 15882
Project: 15882
Buggy source:
/** 
 * Evict cold entries (resident and non-resident) until the memory limit is reached. The new entry is added as a cold entry, except if it is the only entry.
 * @param newCold a new cold entry
 */
private void evict(Entry<V> newCold){
  while (queueSize < (mapSize >>> 5)) {
    convertOldestHotToCold();
  }
  if (stackSize > 0) {
    addToQueue(queue,newCold);
  }
  while (usedMemory > maxMemory && queueSize > 1) {
    Entry<V> e=queue.queuePrev;
    usedMemory-=e.memory;
    removeFromQueue(e);
    e.value=null;
    e.memory=0;
    addToQueue(queue2,e);
    while (queue2Size + queue2Size > stackSize) {
      e=queue2.queuePrev;
      int hash=getHash(e.key);
      remove(e.key,hash);
    }
  }
}

Fixed version (ground truth):
/** 
 * Evict cold entries (resident and non-resident) until the memory limit is reached. The new entry is added as a cold entry, except if it is the only entry.
 * @param newCold a new cold entry
 */
private void evict(Entry<V> newCold){
  while (queueSize <= (mapSize >>> 5)) {
    convertOldestHotToCold();
  }
  if (stackSize > 0) {
    addToQueue(queue,newCold);
  }
  while (usedMemory > maxMemory && queueSize > 1) {
    Entry<V> e=queue.queuePrev;
    usedMemory-=e.memory;
    removeFromQueue(e);
    e.value=null;
    e.memory=0;
    addToQueue(queue2,e);
    while (queue2Size + queue2Size > stackSize) {
      e=queue2.queuePrev;
      int hash=getHash(e.key);
      remove(e.key,hash);
    }
  }
}
Program: 15883
Project: 15883
Buggy source:
/** 
 * Evict cold entries (resident and non-resident) until the memory limit is reached. The new entry is added as a cold entry, except if it is the only entry.
 * @param newCold a new cold entry
 */
private void evict(Entry<K,V> newCold){
  while (queueSize < (mapSize >>> 5)) {
    convertOldestHotToCold();
  }
  if (stackSize > 0) {
    addToQueue(queue,newCold);
  }
  while (usedMemory > maxMemory && queueSize > 1) {
    Entry<K,V> e=queue.queuePrev;
    usedMemory-=e.memory;
    removeFromQueue(e);
    e.value=null;
    e.memory=0;
    addToQueue(queue2,e);
    while (queue2Size + queue2Size > stackSize) {
      e=queue2.queuePrev;
      int hash=getHash(e.key);
      remove(e.key,hash);
    }
  }
}

Fixed version (ground truth):
/** 
 * Evict cold entries (resident and non-resident) until the memory limit is reached. The new entry is added as a cold entry, except if it is the only entry.
 * @param newCold a new cold entry
 */
private void evict(Entry<K,V> newCold){
  while (queueSize <= (mapSize >>> 5)) {
    convertOldestHotToCold();
  }
  if (stackSize > 0) {
    addToQueue(queue,newCold);
  }
  while (usedMemory > maxMemory && queueSize > 1) {
    Entry<K,V> e=queue.queuePrev;
    usedMemory-=e.memory;
    removeFromQueue(e);
    e.value=null;
    e.memory=0;
    addToQueue(queue2,e);
    while (queue2Size + queue2Size > stackSize) {
      e=queue2.queuePrev;
      int hash=getHash(e.key);
      remove(e.key,hash);
    }
  }
}
Program: 15885
Project: 15885
Buggy source:
private void readMeta(){
  chunks.clear();
  Chunk header=readChunkHeader(rootChunkStart);
  lastChunkId=header.id;
  chunks.put(header.id,header);
  meta.setRootPos(header.metaRootPos,-1);
  String s=meta.get("String_Node_Str" + lastChunkId);
  Chunk h2=Chunk.fromString(s);
  h2.start=header.start;
  h2.length=header.length;
  h2.metaRootPos=header.metaRootPos;
  h2.pageCount=header.pageCount;
  h2.pageCountLive=header.pageCountLive;
  h2.maxLength=header.maxLength;
  h2.maxLengthLive=header.maxLengthLive;
  chunks.put(header.id,h2);
  for (Iterator<String> it=meta.keyIterator("String_Node_Str"); it.hasNext(); ) {
    s=it.next();
    if (!s.startsWith("String_Node_Str")) {
      break;
    }
    s=meta.get(s);
    Chunk c=Chunk.fromString(s);
    if (!chunks.containsKey(c.id)) {
      chunks.put(c.id,c);
    }
  }
  for (  Chunk c : chunks.values()) {
    if (c.pageCountLive == 0) {
      registerFreePage(currentVersion,c.id,0,0);
    }
    if (c.id > lastChunkId) {
      System.out.println("String_Node_Str");
    }
    lastChunkId=Math.max(c.id,lastChunkId);
    if (c.start == Long.MAX_VALUE) {
      ;
      ;
      System.out.println("String_Node_Str");
      continue;
    }
    int len=MathUtils.roundUpInt(c.length,BLOCK_SIZE) + BLOCK_SIZE;
    fileStore.markUsed(c.start,len);
  }
}

Fixed version (ground truth):
private void readMeta(){
  chunks.clear();
  Chunk header=readChunkHeader(rootChunkStart);
  lastChunkId=header.id;
  chunks.put(header.id,header);
  meta.setRootPos(header.metaRootPos,-1);
  String s=meta.get("String_Node_Str" + lastChunkId);
  Chunk h2=Chunk.fromString(s);
  h2.start=header.start;
  h2.length=header.length;
  h2.metaRootPos=header.metaRootPos;
  h2.pageCount=header.pageCount;
  h2.pageCountLive=header.pageCountLive;
  h2.maxLength=header.maxLength;
  h2.maxLengthLive=header.maxLengthLive;
  chunks.put(header.id,h2);
  for (Iterator<String> it=meta.keyIterator("String_Node_Str"); it.hasNext(); ) {
    s=it.next();
    if (!s.startsWith("String_Node_Str")) {
      break;
    }
    s=meta.get(s);
    Chunk c=Chunk.fromString(s);
    if (!chunks.containsKey(c.id)) {
      chunks.put(c.id,c);
    }
  }
  for (  Chunk c : chunks.values()) {
    if (c.pageCountLive == 0) {
      registerFreePage(currentVersion,c.id,0,0);
    }
    int len=MathUtils.roundUpInt(c.length,BLOCK_SIZE) + BLOCK_SIZE;
    fileStore.markUsed(c.start,len);
  }
}
Program: 15887
Project: 15887
Buggy source:
/** 
 * Read a page.
 * @param map the map
 * @param pos the page position
 * @return the page
 */
Page readPage(MVMap<?,?> map,long pos){
  Page p=cache.get(pos);
  if (p == null) {
    Chunk c=getChunk(pos);
    if (c == null) {
      throw DataUtils.newIllegalStateException(DataUtils.ERROR_FILE_CORRUPT,"String_Node_Str",DataUtils.getPageChunkId(pos));
    }
    long filePos=c.start;
    filePos+=DataUtils.getPageOffset(pos);
    p=Page.read(fileStore,map,pos,filePos,fileStore.size());
    cache.put(pos,p,p.getMemory());
  }
  return p;
}

Fixed version (ground truth):
/** 
 * Read a page.
 * @param map the map
 * @param pos the page position
 * @return the page
 */
Page readPage(MVMap<?,?> map,long pos){
  Page p=cache.get(pos);
  if (p == null) {
    Chunk c=getChunk(pos);
    long filePos=c.start;
    filePos+=DataUtils.getPageOffset(pos);
    if (filePos < 0) {
      throw DataUtils.newIllegalStateException(DataUtils.ERROR_FILE_CORRUPT,"String_Node_Str",filePos);
    }
    p=Page.read(fileStore,map,pos,filePos,fileStore.size());
    cache.put(pos,p,p.getMemory());
  }
  return p;
}
Program: 15888
Project: 15888
Buggy source:
private void copyLive(Chunk chunk,ArrayList<Chunk> old){
  ByteBuffer buff=fileStore.readFully(chunk.start,chunk.length);
  Chunk.fromHeader(buff,chunk.start);
  int chunkLength=chunk.length;
  markMetaChanged();
  while (buff.position() < chunkLength) {
    int start=buff.position();
    int pageLength=buff.getInt();
    buff.getShort();
    int mapId=DataUtils.readVarInt(buff);
    @SuppressWarnings("String_Node_Str") MVMap<Object,Object> map=(MVMap<Object,Object>)getMap(mapId);
    if (map == null) {
      buff.position(start + pageLength);
      continue;
    }
    buff.position(start);
    Page page=new Page(map,0);
    page.read(buff,chunk.id,buff.position(),chunk.length);
    for (int i=0; i < page.getKeyCount(); i++) {
      Object k=page.getKey(i);
      Page p=map.getPage(k);
      if (p == null) {
      }
 else       if (p.getPos() < 0) {
      }
 else {
        Chunk c=getChunk(p.getPos());
        if (old.contains(c)) {
          Object value=map.remove(k);
          map.put(k,value);
        }
      }
    }
  }
}

Fixed version (ground truth):
private void copyLive(Chunk chunk,ArrayList<Chunk> old){
  ByteBuffer buff=fileStore.readFully(chunk.start,chunk.length);
  Chunk.fromHeader(buff,chunk.start);
  int chunkLength=chunk.length;
  markMetaChanged();
  while (buff.position() < chunkLength) {
    int start=buff.position();
    int pageLength=buff.getInt();
    buff.getShort();
    int mapId=DataUtils.readVarInt(buff);
    @SuppressWarnings("String_Node_Str") MVMap<Object,Object> map=(MVMap<Object,Object>)getMap(mapId);
    if (map == null) {
      buff.position(start + pageLength);
      continue;
    }
    buff.position(start);
    Page page=new Page(map,0);
    page.read(buff,chunk.id,buff.position(),chunk.length);
    for (int i=0; i < page.getKeyCount(); i++) {
      Object k=page.getKey(i);
      Page p=map.getPage(k);
      if (p == null) {
      }
 else       if (p.getPos() == 0) {
      }
 else {
        Chunk c=getChunk(p.getPos());
        if (old.contains(c)) {
          Object value=map.remove(k);
          map.put(k,value);
        }
      }
    }
  }
}
Program: 15889
Project: 15889
Buggy source:
/** 
 * Get the chunk for the given position.
 * @param pos the position
 * @return the chunk
 */
Chunk getChunk(long pos){
  return chunks.get(DataUtils.getPageChunkId(pos));
}

Fixed version (ground truth):
/** 
 * Get the chunk for the given position.
 * @param pos the position
 * @return the chunk
 */
Chunk getChunk(long pos){
  int chunkId=DataUtils.getPageChunkId(pos);
  Chunk c=chunks.get(chunkId);
  if (c == null) {
    String s=meta.get("String_Node_Str" + chunkId);
    if (s == null) {
      throw DataUtils.newIllegalStateException(DataUtils.ERROR_FILE_CORRUPT,"String_Node_Str",DataUtils.getPageChunkId(pos));
    }
    c=Chunk.fromString(s);
    chunks.put(c.id,c);
  }
  return c;
}
Program: 15890
Project: 15890
Buggy source:
private void readMeta(){
  Chunk header=readChunkHeader(rootChunkStart);
  lastChunkId=header.id;
  chunks.put(header.id,header);
  meta.setRootPos(header.metaRootPos,-1);
  for (int id=lastChunkId; id >= 0; id--) {
    String s=meta.get("String_Node_Str" + id);
    if (s == null) {
      continue;
    }
    Chunk c=Chunk.fromString(s);
    if (c.id == header.id) {
      c.start=header.start;
      c.length=header.length;
      c.metaRootPos=header.metaRootPos;
      c.pageCount=header.pageCount;
      c.pageCountLive=header.pageCountLive;
      c.maxLength=header.maxLength;
      c.maxLengthLive=header.maxLengthLive;
    }
    lastChunkId=Math.max(c.id,lastChunkId);
    chunks.put(c.id,c);
    if (c.pageCountLive == 0) {
      registerFreePage(currentVersion,c.id,0,0);
    }
  }
  for (  Chunk c : chunks.values()) {
    if (c.start == Long.MAX_VALUE) {
      continue;
    }
    int len=MathUtils.roundUpInt(c.length,BLOCK_SIZE) + BLOCK_SIZE;
    fileStore.markUsed(c.start,len);
  }
}

Fixed version (ground truth):
private void readMeta(){
  chunks.clear();
  Chunk header=readChunkHeader(rootChunkStart);
  lastChunkId=header.id;
  chunks.put(header.id,header);
  meta.setRootPos(header.metaRootPos,-1);
  String s=meta.get("String_Node_Str" + lastChunkId);
  Chunk h2=Chunk.fromString(s);
  h2.start=header.start;
  h2.length=header.length;
  h2.metaRootPos=header.metaRootPos;
  h2.pageCount=header.pageCount;
  h2.pageCountLive=header.pageCountLive;
  h2.maxLength=header.maxLength;
  h2.maxLengthLive=header.maxLengthLive;
  chunks.put(header.id,h2);
  for (Iterator<String> it=meta.keyIterator("String_Node_Str"); it.hasNext(); ) {
    s=it.next();
    if (!s.startsWith("String_Node_Str")) {
      break;
    }
    s=meta.get(s);
    Chunk c=Chunk.fromString(s);
    if (!chunks.containsKey(c.id)) {
      chunks.put(c.id,c);
    }
  }
  for (  Chunk c : chunks.values()) {
    if (c.pageCountLive == 0) {
      registerFreePage(currentVersion,c.id,0,0);
    }
    if (c.id > lastChunkId) {
      System.out.println("String_Node_Str");
    }
    lastChunkId=Math.max(c.id,lastChunkId);
    if (c.start == Long.MAX_VALUE) {
      ;
      ;
      System.out.println("String_Node_Str");
      continue;
    }
    int len=MathUtils.roundUpInt(c.length,BLOCK_SIZE) + BLOCK_SIZE;
    fileStore.markUsed(c.start,len);
  }
}