nus-yam/ex-repair huggingface dataset:
Program: 15797
Project: 15797
Buggy source:
private void rebuildIndex(Session session,MVIndex index,String indexName){
  try {
    if (session.getDatabase().getMvStore() == null) {
      rebuildIndexBuffered(session,index);
    }
 else {
      rebuildIndexBlockMerge(session,index);
    }
  }
 catch (  DbException e) {
    getSchema().freeUniqueName(indexName);
    try {
      index.remove(session);
    }
 catch (    DbException e2) {
      trace.error(e2,"String_Node_Str");
      throw e2;
    }
    throw e;
  }
}

Fixed version (ground truth):
private void rebuildIndex(Session session,MVIndex index,String indexName){
  try {
    if (session.getDatabase().getMvStore() == null || index instanceof MVSpatialIndex) {
      rebuildIndexBuffered(session,index);
    }
 else {
      rebuildIndexBlockMerge(session,index);
    }
  }
 catch (  DbException e) {
    getSchema().freeUniqueName(indexName);
    try {
      index.remove(session);
    }
 catch (    DbException e2) {
      trace.error(e2,"String_Node_Str");
      throw e2;
    }
    throw e;
  }
}
Program: 15806
Project: 15806
Buggy source:
@Override public Value divide(Value v){
  ValueDecimal dec=(ValueDecimal)v;
  if (dec.value.signum() == 0) {
    throw DbException.get(ErrorCode.DIVISION_BY_ZERO_1,getSQL());
  }
  BigDecimal bd=value.divide(dec.value,value.scale() + DIVIDE_SCALE_ADD,BigDecimal.ROUND_HALF_DOWN);
  if (bd.signum() == 0) {
    bd=BigDecimal.ZERO;
  }
 else   if (bd.scale() > 0) {
    if (!bd.unscaledValue().testBit(0)) {
      String s=bd.toString();
      int i=s.length() - 1;
      while (i >= 0 && s.charAt(i) == '0') {
        i--;
      }
      if (i < s.length() - 1) {
        s=s.substring(0,i + 1);
        bd=new BigDecimal(s);
      }
    }
  }
  return ValueDecimal.get(bd);
}

Fixed version (ground truth):
@Override public Value divide(Value v){
  ValueDecimal dec=(ValueDecimal)v;
  if (dec.value.signum() == 0) {
    throw DbException.get(ErrorCode.DIVISION_BY_ZERO_1,getSQL());
  }
  BigDecimal bd=value.divide(dec.value,value.scale() + DIVIDE_SCALE_ADD,BigDecimal.ROUND_HALF_DOWN);
  if (bd.signum() == 0) {
    bd=BigDecimal.ZERO;
  }
 else   if (bd.scale() > 0) {
    if (!bd.unscaledValue().testBit(0)) {
      bd=bd.stripTrailingZeros();
    }
  }
  return ValueDecimal.get(bd);
}
Program: 15807
Project: 15807
Buggy source:
@Override public Value divide(Value v){
  ValueDecimal dec=(ValueDecimal)v;
  if (dec.value.signum() == 0) {
    throw DbException.get(ErrorCode.DIVISION_BY_ZERO_1,getSQL());
  }
  BigDecimal bd=value.divide(dec.value,value.scale() + DIVIDE_SCALE_ADD,BigDecimal.ROUND_HALF_DOWN);
  if (bd.signum() == 0) {
    bd=BigDecimal.ZERO;
  }
 else   if (bd.scale() > 0) {
    if (!bd.unscaledValue().testBit(0)) {
      String s=bd.toString();
      int i=s.length() - 1;
      while (i >= 0 && s.charAt(i) == '0') {
        i--;
      }
      if (i < s.length() - 1) {
        s=s.substring(0,i + 1);
        bd=new BigDecimal(s);
      }
    }
  }
  return ValueDecimal.get(bd);
}

Fixed version (ground truth):
@Override public Value divide(Value v){
  ValueDecimal dec=(ValueDecimal)v;
  if (dec.value.signum() == 0) {
    throw DbException.get(ErrorCode.DIVISION_BY_ZERO_1,getSQL());
  }
  BigDecimal bd=value.divide(dec.value,value.scale() + DIVIDE_SCALE_ADD,BigDecimal.ROUND_HALF_DOWN);
  if (bd.signum() == 0) {
    bd=BigDecimal.ZERO;
  }
 else   if (bd.scale() > 0) {
    if (!bd.unscaledValue().testBit(0)) {
      bd=bd.stripTrailingZeros();
    }
  }
  return ValueDecimal.get(bd);
}
Program: 15810
Project: 15810
Buggy source:
public FunctionTable(Schema schema,Session session,Expression functionExpr,FunctionCall function){
  super(schema,0,function.getName(),false,true);
  this.functionExpr=functionExpr;
  this.function=function;
  if (function instanceof TableFunction) {
    rowCount=((TableFunction)function).getRowCount();
  }
 else {
    rowCount=Long.MAX_VALUE;
  }
  function.optimize(session);
  int type=function.getType();
  if (type != Value.RESULT_SET) {
    throw DbException.get(ErrorCode.FUNCTION_MUST_RETURN_RESULT_SET_1,function.getName());
  }
  int params=function.getParameterCount();
  Expression[] columnListArgs=new Expression[params];
  Expression[] args=function.getArgs();
  for (int i=0; i < params; i++) {
    args[i]=args[i].optimize(session);
    columnListArgs[i]=args[i];
  }
  ValueResultSet template=function.getValueForColumnList(session,columnListArgs);
  if (template == null) {
    throw DbException.get(ErrorCode.FUNCTION_MUST_RETURN_RESULT_SET_1,function.getName());
  }
  ResultSet rs=template.getResultSet();
  try {
    ResultSetMetaData meta=rs.getMetaData();
    int columnCount=meta.getColumnCount();
    Column[] cols=new Column[columnCount];
    for (int i=0; i < columnCount; i++) {
      cols[i]=new Column(meta.getColumnName(i + 1),DataType.getValueTypeFromResultSet(meta,i + 1),meta.getPrecision(i + 1),meta.getScale(i + 1),meta.getColumnDisplaySize(i + 1));
    }
    setColumns(cols);
  }
 catch (  SQLException e) {
    throw DbException.convert(e);
  }
}

Fixed version (ground truth):
public FunctionTable(Schema schema,Session session,Expression functionExpr,FunctionCall function){
  super(schema,0,function.getName(),false,true);
  this.functionExpr=functionExpr;
  this.function=function;
  if (function instanceof TableFunction) {
    rowCount=((TableFunction)function).getRowCount();
  }
 else {
    rowCount=Long.MAX_VALUE;
  }
  function.optimize(session);
  int type=function.getType();
  if (type != Value.RESULT_SET) {
    throw DbException.get(ErrorCode.FUNCTION_MUST_RETURN_RESULT_SET_1,function.getName());
  }
  Expression[] args=function.getArgs();
  int numParams=args.length;
  Expression[] columnListArgs=new Expression[numParams];
  for (int i=0; i < numParams; i++) {
    args[i]=args[i].optimize(session);
    columnListArgs[i]=args[i];
  }
  ValueResultSet template=function.getValueForColumnList(session,columnListArgs);
  if (template == null) {
    throw DbException.get(ErrorCode.FUNCTION_MUST_RETURN_RESULT_SET_1,function.getName());
  }
  ResultSet rs=template.getResultSet();
  try {
    ResultSetMetaData meta=rs.getMetaData();
    int columnCount=meta.getColumnCount();
    Column[] cols=new Column[columnCount];
    for (int i=0; i < columnCount; i++) {
      cols[i]=new Column(meta.getColumnName(i + 1),DataType.getValueTypeFromResultSet(meta,i + 1),meta.getPrecision(i + 1),meta.getScale(i + 1),meta.getColumnDisplaySize(i + 1));
    }
    setColumns(cols);
  }
 catch (  SQLException e) {
    throw DbException.convert(e);
  }
}
Program: 15811
Project: 15811
Buggy source:
@Override public void test() throws Exception {
  deleteDb("String_Node_Str");
  testVersion();
  testFunctionTable();
  testArrayParameters();
  testDefaultConnection();
  testFunctionInSchema();
  testGreatest();
  testSource();
  testDynamicArgumentAndReturn();
  testUUID();
  testWhiteSpacesInParameters();
  testSchemaSearchPath();
  testDeterministic();
  testTransactionId();
  testPrecision();
  testMathFunctions();
  testVarArgs();
  testAggregate();
  testAggregateType();
  testFunctions();
  testFileRead();
  testValue();
  testNvl2();
  testConcatWs();
  testTruncate();
  testToCharFromDateTime();
  testToCharFromNumber();
  testToCharFromText();
  deleteDb("String_Node_Str");
  FileUtils.deleteRecursive(TEMP_DIR,true);
}

Fixed version (ground truth):
@Override public void test() throws Exception {
  deleteDb("String_Node_Str");
  testVersion();
  testFunctionTable();
  testFunctionTableVarArgs();
  testArrayParameters();
  testDefaultConnection();
  testFunctionInSchema();
  testGreatest();
  testSource();
  testDynamicArgumentAndReturn();
  testUUID();
  testWhiteSpacesInParameters();
  testSchemaSearchPath();
  testDeterministic();
  testTransactionId();
  testPrecision();
  testMathFunctions();
  testVarArgs();
  testAggregate();
  testAggregateType();
  testFunctions();
  testFileRead();
  testValue();
  testNvl2();
  testConcatWs();
  testTruncate();
  testToCharFromDateTime();
  testToCharFromNumber();
  testToCharFromText();
  deleteDb("String_Node_Str");
  FileUtils.deleteRecursive(TEMP_DIR,true);
}
Program: 15812
Project: 15812
Buggy source:
public FunctionTable(Schema schema,Session session,Expression functionExpr,FunctionCall function){
  super(schema,0,function.getName(),false,true);
  this.functionExpr=functionExpr;
  this.function=function;
  if (function instanceof TableFunction) {
    rowCount=((TableFunction)function).getRowCount();
  }
 else {
    rowCount=Long.MAX_VALUE;
  }
  function.optimize(session);
  int type=function.getType();
  if (type != Value.RESULT_SET) {
    throw DbException.get(ErrorCode.FUNCTION_MUST_RETURN_RESULT_SET_1,function.getName());
  }
  int params=function.getParameterCount();
  Expression[] columnListArgs=new Expression[params];
  Expression[] args=function.getArgs();
  for (int i=0; i < params; i++) {
    args[i]=args[i].optimize(session);
    columnListArgs[i]=args[i];
  }
  ValueResultSet template=function.getValueForColumnList(session,columnListArgs);
  if (template == null) {
    throw DbException.get(ErrorCode.FUNCTION_MUST_RETURN_RESULT_SET_1,function.getName());
  }
  ResultSet rs=template.getResultSet();
  try {
    ResultSetMetaData meta=rs.getMetaData();
    int columnCount=meta.getColumnCount();
    Column[] cols=new Column[columnCount];
    for (int i=0; i < columnCount; i++) {
      cols[i]=new Column(meta.getColumnName(i + 1),DataType.getValueTypeFromResultSet(meta,i + 1),meta.getPrecision(i + 1),meta.getScale(i + 1),meta.getColumnDisplaySize(i + 1));
    }
    setColumns(cols);
  }
 catch (  SQLException e) {
    throw DbException.convert(e);
  }
}

Fixed version (ground truth):
public FunctionTable(Schema schema,Session session,Expression functionExpr,FunctionCall function){
  super(schema,0,function.getName(),false,true);
  this.functionExpr=functionExpr;
  this.function=function;
  if (function instanceof TableFunction) {
    rowCount=((TableFunction)function).getRowCount();
  }
 else {
    rowCount=Long.MAX_VALUE;
  }
  function.optimize(session);
  int type=function.getType();
  if (type != Value.RESULT_SET) {
    throw DbException.get(ErrorCode.FUNCTION_MUST_RETURN_RESULT_SET_1,function.getName());
  }
  Expression[] args=function.getArgs();
  int numParams=args.length;
  Expression[] columnListArgs=new Expression[numParams];
  for (int i=0; i < numParams; i++) {
    args[i]=args[i].optimize(session);
    columnListArgs[i]=args[i];
  }
  ValueResultSet template=function.getValueForColumnList(session,columnListArgs);
  if (template == null) {
    throw DbException.get(ErrorCode.FUNCTION_MUST_RETURN_RESULT_SET_1,function.getName());
  }
  ResultSet rs=template.getResultSet();
  try {
    ResultSetMetaData meta=rs.getMetaData();
    int columnCount=meta.getColumnCount();
    Column[] cols=new Column[columnCount];
    for (int i=0; i < columnCount; i++) {
      cols[i]=new Column(meta.getColumnName(i + 1),DataType.getValueTypeFromResultSet(meta,i + 1),meta.getPrecision(i + 1),meta.getScale(i + 1),meta.getColumnDisplaySize(i + 1));
    }
    setColumns(cols);
  }
 catch (  SQLException e) {
    throw DbException.convert(e);
  }
}
Program: 15813
Project: 15813
Buggy source:
@Override public void test() throws Exception {
  deleteDb("String_Node_Str");
  testVersion();
  testFunctionTable();
  testArrayParameters();
  testDefaultConnection();
  testFunctionInSchema();
  testGreatest();
  testSource();
  testDynamicArgumentAndReturn();
  testUUID();
  testWhiteSpacesInParameters();
  testSchemaSearchPath();
  testDeterministic();
  testTransactionId();
  testPrecision();
  testMathFunctions();
  testVarArgs();
  testAggregate();
  testAggregateType();
  testFunctions();
  testFileRead();
  testValue();
  testNvl2();
  testConcatWs();
  testTruncate();
  testToCharFromDateTime();
  testToCharFromNumber();
  testToCharFromText();
  deleteDb("String_Node_Str");
  FileUtils.deleteRecursive(TEMP_DIR,true);
}

Fixed version (ground truth):
@Override public void test() throws Exception {
  deleteDb("String_Node_Str");
  testVersion();
  testFunctionTable();
  testFunctionTableVarArgs();
  testArrayParameters();
  testDefaultConnection();
  testFunctionInSchema();
  testGreatest();
  testSource();
  testDynamicArgumentAndReturn();
  testUUID();
  testWhiteSpacesInParameters();
  testSchemaSearchPath();
  testDeterministic();
  testTransactionId();
  testPrecision();
  testMathFunctions();
  testVarArgs();
  testAggregate();
  testAggregateType();
  testFunctions();
  testFileRead();
  testValue();
  testNvl2();
  testConcatWs();
  testTruncate();
  testToCharFromDateTime();
  testToCharFromNumber();
  testToCharFromText();
  deleteDb("String_Node_Str");
  FileUtils.deleteRecursive(TEMP_DIR,true);
}
Program: 15814
Project: 15814
Buggy source:
@Override public void start(){
  try {
    serverSocket=NetUtils.createServerSocket(port,false);
  }
 catch (  DbException e) {
    if (!portIsSet) {
      serverSocket=NetUtils.createServerSocket(0,false);
    }
 else {
      throw e;
    }
  }
  port=serverSocket.getLocalPort();
}

Fixed version (ground truth):
@Override public void start(){
  stop=false;
  try {
    serverSocket=NetUtils.createServerSocket(port,false);
  }
 catch (  DbException e) {
    if (!portIsSet) {
      serverSocket=NetUtils.createServerSocket(0,false);
    }
 else {
      throw e;
    }
  }
  port=serverSocket.getLocalPort();
}
Program: 15815
Project: 15815
Buggy source:
@Override public void start(){
  try {
    serverSocket=NetUtils.createServerSocket(port,false);
  }
 catch (  DbException e) {
    if (!portIsSet) {
      serverSocket=NetUtils.createServerSocket(0,false);
    }
 else {
      throw e;
    }
  }
  port=serverSocket.getLocalPort();
}

Fixed version (ground truth):
@Override public void start(){
  stop=false;
  try {
    serverSocket=NetUtils.createServerSocket(port,false);
  }
 catch (  DbException e) {
    if (!portIsSet) {
      serverSocket=NetUtils.createServerSocket(0,false);
    }
 else {
      throw e;
    }
  }
  port=serverSocket.getLocalPort();
}
Program: 15816
Project: 15816
Buggy source:
/** 
 * Compare two values, given the values are not NULL.
 * @param database the database
 * @param l the first value
 * @param r the second value
 * @param compareType the compare type
 * @return the result of the comparison (1 if the first value is bigger, -1if smaller, 0 if both are equal)
 */
static boolean compareNotNull(Database database,Value l,Value r,int compareType){
  boolean result;
switch (compareType) {
case EQUAL:
case EQUAL_NULL_SAFE:
    result=database.areEqual(l,r);
  break;
case NOT_EQUAL:
case NOT_EQUAL_NULL_SAFE:
result=!database.areEqual(l,r);
break;
case BIGGER_EQUAL:
result=database.compare(l,r) >= 0;
break;
case BIGGER:
result=database.compare(l,r) > 0;
break;
case SMALLER_EQUAL:
result=database.compare(l,r) <= 0;
break;
case SMALLER:
result=database.compare(l,r) < 0;
break;
case SPATIAL_INTERSECTS:
{
ValueGeometry lg=(ValueGeometry)l.convertTo(Value.GEOMETRY);
ValueGeometry rg=(ValueGeometry)r.convertTo(Value.GEOMETRY);
result=lg.intersectsBoundingBox(rg);
break;
}
default :
throw DbException.throwInternalError("String_Node_Str" + compareType);
}
return result;
}

Fixed version (ground truth):
/** 
 * Compare two values, given the values are not NULL.
 * @param database the database
 * @param l the first value
 * @param r the second value
 * @param compareType the compare type
 * @return true if the comparison indicated by the comparison type evaluates to true
 */
static boolean compareNotNull(Database database,Value l,Value r,int compareType){
  boolean result;
switch (compareType) {
case EQUAL:
case EQUAL_NULL_SAFE:
    result=database.areEqual(l,r);
  break;
case NOT_EQUAL:
case NOT_EQUAL_NULL_SAFE:
result=!database.areEqual(l,r);
break;
case BIGGER_EQUAL:
result=database.compare(l,r) >= 0;
break;
case BIGGER:
result=database.compare(l,r) > 0;
break;
case SMALLER_EQUAL:
result=database.compare(l,r) <= 0;
break;
case SMALLER:
result=database.compare(l,r) < 0;
break;
case SPATIAL_INTERSECTS:
{
ValueGeometry lg=(ValueGeometry)l.convertTo(Value.GEOMETRY);
ValueGeometry rg=(ValueGeometry)r.convertTo(Value.GEOMETRY);
result=lg.intersectsBoundingBox(rg);
break;
}
default :
throw DbException.throwInternalError("String_Node_Str" + compareType);
}
return result;
}
Program: 15817
Project: 15817
Buggy source:
/** 
 * Create a new IN(..) condition.
 * @param session the session
 * @param left the expression before IN
 * @param valueList the value list (at least two elements)
 */
public ConditionInConstantSet(Session session,Expression left,ArrayList<Expression> valueList){
  this.left=left;
  this.valueList=valueList;
  this.valueSet=new HashSet<Value>(valueList.size());
  int type=left.getType();
  for (  Expression expression : valueList) {
    valueSet.add(expression.getValue(session).convertTo(type));
  }
}

Fixed version (ground truth):
/** 
 * Create a new IN(..) condition.
 * @param session the session
 * @param left the expression before IN
 * @param valueList the value list (at least two elements)
 */
public ConditionInConstantSet(final Session session,Expression left,ArrayList<Expression> valueList){
  this.left=left;
  this.valueList=valueList;
  this.valueSet=new TreeSet<Value>(new Comparator<Value>(){
    @Override public int compare(    Value o1,    Value o2){
      return session.getDatabase().compare(o1,o2);
    }
  }
);
  int type=left.getType();
  for (  Expression expression : valueList) {
    valueSet.add(expression.getValue(session).convertTo(type));
  }
}
Program: 15818
Project: 15818
Buggy source:
@Override public void test() throws Exception {
  deleteDb("String_Node_Str");
  testExplainRoundTrip();
  testOrderByExpression();
  testGroupSubquery();
  testAnalyzeLob();
  testLike();
  testExistsSubquery();
  testQueryCacheConcurrentUse();
  testQueryCacheResetParams();
  testRowId();
  testSortIndex();
  testAutoAnalyze();
  testInAndBetween();
  testNestedIn();
  testConstantIn();
  testNestedInSelectAndLike();
  testNestedInSelect();
  testInSelectJoin();
  testMinMaxNullOptimization();
  if (config.networked) {
    return;
  }
  testOptimizeInJoinSelect();
  testOptimizeInJoin();
  testMultiColumnRangeQuery();
  testDistinctOptimization();
  testQueryCacheTimestamp();
  testQueryCacheSpeed();
  testQueryCache(true);
  testQueryCache(false);
  testIn();
  testMinMaxCountOptimization(true);
  testMinMaxCountOptimization(false);
  testOrderedIndexes();
  testConvertOrToIn();
  deleteDb("String_Node_Str");
}

Fixed version (ground truth):
@Override public void test() throws Exception {
  deleteDb("String_Node_Str");
  testExplainRoundTrip();
  testOrderByExpression();
  testGroupSubquery();
  testAnalyzeLob();
  testLike();
  testExistsSubquery();
  testQueryCacheConcurrentUse();
  testQueryCacheResetParams();
  testRowId();
  testSortIndex();
  testAutoAnalyze();
  testInAndBetween();
  testNestedIn();
  testConstantIn1();
  testConstantIn2();
  testNestedInSelectAndLike();
  testNestedInSelect();
  testInSelectJoin();
  testMinMaxNullOptimization();
  if (config.networked) {
    return;
  }
  testOptimizeInJoinSelect();
  testOptimizeInJoin();
  testMultiColumnRangeQuery();
  testDistinctOptimization();
  testQueryCacheTimestamp();
  testQueryCacheSpeed();
  testQueryCache(true);
  testQueryCache(false);
  testIn();
  testMinMaxCountOptimization(true);
  testMinMaxCountOptimization(false);
  testOrderedIndexes();
  testConvertOrToIn();
  deleteDb("String_Node_Str");
}
Program: 15819
Project: 15819
Buggy source:
/** 
 * Compare two values, given the values are not NULL.
 * @param database the database
 * @param l the first value
 * @param r the second value
 * @param compareType the compare type
 * @return the result of the comparison (1 if the first value is bigger, -1if smaller, 0 if both are equal)
 */
static boolean compareNotNull(Database database,Value l,Value r,int compareType){
  boolean result;
switch (compareType) {
case EQUAL:
case EQUAL_NULL_SAFE:
    result=database.areEqual(l,r);
  break;
case NOT_EQUAL:
case NOT_EQUAL_NULL_SAFE:
result=!database.areEqual(l,r);
break;
case BIGGER_EQUAL:
result=database.compare(l,r) >= 0;
break;
case BIGGER:
result=database.compare(l,r) > 0;
break;
case SMALLER_EQUAL:
result=database.compare(l,r) <= 0;
break;
case SMALLER:
result=database.compare(l,r) < 0;
break;
case SPATIAL_INTERSECTS:
{
ValueGeometry lg=(ValueGeometry)l.convertTo(Value.GEOMETRY);
ValueGeometry rg=(ValueGeometry)r.convertTo(Value.GEOMETRY);
result=lg.intersectsBoundingBox(rg);
break;
}
default :
throw DbException.throwInternalError("String_Node_Str" + compareType);
}
return result;
}

Fixed version (ground truth):
/** 
 * Compare two values, given the values are not NULL.
 * @param database the database
 * @param l the first value
 * @param r the second value
 * @param compareType the compare type
 * @return true if the comparison indicated by the comparison type evaluates to true
 */
static boolean compareNotNull(Database database,Value l,Value r,int compareType){
  boolean result;
switch (compareType) {
case EQUAL:
case EQUAL_NULL_SAFE:
    result=database.areEqual(l,r);
  break;
case NOT_EQUAL:
case NOT_EQUAL_NULL_SAFE:
result=!database.areEqual(l,r);
break;
case BIGGER_EQUAL:
result=database.compare(l,r) >= 0;
break;
case BIGGER:
result=database.compare(l,r) > 0;
break;
case SMALLER_EQUAL:
result=database.compare(l,r) <= 0;
break;
case SMALLER:
result=database.compare(l,r) < 0;
break;
case SPATIAL_INTERSECTS:
{
ValueGeometry lg=(ValueGeometry)l.convertTo(Value.GEOMETRY);
ValueGeometry rg=(ValueGeometry)r.convertTo(Value.GEOMETRY);
result=lg.intersectsBoundingBox(rg);
break;
}
default :
throw DbException.throwInternalError("String_Node_Str" + compareType);
}
return result;
}
Program: 15820
Project: 15820
Buggy source:
/** 
 * Create a new IN(..) condition.
 * @param session the session
 * @param left the expression before IN
 * @param valueList the value list (at least two elements)
 */
public ConditionInConstantSet(Session session,Expression left,ArrayList<Expression> valueList){
  this.left=left;
  this.valueList=valueList;
  this.valueSet=new HashSet<Value>(valueList.size());
  int type=left.getType();
  for (  Expression expression : valueList) {
    valueSet.add(expression.getValue(session).convertTo(type));
  }
}

Fixed version (ground truth):
/** 
 * Create a new IN(..) condition.
 * @param session the session
 * @param left the expression before IN
 * @param valueList the value list (at least two elements)
 */
public ConditionInConstantSet(final Session session,Expression left,ArrayList<Expression> valueList){
  this.left=left;
  this.valueList=valueList;
  this.valueSet=new TreeSet<Value>(new Comparator<Value>(){
    @Override public int compare(    Value o1,    Value o2){
      return session.getDatabase().compare(o1,o2);
    }
  }
);
  int type=left.getType();
  for (  Expression expression : valueList) {
    valueSet.add(expression.getValue(session).convertTo(type));
  }
}
Program: 15821
Project: 15821
Buggy source:
@Override public void test() throws Exception {
  deleteDb("String_Node_Str");
  testExplainRoundTrip();
  testOrderByExpression();
  testGroupSubquery();
  testAnalyzeLob();
  testLike();
  testExistsSubquery();
  testQueryCacheConcurrentUse();
  testQueryCacheResetParams();
  testRowId();
  testSortIndex();
  testAutoAnalyze();
  testInAndBetween();
  testNestedIn();
  testConstantIn();
  testNestedInSelectAndLike();
  testNestedInSelect();
  testInSelectJoin();
  testMinMaxNullOptimization();
  if (config.networked) {
    return;
  }
  testOptimizeInJoinSelect();
  testOptimizeInJoin();
  testMultiColumnRangeQuery();
  testDistinctOptimization();
  testQueryCacheTimestamp();
  testQueryCacheSpeed();
  testQueryCache(true);
  testQueryCache(false);
  testIn();
  testMinMaxCountOptimization(true);
  testMinMaxCountOptimization(false);
  testOrderedIndexes();
  testConvertOrToIn();
  deleteDb("String_Node_Str");
}

Fixed version (ground truth):
@Override public void test() throws Exception {
  deleteDb("String_Node_Str");
  testExplainRoundTrip();
  testOrderByExpression();
  testGroupSubquery();
  testAnalyzeLob();
  testLike();
  testExistsSubquery();
  testQueryCacheConcurrentUse();
  testQueryCacheResetParams();
  testRowId();
  testSortIndex();
  testAutoAnalyze();
  testInAndBetween();
  testNestedIn();
  testConstantIn1();
  testConstantIn2();
  testNestedInSelectAndLike();
  testNestedInSelect();
  testInSelectJoin();
  testMinMaxNullOptimization();
  if (config.networked) {
    return;
  }
  testOptimizeInJoinSelect();
  testOptimizeInJoin();
  testMultiColumnRangeQuery();
  testDistinctOptimization();
  testQueryCacheTimestamp();
  testQueryCacheSpeed();
  testQueryCache(true);
  testQueryCache(false);
  testIn();
  testMinMaxCountOptimization(true);
  testMinMaxCountOptimization(false);
  testOrderedIndexes();
  testConvertOrToIn();
  deleteDb("String_Node_Str");
}
Program: 15822
Project: 15822
Buggy source:
@Override public void init(){
  if (init) {
    return;
  }
  init=true;
  Store s=database.getMvStore();
  MVStore mvStore;
  if (s == null) {
    mvStore=MVStore.open(null);
  }
 else {
    mvStore=s.getStore();
  }
  lobMap=mvStore.openMap("String_Node_Str",new MVMapConcurrent.Builder<Long,Object[]>());
  refMap=mvStore.openMap("String_Node_Str",new MVMapConcurrent.Builder<Object[],Boolean>());
  dataMap=mvStore.openMap("String_Node_Str",new MVMapConcurrent.Builder<Long,byte[]>());
  streamStore=new StreamStore(dataMap);
}

Fixed version (ground truth):
@Override public void init(){
  if (init) {
    return;
  }
  init=true;
  Store s=database.getMvStore();
  MVStore mvStore;
  if (s == null) {
    mvStore=MVStore.open(null);
  }
 else {
    mvStore=s.getStore();
  }
  lobMap=mvStore.openMap("String_Node_Str",new MVMapConcurrent.Builder<Long,Object[]>());
  refMap=mvStore.openMap("String_Node_Str",new MVMapConcurrent.Builder<Object[],Boolean>());
  dataMap=mvStore.openMap("String_Node_Str",new MVMapConcurrent.Builder<Long,byte[]>());
  streamStore=new StreamStore(dataMap);
  streamStore.setMaxBlockSize(32 * 1024);
}
Program: 15823
Project: 15823
Buggy source:
private void removeLob(int tableId,long lobId){
  Object[] value=lobMap.remove(lobId);
  byte[] streamStoreId=(byte[])value[0];
  Object[] key=new Object[]{streamStoreId,0};
  value=refMap.ceilingKey(key);
  boolean hasMoreEntries=false;
  if (value != null) {
    byte[] s2=(byte[])value[0];
    if (Arrays.equals(streamStoreId,s2)) {
      hasMoreEntries=true;
    }
  }
  if (!hasMoreEntries) {
    streamStore.remove(streamStoreId);
  }
}

Fixed version (ground truth):
private void removeLob(int tableId,long lobId){
  if (TRACE) {
    trace("String_Node_Str" + tableId + "String_Node_Str"+ lobId);
  }
  Object[] value=lobMap.remove(lobId);
  byte[] streamStoreId=(byte[])value[0];
  Object[] key=new Object[]{streamStoreId,lobId};
  refMap.remove(key);
  key=new Object[]{streamStoreId,0};
  value=refMap.ceilingKey(key);
  boolean hasMoreEntries=false;
  if (value != null) {
    byte[] s2=(byte[])value[0];
    if (Arrays.equals(streamStoreId,s2)) {
      hasMoreEntries=true;
    }
  }
  if (!hasMoreEntries) {
    streamStore.remove(streamStoreId);
  }
}
Program: 15824
Project: 15824
Buggy source:
@Override public void setTable(ValueLobDb lob,int tableId){
  init();
  long lobId=lob.getLobId();
  Object[] value=lobMap.remove(lobId);
  value[1]=tableId;
  lobMap.put(lobId,value);
}

Fixed version (ground truth):
@Override public void setTable(ValueLobDb lob,int tableId){
  init();
  long lobId=lob.getLobId();
  Object[] value=lobMap.remove(lobId);
  if (TRACE) {
    trace("String_Node_Str" + lob.getTableId() + "String_Node_Str"+ lob.getLobId()+ "String_Node_Str"+ tableId+ "String_Node_Str"+ lobId);
  }
  value[1]=tableId;
  lobMap.put(lobId,value);
}
Program: 15825
Project: 15825
Buggy source:
private ValueLobDb createLob(InputStream in,int type) throws IOException {
  byte[] streamStoreId;
  try {
    streamStoreId=streamStore.put(in);
  }
 catch (  Exception e) {
    throw DbException.convertToIOException(e);
  }
  long lobId=streamStore.getAndIncrementNextKey();
  long length=streamStore.length(streamStoreId);
  int tableId=LobStorageFrontend.TABLE_TEMP;
  Object[] value=new Object[]{streamStoreId,tableId,length,0};
  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):
private ValueLobDb createLob(InputStream in,int type) throws IOException {
  byte[] streamStoreId;
  try {
    streamStoreId=streamStore.put(in);
  }
 catch (  Exception e) {
    throw DbException.convertToIOException(e);
  }
  long lobId=generateLobId();
  long length=streamStore.length(streamStoreId);
  int tableId=LobStorageFrontend.TABLE_TEMP;
  Object[] value=new Object[]{streamStoreId,tableId,length,0};
  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" + tableId + "String_Node_Str"+ lobId);
  }
  return lob;
}
Program: 15826
Project: 15826
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: 15827
Project: 15827
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: 15828
Project: 15828
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: 15829
Project: 15829
Buggy source:
@Override public int read(byte[] b,int off,int len){
  while (true) {
    if (buffer == null) {
      buffer=nextBuffer();
      if (buffer == null) {
        return -1;
      }
    }
    int result=buffer.read(b,off,len);
    if (result > 0) {
      pos+=result;
      return result;
    }
    buffer=null;
  }
}

Fixed version (ground truth):
@Override public int read(byte[] b,int off,int len){
  if (len <= 0) {
    return 0;
  }
  while (true) {
    if (buffer == null) {
      buffer=nextBuffer();
      if (buffer == null) {
        return -1;
      }
    }
    int result=buffer.read(b,off,len);
    if (result > 0) {
      pos+=result;
      return result;
    }
    buffer=null;
  }
}
Program: 15830
Project: 15830
Buggy source:
/** 
 * Generate a new key.
 * @return the new key
 */
public long getAndIncrementNextKey(){
  long key=nextKey.getAndIncrement();
  if (!map.containsKey(key)) {
    return key;
  }
synchronized (this) {
    long low=key, high=Long.MAX_VALUE;
    while (low < high) {
      long x=(low + high) >>> 1;
      if (map.containsKey(x)) {
        low=x + 1;
      }
 else {
        high=x;
      }
    }
    key=low;
    nextKey.set(key + 1);
    return key;
  }
}

Fixed version (ground truth):
/** 
 * Generate a new key.
 * @return the new key
 */
private long getAndIncrementNextKey(){
  long key=nextKey.getAndIncrement();
  if (!map.containsKey(key)) {
    return key;
  }
synchronized (this) {
    long low=key, high=Long.MAX_VALUE;
    while (low < high) {
      long x=(low + high) >>> 1;
      if (map.containsKey(x)) {
        low=x + 1;
      }
 else {
        high=x;
      }
    }
    key=low;
    nextKey.set(key + 1);
    return key;
  }
}
Program: 15831
Project: 15831
Buggy source:
private ByteArrayInputStream nextBuffer(){
  while (idBuffer.hasRemaining()) {
switch (idBuffer.get()) {
case 0:
{
        int len=DataUtils.readVarInt(idBuffer);
        if (skip >= len) {
          skip-=len;
          idBuffer.position(idBuffer.position() + len);
          continue;
        }
        int p=(int)(idBuffer.position() + skip);
        int l=(int)(len - skip);
        idBuffer.position(p + l);
        return new ByteArrayInputStream(idBuffer.array(),p,l);
      }
case 1:
{
      int len=DataUtils.readVarInt(idBuffer);
      long key=DataUtils.readVarLong(idBuffer);
      if (skip >= len) {
        skip-=len;
        continue;
      }
      byte[] data=store.getBlock(key);
      int s=(int)skip;
      skip=0;
      return new ByteArrayInputStream(data,s,data.length - s);
    }
case 2:
{
    long len=DataUtils.readVarInt(idBuffer);
    long key=DataUtils.readVarLong(idBuffer);
    if (skip >= len) {
      skip-=len;
      continue;
    }
    byte[] k=store.getBlock(key);
    ByteBuffer newBuffer=ByteBuffer.allocate(k.length + idBuffer.limit() - idBuffer.position());
    newBuffer.put(k);
    newBuffer.put(idBuffer);
    newBuffer.flip();
    idBuffer=newBuffer;
    return nextBuffer();
  }
default :
throw DataUtils.newIllegalArgumentException("String_Node_Str",Arrays.toString(idBuffer.array()));
}
}
return null;
}

Fixed version (ground truth):
private ByteArrayInputStream nextBuffer(){
  while (idBuffer.hasRemaining()) {
switch (idBuffer.get()) {
case 0:
{
        int len=DataUtils.readVarInt(idBuffer);
        if (skip >= len) {
          skip-=len;
          idBuffer.position(idBuffer.position() + len);
          continue;
        }
        int p=(int)(idBuffer.position() + skip);
        int l=(int)(len - skip);
        idBuffer.position(p + l);
        return new ByteArrayInputStream(idBuffer.array(),p,l);
      }
case 1:
{
      int len=DataUtils.readVarInt(idBuffer);
      long key=DataUtils.readVarLong(idBuffer);
      if (skip >= len) {
        skip-=len;
        continue;
      }
      byte[] data=store.getBlock(key);
      int s=(int)skip;
      skip=0;
      return new ByteArrayInputStream(data,s,data.length - s);
    }
case 2:
{
    long len=DataUtils.readVarLong(idBuffer);
    long key=DataUtils.readVarLong(idBuffer);
    if (skip >= len) {
      skip-=len;
      continue;
    }
    byte[] k=store.getBlock(key);
    ByteBuffer newBuffer=ByteBuffer.allocate(k.length + idBuffer.limit() - idBuffer.position());
    newBuffer.put(k);
    newBuffer.put(idBuffer);
    newBuffer.flip();
    idBuffer=newBuffer;
    return nextBuffer();
  }
default :
throw DataUtils.newIllegalArgumentException("String_Node_Str",Arrays.toString(idBuffer.array()));
}
}
return null;
}
Program: 15832
Project: 15832
Buggy source:
@Override public int read(byte[] b,int off,int len){
  while (true) {
    if (buffer == null) {
      buffer=nextBuffer();
      if (buffer == null) {
        return -1;
      }
    }
    int result=buffer.read(b,off,len);
    if (result > 0) {
      pos+=result;
      return result;
    }
    buffer=null;
  }
}

Fixed version (ground truth):
@Override public int read(byte[] b,int off,int len){
  if (len <= 0) {
    return 0;
  }
  while (true) {
    if (buffer == null) {
      buffer=nextBuffer();
      if (buffer == null) {
        return -1;
      }
    }
    int result=buffer.read(b,off,len);
    if (result > 0) {
      pos+=result;
      return result;
    }
    buffer=null;
  }
}
Program: 15833
Project: 15833
Buggy source:
/** 
 * Generate a new key.
 * @return the new key
 */
public long getAndIncrementNextKey(){
  long key=nextKey.getAndIncrement();
  if (!map.containsKey(key)) {
    return key;
  }
synchronized (this) {
    long low=key, high=Long.MAX_VALUE;
    while (low < high) {
      long x=(low + high) >>> 1;
      if (map.containsKey(x)) {
        low=x + 1;
      }
 else {
        high=x;
      }
    }
    key=low;
    nextKey.set(key + 1);
    return key;
  }
}

Fixed version (ground truth):
/** 
 * Generate a new key.
 * @return the new key
 */
private long getAndIncrementNextKey(){
  long key=nextKey.getAndIncrement();
  if (!map.containsKey(key)) {
    return key;
  }
synchronized (this) {
    long low=key, high=Long.MAX_VALUE;
    while (low < high) {
      long x=(low + high) >>> 1;
      if (map.containsKey(x)) {
        low=x + 1;
      }
 else {
        high=x;
      }
    }
    key=low;
    nextKey.set(key + 1);
    return key;
  }
}
Program: 15834
Project: 15834
Buggy source:
private ByteArrayInputStream nextBuffer(){
  while (idBuffer.hasRemaining()) {
switch (idBuffer.get()) {
case 0:
{
        int len=DataUtils.readVarInt(idBuffer);
        if (skip >= len) {
          skip-=len;
          idBuffer.position(idBuffer.position() + len);
          continue;
        }
        int p=(int)(idBuffer.position() + skip);
        int l=(int)(len - skip);
        idBuffer.position(p + l);
        return new ByteArrayInputStream(idBuffer.array(),p,l);
      }
case 1:
{
      int len=DataUtils.readVarInt(idBuffer);
      long key=DataUtils.readVarLong(idBuffer);
      if (skip >= len) {
        skip-=len;
        continue;
      }
      byte[] data=store.getBlock(key);
      int s=(int)skip;
      skip=0;
      return new ByteArrayInputStream(data,s,data.length - s);
    }
case 2:
{
    long len=DataUtils.readVarInt(idBuffer);
    long key=DataUtils.readVarLong(idBuffer);
    if (skip >= len) {
      skip-=len;
      continue;
    }
    byte[] k=store.getBlock(key);
    ByteBuffer newBuffer=ByteBuffer.allocate(k.length + idBuffer.limit() - idBuffer.position());
    newBuffer.put(k);
    newBuffer.put(idBuffer);
    newBuffer.flip();
    idBuffer=newBuffer;
    return nextBuffer();
  }
default :
throw DataUtils.newIllegalArgumentException("String_Node_Str",Arrays.toString(idBuffer.array()));
}
}
return null;
}

Fixed version (ground truth):
private ByteArrayInputStream nextBuffer(){
  while (idBuffer.hasRemaining()) {
switch (idBuffer.get()) {
case 0:
{
        int len=DataUtils.readVarInt(idBuffer);
        if (skip >= len) {
          skip-=len;
          idBuffer.position(idBuffer.position() + len);
          continue;
        }
        int p=(int)(idBuffer.position() + skip);
        int l=(int)(len - skip);
        idBuffer.position(p + l);
        return new ByteArrayInputStream(idBuffer.array(),p,l);
      }
case 1:
{
      int len=DataUtils.readVarInt(idBuffer);
      long key=DataUtils.readVarLong(idBuffer);
      if (skip >= len) {
        skip-=len;
        continue;
      }
      byte[] data=store.getBlock(key);
      int s=(int)skip;
      skip=0;
      return new ByteArrayInputStream(data,s,data.length - s);
    }
case 2:
{
    long len=DataUtils.readVarLong(idBuffer);
    long key=DataUtils.readVarLong(idBuffer);
    if (skip >= len) {
      skip-=len;
      continue;
    }
    byte[] k=store.getBlock(key);
    ByteBuffer newBuffer=ByteBuffer.allocate(k.length + idBuffer.limit() - idBuffer.position());
    newBuffer.put(k);
    newBuffer.put(idBuffer);
    newBuffer.flip();
    idBuffer=newBuffer;
    return nextBuffer();
  }
default :
throw DataUtils.newIllegalArgumentException("String_Node_Str",Arrays.toString(idBuffer.array()));
}
}
return null;
}
Program: 15835
Project: 15835
Buggy source:
@Override public void init(){
  if (init) {
    return;
  }
  init=true;
  Store s=database.getMvStore();
  MVStore mvStore;
  if (s == null) {
    mvStore=MVStore.open(null);
  }
 else {
    mvStore=s.getStore();
  }
  lobMap=mvStore.openMap("String_Node_Str",new MVMapConcurrent.Builder<Long,Object[]>());
  refMap=mvStore.openMap("String_Node_Str",new MVMapConcurrent.Builder<Object[],Boolean>());
  dataMap=mvStore.openMap("String_Node_Str",new MVMapConcurrent.Builder<Long,byte[]>());
  streamStore=new StreamStore(dataMap);
}

Fixed version (ground truth):
@Override public void init(){
  if (init) {
    return;
  }
  init=true;
  Store s=database.getMvStore();
  MVStore mvStore;
  if (s == null) {
    mvStore=MVStore.open(null);
  }
 else {
    mvStore=s.getStore();
  }
  lobMap=mvStore.openMap("String_Node_Str",new MVMapConcurrent.Builder<Long,Object[]>());
  refMap=mvStore.openMap("String_Node_Str",new MVMapConcurrent.Builder<Object[],Boolean>());
  dataMap=mvStore.openMap("String_Node_Str",new MVMapConcurrent.Builder<Long,byte[]>());
  streamStore=new StreamStore(dataMap);
  streamStore.setMaxBlockSize(32 * 1024);
}
Program: 15836
Project: 15836
Buggy source:
private void removeLob(int tableId,long lobId){
  Object[] value=lobMap.remove(lobId);
  byte[] streamStoreId=(byte[])value[0];
  Object[] key=new Object[]{streamStoreId,0};
  value=refMap.ceilingKey(key);
  boolean hasMoreEntries=false;
  if (value != null) {
    byte[] s2=(byte[])value[0];
    if (Arrays.equals(streamStoreId,s2)) {
      hasMoreEntries=true;
    }
  }
  if (!hasMoreEntries) {
    streamStore.remove(streamStoreId);
  }
}

Fixed version (ground truth):
private void removeLob(int tableId,long lobId){
  if (TRACE) {
    trace("String_Node_Str" + tableId + "String_Node_Str"+ lobId);
  }
  Object[] value=lobMap.remove(lobId);
  byte[] streamStoreId=(byte[])value[0];
  Object[] key=new Object[]{streamStoreId,lobId};
  refMap.remove(key);
  key=new Object[]{streamStoreId,0};
  value=refMap.ceilingKey(key);
  boolean hasMoreEntries=false;
  if (value != null) {
    byte[] s2=(byte[])value[0];
    if (Arrays.equals(streamStoreId,s2)) {
      hasMoreEntries=true;
    }
  }
  if (!hasMoreEntries) {
    streamStore.remove(streamStoreId);
  }
}
Program: 15837
Project: 15837
Buggy source:
@Override public void setTable(ValueLobDb lob,int tableId){
  init();
  long lobId=lob.getLobId();
  Object[] value=lobMap.remove(lobId);
  value[1]=tableId;
  lobMap.put(lobId,value);
}

Fixed version (ground truth):
@Override public void setTable(ValueLobDb lob,int tableId){
  init();
  long lobId=lob.getLobId();
  Object[] value=lobMap.remove(lobId);
  if (TRACE) {
    trace("String_Node_Str" + lob.getTableId() + "String_Node_Str"+ lob.getLobId()+ "String_Node_Str"+ tableId+ "String_Node_Str"+ lobId);
  }
  value[1]=tableId;
  lobMap.put(lobId,value);
}
Program: 15838
Project: 15838
Buggy source:
private ValueLobDb createLob(InputStream in,int type) throws IOException {
  byte[] streamStoreId;
  try {
    streamStoreId=streamStore.put(in);
  }
 catch (  Exception e) {
    throw DbException.convertToIOException(e);
  }
  long lobId=streamStore.getAndIncrementNextKey();
  long length=streamStore.length(streamStoreId);
  int tableId=LobStorageFrontend.TABLE_TEMP;
  Object[] value=new Object[]{streamStoreId,tableId,length,0};
  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):
private ValueLobDb createLob(InputStream in,int type) throws IOException {
  byte[] streamStoreId;
  try {
    streamStoreId=streamStore.put(in);
  }
 catch (  Exception e) {
    throw DbException.convertToIOException(e);
  }
  long lobId=generateLobId();
  long length=streamStore.length(streamStoreId);
  int tableId=LobStorageFrontend.TABLE_TEMP;
  Object[] value=new Object[]{streamStoreId,tableId,length,0};
  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" + tableId + "String_Node_Str"+ lobId);
  }
  return lob;
}