nus-yam/ex-repair huggingface dataset:
Program: 112007
Project: 112007
Buggy source:
/** 
 * When enum value in data has an undefined index, it's considered as corrupted record and will be skipped.
 * @throws Exception
 */
@Test public void testEnumMissingSchema() throws Exception {
  CountingErrorHandler countingHandler=new CountingErrorHandler();
  BufferedProtocolReadToWrite p=new BufferedProtocolReadToWrite(new ThriftSchemaConverter().toStructType(StructWithEnum.class),countingHandler);
  final ByteArrayOutputStream in=new ByteArrayOutputStream();
  final ByteArrayOutputStream out=new ByteArrayOutputStream();
  StructWithMoreEnum moreEnum=new StructWithMoreEnum(NumberEnumWithMoreValue.FOUR);
  moreEnum.write(protocol(in));
  try {
    p.readOne(protocol(new ByteArrayInputStream(in.toByteArray())),protocol(out));
  }
 catch (  SkippableException e) {
    Throwable cause=e.getCause();
    assertTrue(cause instanceof DecodingSchemaMismatchException);
    assertTrue(cause.getMessage().contains("String_Node_Str"));
  }
  assertEquals(0,countingHandler.recordCountOfMissingFields);
  assertEquals(0,countingHandler.fieldIgnoredCount);
}

Fixed version (ground truth):
/** 
 * When enum value in data has an undefined index, it's considered as corrupted record and will be skipped.
 * @throws Exception
 */
@Test public void testEnumMissingSchema() throws Exception {
  CountingErrorHandler countingHandler=new CountingErrorHandler();
  BufferedProtocolReadToWrite p=new BufferedProtocolReadToWrite(new ThriftSchemaConverter().toStructType(StructWithEnum.class),countingHandler);
  final ByteArrayOutputStream in=new ByteArrayOutputStream();
  final ByteArrayOutputStream out=new ByteArrayOutputStream();
  StructWithMoreEnum enumDefinedInOldDefinition=new StructWithMoreEnum(NumberEnumWithMoreValue.THREE);
  StructWithMoreEnum extraEnumDefinedInNewDefinition=new StructWithMoreEnum(NumberEnumWithMoreValue.FOUR);
  enumDefinedInOldDefinition.write(protocol(in));
  extraEnumDefinedInNewDefinition.write(protocol(in));
  try {
    p.readOne(protocol(new ByteArrayInputStream(in.toByteArray())),protocol(out));
  }
 catch (  SkippableException e) {
    Throwable cause=e.getCause();
    assertTrue(cause instanceof DecodingSchemaMismatchException);
    assertTrue(cause.getMessage().contains("String_Node_Str"));
  }
  assertEquals(0,countingHandler.recordCountOfMissingFields);
  assertEquals(0,countingHandler.fieldIgnoredCount);
}
Program: 112008
Project: 112008
Buggy source:
public EnumWriteProtocol(PrimitiveColumnIO columnIO,EnumType type,Events returnClause){
  super(returnClause);
  for (  EnumValue enumValue : type.getValues()) {
    enumLookup.put(enumValue.getId(),Binary.fromString(enumValue.getName()));
  }
  this.columnIO=columnIO;
}

Fixed version (ground truth):
public EnumWriteProtocol(PrimitiveColumnIO columnIO,EnumType type,Events returnClause){
  super(returnClause);
  this.columnIO=columnIO;
  this.type=type;
}
Program: 112009
Project: 112009
Buggy source:
public FieldEnumConverter(List<TProtocol> events,ThriftField field){
  this.events=events;
  final List<EnumValue> values=((EnumType)field.getType()).getValues();
  for (  EnumValue enumValue : values) {
    enumLookup.put(Binary.fromString(enumValue.getName()),enumValue.getId());
  }
}

Fixed version (ground truth):
public FieldEnumConverter(List<TProtocol> events,ThriftField field){
  this.events=events;
  final Iterable<EnumValue> values=((EnumType)field.getType()).getValues();
  for (  EnumValue enumValue : values) {
    enumLookup.put(Binary.fromString(enumValue.getName()),enumValue.getId());
  }
}
Program: 112010
Project: 112010
Buggy source:
public List<EnumValue> getValues(){
  return values;
}

Fixed version (ground truth):
public Iterable<EnumValue> getValues(){
  return new Iterable<EnumValue>(){
    @Override public Iterator<EnumValue> iterator(){
      return values.iterator();
    }
  }
;
}
Program: 112011
Project: 112011
Buggy source:
/** 
 * When enum value in data has an undefined index, it's considered as corrupted record and will be skipped.
 * @throws Exception
 */
@Test public void testEnumMissingSchema() throws Exception {
  CountingErrorHandler countingHandler=new CountingErrorHandler();
  BufferedProtocolReadToWrite p=new BufferedProtocolReadToWrite(new ThriftSchemaConverter().toStructType(StructWithEnum.class),countingHandler);
  final ByteArrayOutputStream in=new ByteArrayOutputStream();
  final ByteArrayOutputStream out=new ByteArrayOutputStream();
  StructWithMoreEnum moreEnum=new StructWithMoreEnum(NumberEnumWithMoreValue.FOUR);
  moreEnum.write(protocol(in));
  try {
    p.readOne(protocol(new ByteArrayInputStream(in.toByteArray())),protocol(out));
  }
 catch (  SkippableException e) {
    Throwable cause=e.getCause();
    assertTrue(cause instanceof DecodingSchemaMismatchException);
    assertTrue(cause.getMessage().contains("String_Node_Str"));
  }
  assertEquals(0,countingHandler.recordCountOfMissingFields);
  assertEquals(0,countingHandler.fieldIgnoredCount);
}

Fixed version (ground truth):
/** 
 * When enum value in data has an undefined index, it's considered as corrupted record and will be skipped.
 * @throws Exception
 */
@Test public void testEnumMissingSchema() throws Exception {
  CountingErrorHandler countingHandler=new CountingErrorHandler();
  BufferedProtocolReadToWrite p=new BufferedProtocolReadToWrite(new ThriftSchemaConverter().toStructType(StructWithEnum.class),countingHandler);
  final ByteArrayOutputStream in=new ByteArrayOutputStream();
  final ByteArrayOutputStream out=new ByteArrayOutputStream();
  StructWithMoreEnum enumDefinedInOldDefinition=new StructWithMoreEnum(NumberEnumWithMoreValue.THREE);
  StructWithMoreEnum extraEnumDefinedInNewDefinition=new StructWithMoreEnum(NumberEnumWithMoreValue.FOUR);
  enumDefinedInOldDefinition.write(protocol(in));
  extraEnumDefinedInNewDefinition.write(protocol(in));
  try {
    p.readOne(protocol(new ByteArrayInputStream(in.toByteArray())),protocol(out));
  }
 catch (  SkippableException e) {
    Throwable cause=e.getCause();
    assertTrue(cause instanceof DecodingSchemaMismatchException);
    assertTrue(cause.getMessage().contains("String_Node_Str"));
  }
  assertEquals(0,countingHandler.recordCountOfMissingFields);
  assertEquals(0,countingHandler.fieldIgnoredCount);
}
Program: 112012
Project: 112012
Buggy source:
/** 
 * Internal method visible for testing purposes
 */
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) Class<? extends HiveBinding> createInternal(Class hiveVersionInfo){
  String hiveVersion;
  try {
    Method getVersionMethod=hiveVersionInfo.getMethod(HIVE_VERSION_METHOD_NAME,(Class[])null);
    String rawVersion=(String)getVersionMethod.invoke(null,(Object[])null);
    LOG.debug("String_Node_Str" + hiveVersionInfo.getSimpleName() + "String_Node_Str"+ rawVersion+ "String_Node_Str");
    hiveVersion=trimVersion(rawVersion);
  }
 catch (  Exception e) {
    throw new UnexpectedHiveVersionProviderError("String_Node_Str" + "String_Node_Str",e);
  }
  if (hiveVersion.startsWith(HIVE_VERSION_010)) {
    LOG.debug("String_Node_Str" + hiveVersion + "String_Node_Str"+ Hive010Binding.class.getSimpleName());
    return Hive010Binding.class;
  }
 else   if (hiveVersion.startsWith(HIVE_VERSION_011)) {
    LOG.debug("String_Node_Str" + hiveVersion + "String_Node_Str"+ Hive010Binding.class.getSimpleName()+ "String_Node_Str"+ "String_Node_Str");
    return Hive010Binding.class;
  }
  LOG.debug("String_Node_Str" + hiveVersion + "String_Node_Str"+ Hive012Binding.class.getSimpleName());
  return Hive012Binding.class;
}

Fixed version (ground truth):
/** 
 * Internal method visible for testing purposes
 */
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) Class<? extends HiveBinding> createInternal(Class hiveVersionInfo){
  String hiveVersion;
  try {
    Method getVersionMethod=hiveVersionInfo.getMethod(HIVE_VERSION_METHOD_NAME,(Class[])null);
    String rawVersion=(String)getVersionMethod.invoke(null,(Object[])null);
    LOG.debug("String_Node_Str" + hiveVersionInfo.getSimpleName() + "String_Node_Str"+ rawVersion+ "String_Node_Str");
    hiveVersion=trimVersion(rawVersion);
  }
 catch (  Exception e) {
    throw new UnexpectedHiveVersionProviderError("String_Node_Str" + "String_Node_Str",e);
  }
  if (hiveVersion.equalsIgnoreCase(HIVE_VERSION_UNKNOWN)) {
    LOG.debug("String_Node_Str");
    return createBindingForUnknownVersion();
  }
  if (hiveVersion.startsWith(HIVE_VERSION_010)) {
    LOG.debug("String_Node_Str" + hiveVersion + "String_Node_Str"+ Hive010Binding.class.getSimpleName());
    return Hive010Binding.class;
  }
 else   if (hiveVersion.startsWith(HIVE_VERSION_011)) {
    LOG.debug("String_Node_Str" + hiveVersion + "String_Node_Str"+ Hive010Binding.class.getSimpleName()+ "String_Node_Str"+ "String_Node_Str");
    return Hive010Binding.class;
  }
  LOG.debug("String_Node_Str" + hiveVersion + "String_Node_Str"+ Hive012Binding.class.getSimpleName());
  return Hive012Binding.class;
}
Program: 112013
Project: 112013
Buggy source:
@Test public void testUnknownHiveVersion(){
  hiveBindingFactory.createInternal(UnknownHiveVersion.class);
  Assert.assertEquals(Hive012Binding.class,hiveBindingFactory.createInternal(UnknownHiveVersion.class));
}

Fixed version (ground truth):
@Test public void testUnknownHiveVersion(){
  hiveBindingFactory.createInternal(BlankHiveVersion.class);
  Assert.assertEquals(Hive012Binding.class,hiveBindingFactory.createInternal(BlankHiveVersion.class));
}
Program: 112014
Project: 112014
Buggy source:
private boolean readOneStruct(TProtocol in,List<Action> buffer,StructType type) throws TException {
  final TStruct struct=in.readStructBegin();
  buffer.add(new Action(){
    @Override public void write(    TProtocol out) throws TException {
      out.writeStructBegin(struct);
    }
    @Override public String toDebugString(){
      return "String_Node_Str";
    }
  }
);
  TField field;
  boolean hasFieldsIgnored=false;
  while ((field=in.readFieldBegin()).type != TType.STOP) {
    final TField currentField=field;
    if (field.id > type.getChildren().size()) {
      notifyIgnoredFieldsOfRecord(field);
      hasFieldsIgnored|=true;
      new ProtocolReadToWrite().readOneValue(in,new NullProtocol(),field.type);
      continue;
    }
    buffer.add(new Action(){
      @Override public void write(      TProtocol out) throws TException {
        out.writeFieldBegin(currentField);
      }
      @Override public String toDebugString(){
        return "String_Node_Str" + currentField.id + "String_Node_Str"+ typeName(currentField.type)+ "String_Node_Str";
      }
    }
);
    ThriftField expectedField=type.getChildById(field.id);
    try {
      hasFieldsIgnored|=readOneValue(in,field.type,buffer,expectedField.getType());
    }
 catch (    Exception e) {
      throw new TException("String_Node_Str" + field + "String_Node_Str"+ expectedField,e);
    }
    in.readFieldEnd();
    buffer.add(FIELD_END);
  }
  in.readStructEnd();
  buffer.add(STRUCT_END);
  return hasFieldsIgnored;
}

Fixed version (ground truth):
private boolean readOneStruct(TProtocol in,List<Action> buffer,StructType type) throws TException {
  final TStruct struct=in.readStructBegin();
  buffer.add(new Action(){
    @Override public void write(    TProtocol out) throws TException {
      out.writeStructBegin(struct);
    }
    @Override public String toDebugString(){
      return "String_Node_Str";
    }
  }
);
  TField field;
  boolean hasFieldsIgnored=false;
  while ((field=in.readFieldBegin()).type != TType.STOP) {
    final TField currentField=field;
    if (field.id > type.getChildren().size()) {
      notifyIgnoredFieldsOfRecord(field);
      hasFieldsIgnored|=true;
      new ProtocolReadToWrite().readOneValue(in,new NullProtocol(),field.type);
      continue;
    }
    buffer.add(new Action(){
      @Override public void write(      TProtocol out) throws TException {
        out.writeFieldBegin(currentField);
      }
      @Override public String toDebugString(){
        return "String_Node_Str" + currentField.id + "String_Node_Str"+ typeName(currentField.type)+ "String_Node_Str";
      }
    }
);
    ThriftField expectedField=type.getChildById(field.id);
    hasFieldsIgnored|=readOneValue(in,field.type,buffer,expectedField.getType());
    in.readFieldEnd();
    buffer.add(FIELD_END);
  }
  in.readStructEnd();
  buffer.add(STRUCT_END);
  return hasFieldsIgnored;
}
Program: 112015
Project: 112015
Buggy source:
@Test public void testMissingFieldHandling() throws Exception {
  BufferedProtocolReadToWrite p=new BufferedProtocolReadToWrite(new ThriftSchemaConverter().toStructType(StructV3.class));
  CountingErrorHandler countingHandler=new CountingErrorHandler();
  p.unregisterAllErrorHandlers();
  p.registerErrorHandler(countingHandler);
  final ByteArrayOutputStream in=new ByteArrayOutputStream();
  StructV4WithExtracStructField dataWithNewSchema=new StructV4WithExtracStructField("String_Node_Str");
  dataWithNewSchema.setAge("String_Node_Str");
  dataWithNewSchema.setGender("String_Node_Str");
  StructV3 structV3=new StructV3("String_Node_Str");
  structV3.setAge("String_Node_Str");
  dataWithNewSchema.setAddedStruct(structV3);
  dataWithNewSchema.write(protocol(in));
  final ByteArrayOutputStream out=new ByteArrayOutputStream();
  p.readOne(protocol(new ByteArrayInputStream(in.toByteArray())),protocol(out));
  assertEquals(0,countingHandler.corruptedCount);
  assertEquals(1,countingHandler.recordCountOfMissingFields);
  assertEquals(1,countingHandler.fieldIgnoredCount);
}

Fixed version (ground truth):
/** 
 * When data contains extra field, it should notify the handler and read the data with extra field dropped
 * @throws Exception
 */
@Test public void testMissingFieldHandling() throws Exception {
  BufferedProtocolReadToWrite structForRead=new BufferedProtocolReadToWrite(new ThriftSchemaConverter().toStructType(StructV3.class));
  CountingErrorHandler countingHandler=new CountingErrorHandler(){
    @Override public void handleFieldIgnored(    TField field){
      assertEquals(field.id,4);
      fieldIgnoredCount++;
    }
  }
;
  structForRead.unregisterAllErrorHandlers();
  structForRead.registerErrorHandler(countingHandler);
  final ByteArrayOutputStream in=new ByteArrayOutputStream();
  StructV4WithExtracStructField dataWithNewSchema=new StructV4WithExtracStructField("String_Node_Str");
  dataWithNewSchema.setAge("String_Node_Str");
  dataWithNewSchema.setGender("String_Node_Str");
  StructV3 structV3=new StructV3("String_Node_Str");
  structV3.setAge("String_Node_Str");
  dataWithNewSchema.setAddedStruct(structV3);
  dataWithNewSchema.write(protocol(in));
  final ByteArrayOutputStream out=new ByteArrayOutputStream();
  structForRead.readOne(protocol(new ByteArrayInputStream(in.toByteArray())),protocol(out));
  assertEquals(0,countingHandler.corruptedCount);
  assertEquals(1,countingHandler.recordCountOfMissingFields);
  assertEquals(1,countingHandler.fieldIgnoredCount);
  assertEquals(0,countingHandler.schemaMismatchCount);
  StructV4WithExtracStructField b=StructV4WithExtracStructField.class.newInstance();
  b.read(protocol(new ByteArrayInputStream(out.toByteArray())));
  assertEquals(dataWithNewSchema.getName(),b.getName());
  assertEquals(dataWithNewSchema.getAge(),b.getAge());
  assertEquals(dataWithNewSchema.getGender(),b.getGender());
  assertEquals(null,b.getAddedStruct());
}
Program: 112016
Project: 112016
Buggy source:
@Override public void handleSkipRecordDueToSchemaMismatch(DecodingSchemaMismatchException e){
}

Fixed version (ground truth):
@Override public void handleSkipRecordDueToSchemaMismatch(DecodingSchemaMismatchException e){
  schemaMismatchCount++;
}
Program: 112017
Project: 112017
Buggy source:
@Override public void reset(){
  if (encodedValues != null) {
    encodedValues=new IntList();
  }
  plainValuesWriter.reset();
}

Fixed version (ground truth):
@Override public void reset(){
  if (encodedValues != null) {
    encodedValues=new IntList();
  }
  plainValuesWriter.reset();
  rawDataByteSize=0;
}
Program: 112018
Project: 112018
Buggy source:
@Test public void testLongDictionaryFallBack() throws IOException {
  int slabSize=100;
  int maxDictionaryByteSize=50;
  final DictionaryValuesWriter cw=new PlainLongDictionaryValuesWriter(maxDictionaryByteSize,slabSize);
  int fallBackThreshold=maxDictionaryByteSize / 8;
  for (long i=0; i < 100; i++) {
    cw.writeLong(i);
    if (i < fallBackThreshold) {
      assertEquals(cw.getEncoding(),PLAIN_DICTIONARY);
    }
 else {
      assertEquals(cw.getEncoding(),PLAIN);
    }
  }
  ValuesReader reader=new PlainValuesReader.LongPlainValuesReader();
  reader.initFromPage(100,cw.getBytes().toByteArray(),0);
  for (long i=0; i < 100; i++) {
    assertEquals(i,reader.readLong());
  }
}

Fixed version (ground truth):
@Test public void testLongDictionaryFallBack() throws IOException {
  int slabSize=100;
  int maxDictionaryByteSize=50;
  final DictionaryValuesWriter cw=new PlainLongDictionaryValuesWriter(maxDictionaryByteSize,slabSize);
  int fallBackThreshold=maxDictionaryByteSize / 8;
  for (long i=0; i < 100; i++) {
    cw.writeLong(i);
    if (i < fallBackThreshold) {
      assertEquals(cw.getEncoding(),PLAIN_DICTIONARY);
    }
 else {
      assertEquals(cw.getEncoding(),PLAIN);
    }
  }
  ValuesReader reader=new PlainValuesReader.LongPlainValuesReader();
  reader.initFromPage(100,cw.getBytes().toByteArray(),0);
  for (long i=0; i < 100; i++) {
    assertEquals(i,reader.readLong());
  }
  cw.reset();
  assertEquals(0,cw.getBufferedSize());
}
Program: 112019
Project: 112019
Buggy source:
/** 
 * Fallback strategy is to decode the dictionary and write the result to PlainWriter
 * @throws IOException
 */
@Test public void testIntDictionaryFallBack() throws IOException {
  int slabSize=100;
  int maxDictionaryByteSize=50;
  final DictionaryValuesWriter cw=new PlainIntegerDictionaryValuesWriter(maxDictionaryByteSize,slabSize);
  int fallBackThreshold=maxDictionaryByteSize / 4;
  for (int i=0; i < 100; i++) {
    cw.writeInteger(i);
    if (i < fallBackThreshold) {
      assertEquals(cw.getEncoding(),PLAIN_DICTIONARY);
    }
 else {
      assertEquals(cw.getEncoding(),PLAIN);
    }
  }
  ValuesReader reader=new PlainValuesReader.IntegerPlainValuesReader();
  reader.initFromPage(100,cw.getBytes().toByteArray(),0);
  for (int i=0; i < 100; i++) {
    assertEquals(i,reader.readInteger());
  }
}

Fixed version (ground truth):
/** 
 * Fallback strategy is to decode the dictionary and write the result to PlainWriter
 * @throws IOException
 */
@Test public void testIntDictionaryFallBack() throws IOException {
  int slabSize=100;
  int maxDictionaryByteSize=50;
  final DictionaryValuesWriter cw=new PlainIntegerDictionaryValuesWriter(maxDictionaryByteSize,slabSize);
  int fallBackThreshold=maxDictionaryByteSize / 4;
  for (int i=0; i < 100; i++) {
    cw.writeInteger(i);
    if (i < fallBackThreshold) {
      assertEquals(cw.getEncoding(),PLAIN_DICTIONARY);
    }
 else {
      assertEquals(cw.getEncoding(),PLAIN);
    }
  }
  ValuesReader reader=new PlainValuesReader.IntegerPlainValuesReader();
  reader.initFromPage(100,cw.getBytes().toByteArray(),0);
  for (int i=0; i < 100; i++) {
    assertEquals(i,reader.readInteger());
  }
  cw.reset();
  assertEquals(0,cw.getBufferedSize());
}
Program: 112020
Project: 112020
Buggy source:
@Test public void testFloatDictionaryFallBack() throws IOException {
  int slabSize=100;
  int maxDictionaryByteSize=50;
  final DictionaryValuesWriter cw=new PlainFloatDictionaryValuesWriter(maxDictionaryByteSize,slabSize);
  int fallBackThreshold=maxDictionaryByteSize / 4;
  for (float i=0; i < 100; i++) {
    cw.writeFloat(i);
    if (i < fallBackThreshold) {
      assertEquals(cw.getEncoding(),PLAIN_DICTIONARY);
    }
 else {
      assertEquals(cw.getEncoding(),PLAIN);
    }
  }
  ValuesReader reader=new PlainValuesReader.FloatPlainValuesReader();
  reader.initFromPage(100,cw.getBytes().toByteArray(),0);
  for (float i=0; i < 100; i++) {
    assertEquals(i,reader.readFloat(),0.00001);
  }
}

Fixed version (ground truth):
@Test public void testFloatDictionaryFallBack() throws IOException {
  int slabSize=100;
  int maxDictionaryByteSize=50;
  final DictionaryValuesWriter cw=new PlainFloatDictionaryValuesWriter(maxDictionaryByteSize,slabSize);
  int fallBackThreshold=maxDictionaryByteSize / 4;
  for (float i=0; i < 100; i++) {
    cw.writeFloat(i);
    if (i < fallBackThreshold) {
      assertEquals(cw.getEncoding(),PLAIN_DICTIONARY);
    }
 else {
      assertEquals(cw.getEncoding(),PLAIN);
    }
  }
  ValuesReader reader=new PlainValuesReader.FloatPlainValuesReader();
  reader.initFromPage(100,cw.getBytes().toByteArray(),0);
  for (float i=0; i < 100; i++) {
    assertEquals(i,reader.readFloat(),0.00001);
  }
  cw.reset();
  assertEquals(0,cw.getBufferedSize());
}
Program: 112021
Project: 112021
Buggy source:
@Test public void testDoubleDictionaryFallBack() throws IOException {
  int slabSize=100;
  int maxDictionaryByteSize=50;
  final DictionaryValuesWriter cw=new PlainDoubleDictionaryValuesWriter(maxDictionaryByteSize,slabSize);
  int fallBackThreshold=maxDictionaryByteSize / 8;
  for (double i=0; i < 100; i++) {
    cw.writeDouble(i);
    if (i < fallBackThreshold) {
      assertEquals(cw.getEncoding(),PLAIN_DICTIONARY);
    }
 else {
      assertEquals(cw.getEncoding(),PLAIN);
    }
  }
  ValuesReader reader=new PlainValuesReader.DoublePlainValuesReader();
  reader.initFromPage(100,cw.getBytes().toByteArray(),0);
  for (float i=0; i < 100; i++) {
    assertEquals(i,reader.readDouble(),0.00001);
  }
}

Fixed version (ground truth):
@Test public void testDoubleDictionaryFallBack() throws IOException {
  int slabSize=100;
  int maxDictionaryByteSize=50;
  final DictionaryValuesWriter cw=new PlainDoubleDictionaryValuesWriter(maxDictionaryByteSize,slabSize);
  int fallBackThreshold=maxDictionaryByteSize / 8;
  for (double i=0; i < 100; i++) {
    cw.writeDouble(i);
    if (i < fallBackThreshold) {
      assertEquals(cw.getEncoding(),PLAIN_DICTIONARY);
    }
 else {
      assertEquals(cw.getEncoding(),PLAIN);
    }
  }
  ValuesReader reader=new PlainValuesReader.DoublePlainValuesReader();
  reader.initFromPage(100,cw.getBytes().toByteArray(),0);
  for (float i=0; i < 100; i++) {
    assertEquals(i,reader.readDouble(),0.00001);
  }
  System.out.println(cw.getBufferedSize());
  cw.reset();
  assertEquals(0,cw.getBufferedSize());
}
Program: 112022
Project: 112022
Buggy source:
@Test public void testBinaryDictionaryFallBack() throws IOException {
  int slabSize=100;
  int maxDictionaryByteSize=50;
  final DictionaryValuesWriter cw=new PlainBinaryDictionaryValuesWriter(maxDictionaryByteSize,slabSize);
  int fallBackThreshold=maxDictionaryByteSize;
  int dataSize=0;
  for (long i=0; i < 100; i++) {
    Binary binary=Binary.fromString("String_Node_Str" + i);
    cw.writeBytes(binary);
    dataSize+=(binary.length() + 4);
    if (dataSize < fallBackThreshold) {
      assertEquals(PLAIN_DICTIONARY,cw.getEncoding());
    }
 else {
      assertEquals(PLAIN,cw.getEncoding());
    }
  }
  ValuesReader reader=new BinaryPlainValuesReader();
  reader.initFromPage(100,cw.getBytes().toByteArray(),0);
  for (long i=0; i < 100; i++) {
    assertEquals(Binary.fromString("String_Node_Str" + i),reader.readBytes());
  }
}

Fixed version (ground truth):
@Test public void testBinaryDictionaryFallBack() throws IOException {
  int slabSize=100;
  int maxDictionaryByteSize=50;
  final DictionaryValuesWriter cw=new PlainBinaryDictionaryValuesWriter(maxDictionaryByteSize,slabSize);
  int fallBackThreshold=maxDictionaryByteSize;
  int dataSize=0;
  for (long i=0; i < 100; i++) {
    Binary binary=Binary.fromString("String_Node_Str" + i);
    cw.writeBytes(binary);
    dataSize+=(binary.length() + 4);
    if (dataSize < fallBackThreshold) {
      assertEquals(PLAIN_DICTIONARY,cw.getEncoding());
    }
 else {
      assertEquals(PLAIN,cw.getEncoding());
    }
  }
  ValuesReader reader=new BinaryPlainValuesReader();
  reader.initFromPage(100,cw.getBytes().toByteArray(),0);
  for (long i=0; i < 100; i++) {
    assertEquals(Binary.fromString("String_Node_Str" + i),reader.readBytes());
  }
  cw.reset();
  assertEquals(0,cw.getBufferedSize());
}
Program: 112023
Project: 112023
Buggy source:
@Override public long getBufferedSize(){
  return rawDataByteSize;
}

Fixed version (ground truth):
@Override public long getBufferedSize(){
  return dictionaryTooBig ? plainValuesWriter.getBufferedSize() : encodedValues.size() * 4;
}
Program: 112024
Project: 112024
Buggy source:
@Override protected void clearDictionaryContent(){
  float[] reverseDictionary=new float[getDictionarySize()];
  FloatIterator dicKeyIterator=floatDictionaryContent.keySet().iterator();
  while (dicKeyIterator.hasNext()) {
    float key=dicKeyIterator.nextFloat();
    int id=floatDictionaryContent.get(key);
    reverseDictionary[id]=key;
  }
  IntIterator iterator=encodedValues.iterator();
  while (iterator.hasNext()) {
    int id=iterator.next();
    plainValuesWriter.writeFloat(reverseDictionary[id]);
  }
  floatDictionaryContent.clear();
}

Fixed version (ground truth):
@Override protected void clearDictionaryContent(){
  floatDictionaryContent.clear();
}
Program: 112025
Project: 112025
Buggy source:
private void fallBackToPlainEncoding(){
  if (DEBUG)   LOG.debug("String_Node_Str" + dictionaryByteSize + "String_Node_Str"+ getDictionarySize()+ "String_Node_Str");
  dictionaryTooBig=true;
  if (lastUsedDictionarySize == 0) {
    clearDictionaryContent();
    dictionaryByteSize=0;
    encodedValues=null;
  }
}

Fixed version (ground truth):
private void fallBackToPlainEncoding(){
  if (DEBUG)   LOG.debug("String_Node_Str" + dictionaryByteSize + "String_Node_Str"+ getDictionarySize()+ "String_Node_Str");
  dictionaryTooBig=true;
  fallBackDictionaryEncodedData();
  if (lastUsedDictionarySize == 0) {
    clearDictionaryContent();
    dictionaryByteSize=0;
    encodedValues=null;
  }
}
Program: 112026
Project: 112026
Buggy source:
@Override public int initFromPage(long valueCount,byte[] page,int offset) throws IOException {
  if (DEBUG)   LOG.debug("String_Node_Str" + offset + "String_Node_Str"+ (page.length - offset));
  this.in=new ByteArrayInputStream(page,offset,page.length - offset);
  int bitWidth=BytesUtils.readIntLittleEndianOnOneByte(in);
  if (DEBUG)   LOG.debug("String_Node_Str" + bitWidth);
  decoder=new RunLengthBitPackingHybridDecoder((int)valueCount,bitWidth,in);
  return page.length;
}

Fixed version (ground truth):
@Override public int initFromPage(long valueCount,byte[] page,int offset) throws IOException {
  if (DEBUG)   LOG.debug("String_Node_Str" + offset + "String_Node_Str"+ (page.length - offset));
  this.in=new ByteArrayInputStream(page,offset,page.length - offset);
  int bitWidth=BytesUtils.readIntLittleEndianOnOneByte(in);
  if (DEBUG)   LOG.debug("String_Node_Str" + bitWidth);
  decoder=new RunLengthBitPackingHybridDecoder(bitWidth,in);
  return page.length;
}
Program: 112027
Project: 112027
Buggy source:
public RunLengthBitPackingHybridDecoder(int numValues,int bitWidth,InputStream in){
  if (DEBUG)   LOG.debug("String_Node_Str" + bitWidth);
  Preconditions.checkArgument(bitWidth >= 0 && bitWidth <= 32,"String_Node_Str");
  this.bitWidth=bitWidth;
  this.packer=Packer.LITTLE_ENDIAN.newBytePacker(bitWidth);
  this.in=in;
  this.valuesRemaining=numValues;
}

Fixed version (ground truth):
public RunLengthBitPackingHybridDecoder(int bitWidth,ByteArrayInputStream in){
  if (DEBUG)   LOG.debug("String_Node_Str" + bitWidth);
  Preconditions.checkArgument(bitWidth >= 0 && bitWidth <= 32,"String_Node_Str");
  this.bitWidth=bitWidth;
  this.packer=Packer.LITTLE_ENDIAN.newBytePacker(bitWidth);
  this.in=in;
}
Program: 112028
Project: 112028
Buggy source:
public int readInt() throws IOException {
  Preconditions.checkArgument(valuesRemaining > 0,"String_Node_Str");
  if (currentCount == 0) {
    readNext();
  }
  --currentCount;
  --valuesRemaining;
  int result;
switch (mode) {
case RLE:
    result=currentValue;
  break;
case PACKED:
result=currentBuffer[currentBuffer.length - 1 - currentCount];
break;
default :
throw new ParquetDecodingException("String_Node_Str" + mode);
}
return result;
}

Fixed version (ground truth):
public int readInt() throws IOException {
  if (currentCount == 0) {
    readNext();
  }
  --currentCount;
  int result;
switch (mode) {
case RLE:
    result=currentValue;
  break;
case PACKED:
result=currentBuffer[currentBuffer.length - 1 - currentCount];
break;
default :
throw new ParquetDecodingException("String_Node_Str" + mode);
}
return result;
}
Program: 112029
Project: 112029
Buggy source:
private void readNext() throws IOException {
  final int header=BytesUtils.readUnsignedVarInt(in);
  mode=(header & 1) == 0 ? MODE.RLE : MODE.PACKED;
switch (mode) {
case RLE:
    currentCount=header >>> 1;
  if (DEBUG)   LOG.debug("String_Node_Str" + currentCount + "String_Node_Str");
currentValue=BytesUtils.readIntLittleEndianPaddedOnBitWidth(in,bitWidth);
break;
case PACKED:
int numGroups=header >>> 1;
currentCount=numGroups * 8;
if (DEBUG) LOG.debug("String_Node_Str" + currentCount + "String_Node_Str");
currentBuffer=new int[currentCount];
byte[] bytes=new byte[numGroups * bitWidth];
int valuesLeft=Math.min(currentCount,valuesRemaining);
new DataInputStream(in).readFully(bytes,0,(int)Math.ceil(valuesLeft * bitWidth / 8.0));
for (int valueIndex=0, byteIndex=0; valueIndex < currentCount; valueIndex+=8, byteIndex+=bitWidth) {
packer.unpack8Values(bytes,byteIndex,currentBuffer,valueIndex);
}
break;
default :
throw new ParquetDecodingException("String_Node_Str" + mode);
}
}

Fixed version (ground truth):
private void readNext() throws IOException {
  Preconditions.checkArgument(in.available() > 0,"String_Node_Str");
  final int header=BytesUtils.readUnsignedVarInt(in);
  mode=(header & 1) == 0 ? MODE.RLE : MODE.PACKED;
switch (mode) {
case RLE:
    currentCount=header >>> 1;
  if (DEBUG)   LOG.debug("String_Node_Str" + currentCount + "String_Node_Str");
currentValue=BytesUtils.readIntLittleEndianPaddedOnBitWidth(in,bitWidth);
break;
case PACKED:
int numGroups=header >>> 1;
currentCount=numGroups * 8;
if (DEBUG) LOG.debug("String_Node_Str" + currentCount + "String_Node_Str");
currentBuffer=new int[currentCount];
byte[] bytes=new byte[numGroups * bitWidth];
int bytesToRead=(int)Math.ceil(currentCount * bitWidth / 8.0);
bytesToRead=Math.min(bytesToRead,in.available());
new DataInputStream(in).readFully(bytes,0,bytesToRead);
for (int valueIndex=0, byteIndex=0; valueIndex < currentCount; valueIndex+=8, byteIndex+=bitWidth) {
packer.unpack8Values(bytes,byteIndex,currentBuffer,valueIndex);
}
break;
default :
throw new ParquetDecodingException("String_Node_Str" + mode);
}
}
Program: 112030
Project: 112030
Buggy source:
@Override public int initFromPage(long valueCountL,byte[] page,int offset) throws IOException {
  int valueCount=Ints.checkedCast(valueCountL);
  if (valueCount <= 0) {
    return offset;
  }
  ByteArrayInputStream in=new ByteArrayInputStream(page,offset,page.length);
  int length=BytesUtils.readIntLittleEndian(in);
  decoder=new RunLengthBitPackingHybridDecoder(valueCount,bitWidth,in);
  return offset + length + 4;
}

Fixed version (ground truth):
@Override public int initFromPage(long valueCountL,byte[] page,int offset) throws IOException {
  int valueCount=Ints.checkedCast(valueCountL);
  if (valueCount <= 0) {
    return offset;
  }
  ByteArrayInputStream in=new ByteArrayInputStream(page,offset,page.length);
  int length=BytesUtils.readIntLittleEndian(in);
  decoder=new RunLengthBitPackingHybridDecoder(bitWidth,in);
  return offset + length + 4;
}
Program: 112031
Project: 112031
Buggy source:
private void doIntegrationTest(int bitWidth) throws Exception {
  long modValue=1L << bitWidth;
  RunLengthBitPackingHybridEncoder encoder=new RunLengthBitPackingHybridEncoder(bitWidth,1000);
  int numValues=0;
  for (int i=0; i < 100; i++) {
    encoder.writeInt((int)(i % modValue));
  }
  numValues+=100;
  for (int i=0; i < 100; i++) {
    encoder.writeInt((int)(77 % modValue));
  }
  numValues+=100;
  for (int i=0; i < 100; i++) {
    encoder.writeInt((int)(88 % modValue));
  }
  numValues+=100;
  for (int i=0; i < 1000; i++) {
    encoder.writeInt((int)(i % modValue));
    encoder.writeInt((int)(i % modValue));
    encoder.writeInt((int)(i % modValue));
  }
  numValues+=3000;
  for (int i=0; i < 1000; i++) {
    encoder.writeInt((int)(17 % modValue));
  }
  numValues+=1000;
  InputStream in=new ByteArrayInputStream(encoder.toBytes().toByteArray());
  RunLengthBitPackingHybridDecoder decoder=new RunLengthBitPackingHybridDecoder(numValues,bitWidth,in);
  for (int i=0; i < 100; i++) {
    assertEquals(i % modValue,decoder.readInt());
  }
  for (int i=0; i < 100; i++) {
    assertEquals(77 % modValue,decoder.readInt());
  }
  for (int i=0; i < 100; i++) {
    assertEquals(88 % modValue,decoder.readInt());
  }
  for (int i=0; i < 1000; i++) {
    assertEquals(i % modValue,decoder.readInt());
    assertEquals(i % modValue,decoder.readInt());
    assertEquals(i % modValue,decoder.readInt());
  }
  for (int i=0; i < 1000; i++) {
    assertEquals(17 % modValue,decoder.readInt());
  }
}

Fixed version (ground truth):
private void doIntegrationTest(int bitWidth) throws Exception {
  long modValue=1L << bitWidth;
  RunLengthBitPackingHybridEncoder encoder=new RunLengthBitPackingHybridEncoder(bitWidth,1000);
  int numValues=0;
  for (int i=0; i < 100; i++) {
    encoder.writeInt((int)(i % modValue));
  }
  numValues+=100;
  for (int i=0; i < 100; i++) {
    encoder.writeInt((int)(77 % modValue));
  }
  numValues+=100;
  for (int i=0; i < 100; i++) {
    encoder.writeInt((int)(88 % modValue));
  }
  numValues+=100;
  for (int i=0; i < 1000; i++) {
    encoder.writeInt((int)(i % modValue));
    encoder.writeInt((int)(i % modValue));
    encoder.writeInt((int)(i % modValue));
  }
  numValues+=3000;
  for (int i=0; i < 1000; i++) {
    encoder.writeInt((int)(17 % modValue));
  }
  numValues+=1000;
  byte[] encodedBytes=encoder.toBytes().toByteArray();
  ByteArrayInputStream in=new ByteArrayInputStream(encodedBytes);
  RunLengthBitPackingHybridDecoder decoder=new RunLengthBitPackingHybridDecoder(bitWidth,in);
  for (int i=0; i < 100; i++) {
    assertEquals(i % modValue,decoder.readInt());
  }
  for (int i=0; i < 100; i++) {
    assertEquals(77 % modValue,decoder.readInt());
  }
  for (int i=0; i < 100; i++) {
    assertEquals(88 % modValue,decoder.readInt());
  }
  for (int i=0; i < 1000; i++) {
    assertEquals(i % modValue,decoder.readInt());
    assertEquals(i % modValue,decoder.readInt());
    assertEquals(i % modValue,decoder.readInt());
  }
  for (int i=0; i < 1000; i++) {
    assertEquals(17 % modValue,decoder.readInt());
  }
}
Program: 112032
Project: 112032
Buggy source:
@Test public void testGroupBoundary() throws Exception {
  byte[] bytes=new byte[2];
  bytes[0]=(1 << 1) | 1;
  bytes[1]=(1 << 0) | (2 << 2) | (3 << 4);
  ByteArrayInputStream stream=new ByteArrayInputStream(bytes);
  RunLengthBitPackingHybridDecoder decoder=new RunLengthBitPackingHybridDecoder(3,2,stream);
  assertEquals(decoder.readInt(),1);
  assertEquals(decoder.readInt(),2);
  assertEquals(decoder.readInt(),3);
  assertEquals(stream.available(),0);
}

Fixed version (ground truth):
@Test public void testGroupBoundary() throws Exception {
  byte[] bytes=new byte[2];
  bytes[0]=(1 << 1) | 1;
  bytes[1]=(1 << 0) | (2 << 2) | (3 << 4);
  ByteArrayInputStream stream=new ByteArrayInputStream(bytes);
  RunLengthBitPackingHybridDecoder decoder=new RunLengthBitPackingHybridDecoder(2,stream);
  assertEquals(decoder.readInt(),1);
  assertEquals(decoder.readInt(),2);
  assertEquals(decoder.readInt(),3);
  assertEquals(stream.available(),0);
}
Program: 112033
Project: 112033
Buggy source:
private void convertToElephantBirdCompatibleSchema(Schema schema){
  for (  FieldSchema fieldSchema : schema.getFields()) {
    if (fieldSchema.type == DataType.BOOLEAN) {
      fieldSchema.type=DataType.INTEGER;
    }
  }
}

Fixed version (ground truth):
private void convertToElephantBirdCompatibleSchema(Schema schema){
  if (schema == null) {
    return;
  }
  for (  FieldSchema fieldSchema : schema.getFields()) {
    if (fieldSchema.type == DataType.BOOLEAN) {
      fieldSchema.type=DataType.INTEGER;
    }
    convertToElephantBirdCompatibleSchema(fieldSchema.schema);
  }
}
Program: 112034
Project: 112034
Buggy source:
private void initSchema(Job job) throws IOException {
  if (requestedSchema == null) {
    final GlobalMetaData globalMetaData=getParquetInputFormat().getGlobalMetaData(job);
    schema=getPigSchemaFromMultipleFiles(globalMetaData.getSchema(),globalMetaData.getKeyValueMetaData());
    if (isElephantBirdCompatible(job)) {
      convertToElephantBirdCompatibleSchema(schema);
    }
  }
 else {
    schema=requestedSchema;
  }
}

Fixed version (ground truth):
private void initSchema(Job job) throws IOException {
  if (schema != null) {
    return;
  }
  if (requestedSchema != null) {
    schema=requestedSchema;
    return;
  }
  schema=PigSchemaConverter.parsePigSchema(UDFContext.getUDFContext().getUDFProperties(this.getClass(),new String[]{signature}).getProperty(PARQUET_PIG_SCHEMA));
  if (schema == null) {
    final GlobalMetaData globalMetaData=getParquetInputFormat().getGlobalMetaData(job);
    schema=getPigSchemaFromMultipleFiles(globalMetaData.getSchema(),globalMetaData.getKeyValueMetaData());
  }
  if (isElephantBirdCompatible(job)) {
    convertToElephantBirdCompatibleSchema(schema);
  }
}
Program: 112035
Project: 112035
Buggy source:
private void setInput(String location,Job job) throws IOException {
  this.setLocationHasBeenCalled=true;
  this.location=location;
  setInputPaths(job,location);
}

Fixed version (ground truth):
private void setInput(String location,Job job) throws IOException {
  this.setLocationHasBeenCalled=true;
  this.location=location;
  setInputPaths(job,location);
  initSchema(job);
}
Program: 112036
Project: 112036
Buggy source:
@Override public ResourceSchema getSchema(String location,Job job) throws IOException {
  if (DEBUG)   LOG.debug("String_Node_Str" + location + "String_Node_Str"+ job+ "String_Node_Str");
  setInput(location,job);
  if (schema == null) {
    initSchema(job);
  }
  return new ResourceSchema(schema);
}

Fixed version (ground truth):
@Override public ResourceSchema getSchema(String location,Job job) throws IOException {
  if (DEBUG)   LOG.debug("String_Node_Str" + location + "String_Node_Str"+ job+ "String_Node_Str");
  setInput(location,job);
  return new ResourceSchema(schema);
}
Program: 112037
Project: 112037
Buggy source:
@Override public RequiredFieldResponse pushProjection(RequiredFieldList requiredFieldList) throws FrontendException {
  if (requiredFieldList == null)   return null;
  schema=getSchemaFromRequiredFieldList(schema,requiredFieldList.getFields());
  return new RequiredFieldResponse(true);
}

Fixed version (ground truth):
@Override public RequiredFieldResponse pushProjection(RequiredFieldList requiredFieldList) throws FrontendException {
  if (requiredFieldList == null)   return null;
  schema=getSchemaFromRequiredFieldList(schema,requiredFieldList.getFields());
  storeInUDFContext(PARQUET_PIG_SCHEMA,pigSchemaToString(schema));
  return new RequiredFieldResponse(true);
}
Program: 112038
Project: 112038
Buggy source:
@Override public void setLocation(String location,Job job) throws IOException {
  if (DEBUG)   LOG.debug("String_Node_Str" + location + "String_Node_Str"+ job+ "String_Node_Str");
  setInput(location,job);
  if (schema == null) {
    initSchema(job);
  }
  getConfiguration(job).set(PARQUET_PIG_SCHEMA,pigSchemaToString(schema));
}

Fixed version (ground truth):
@Override public void setLocation(String location,Job job) throws IOException {
  if (DEBUG)   LOG.debug("String_Node_Str" + location + "String_Node_Str"+ job+ "String_Node_Str");
  setInput(location,job);
  getConfiguration(job).set(PARQUET_PIG_SCHEMA,pigSchemaToString(schema));
}
Program: 112039
Project: 112039
Buggy source:
/** 
 * @param pigSchemaString the pig schema to parse
 * @return the parsed pig schema
 */
static Schema parsePigSchema(String pigSchemaString){
  try {
    return pigSchemaString == null ? null : Utils.getSchemaFromString(pigSchemaString);
  }
 catch (  ParserException e) {
    throw new SchemaConversionException("String_Node_Str" + pigSchemaString,e);
  }
}

Fixed version (ground truth):
/** 
 * @param pigSchemaString the pig schema to parse
 * @return the parsed pig schema
 */
public static Schema parsePigSchema(String pigSchemaString){
  try {
    return pigSchemaString == null ? null : Utils.getSchemaFromString(pigSchemaString);
  }
 catch (  ParserException e) {
    throw new SchemaConversionException("String_Node_Str" + pigSchemaString,e);
  }
}
Program: 112040
Project: 112040
Buggy source:
/** 
 * {@inheritDoc}
 * @see parquet.io.api.RecordMaterializer#getCurrentRecord()
 */
@Override public T getCurrentRecord(){
  try {
    rootEvents=new ProtocolEventsAmender(rootEvents).amendMissingRequiredFields(thriftType);
    protocol.addAll(rootEvents);
    rootEvents.clear();
    return thriftReader.readOneRecord(protocol);
  }
 catch (  TException e) {
    throw new ParquetDecodingException("String_Node_Str",e);
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 * @see parquet.io.api.RecordMaterializer#getCurrentRecord()
 */
@Override public T getCurrentRecord(){
  try {
    List<TProtocol> fixedEvents=new ProtocolEventsAmender(rootEvents).amendMissingRequiredFields(thriftType);
    protocol.addAll(fixedEvents);
    rootEvents.clear();
    return thriftReader.readOneRecord(protocol);
  }
 catch (  TException e) {
    throw new ParquetDecodingException("String_Node_Str",e);
  }
}
Program: 112041
Project: 112041
Buggy source:
public List<TProtocol> createProtocolEventsForField(ThriftField missingField){
  TProtocol fieldBegin=new ReadFieldBeginProtocol(missingField);
  createdEvents.add(fieldBegin);
  DummyCreatorVisitor dummyCreatorvisitor=new DummyCreatorVisitor();
  missingField.getType().accept(dummyCreatorvisitor);
  createdEvents.addAll(dummyCreatorvisitor.getEvents());
  createdEvents.add(READ_FIELD_END);
  return createdEvents;
}

Fixed version (ground truth):
public List<TProtocol> createProtocolEventsForField(ThriftField missingField){
  TProtocol fieldBegin=new ReadFieldBeginProtocol(missingField);
  createdEvents.add(fieldBegin);
  DefaultEventsVisitor dummyCreatorvisitor=new DefaultEventsVisitor();
  missingField.getType().accept(dummyCreatorvisitor);
  createdEvents.addAll(dummyCreatorvisitor.getEvents());
  createdEvents.add(READ_FIELD_END);
  return createdEvents;
}
Program: 112042
Project: 112042
Buggy source:
private void flushStore() throws IOException {
  LOG.info("String_Node_Str" + store.allocatedSize());
  w.startBlock(recordCount);
  store.flush();
  pageStore.flushToFileWriter(w);
  recordCount=0;
  w.endBlock();
  store=null;
  pageStore=null;
}

Fixed version (ground truth):
private void flushStore() throws IOException {
  LOG.info("String_Node_Str" + store.allocatedSize());
  if (store.allocatedSize() > 3 * blockSize) {
    LOG.warn("String_Node_Str" + store.memUsageString());
  }
  w.startBlock(recordCount);
  store.flush();
  pageStore.flushToFileWriter(w);
  recordCount=0;
  w.endBlock();
  store=null;
  pageStore=null;
}
Program: 112043
Project: 112043
Buggy source:
private void checkBlockSizeReached() throws IOException {
  if (recordCount >= recordCountForNextMemCheck) {
    long memSize=store.memSize();
    if (memSize > blockSize) {
      LOG.info("String_Node_Str" + memSize + "String_Node_Str"+ blockSize+ "String_Node_Str"+ recordCount+ "String_Node_Str");
      flushStore();
      initStore();
      recordCountForNextMemCheck=Math.max(100,recordCount / 2);
    }
 else {
      float recordSize=(float)memSize / recordCount;
      recordCountForNextMemCheck=Math.max(100,(recordCount + (long)(blockSize / recordSize)) / 2);
      LOG.debug("String_Node_Str" + recordCount + "String_Node_Str"+ recordCountForNextMemCheck);
    }
  }
}

Fixed version (ground truth):
private void checkBlockSizeReached() throws IOException {
  if (recordCount >= recordCountForNextMemCheck) {
    long memSize=store.memSize();
    if (memSize > blockSize) {
      LOG.info("String_Node_Str" + memSize + "String_Node_Str"+ blockSize+ "String_Node_Str"+ recordCount+ "String_Node_Str");
      flushStore();
      initStore();
      recordCountForNextMemCheck=min(max(MINIMUM_RECORD_COUNT_FOR_CHECK,recordCount / 2),MAXIMUM_RECORD_COUNT_FOR_CHECK);
    }
 else {
      float recordSize=(float)memSize / recordCount;
      recordCountForNextMemCheck=min(max(MINIMUM_RECORD_COUNT_FOR_CHECK,(recordCount + (long)(blockSize / recordSize)) / 2),recordCount + MAXIMUM_RECORD_COUNT_FOR_CHECK);
      if (DEBUG)       LOG.debug("String_Node_Str" + recordCount + "String_Node_Str"+ recordCountForNextMemCheck);
    }
  }
}
Program: 112046
Project: 112046
Buggy source:
public static void main(String[] args) throws Throwable {
  File out=new File("String_Node_Str");
  if (out.exists()) {
    if (!out.delete()) {
      throw new RuntimeException("String_Node_Str" + out.getAbsolutePath());
    }
  }
  Path testFile=new Path(out.toURI());
  Configuration configuration=new Configuration();
{
    MessageType schema=new MessageType("String_Node_Str",new PrimitiveType(Repetition.OPTIONAL,PrimitiveTypeName.INT32,"String_Node_Str"));
    MemPageStore pageStore=new MemPageStore(100);
    ColumnWriteStoreImpl store=new ColumnWriteStoreImpl(pageStore,8 * 1024,8 * 1024,false);
    MessageColumnIO columnIO=new ColumnIOFactory().getColumnIO(schema);
    RecordConsumer recordWriter=columnIO.getRecordWriter(store);
    int recordCount=0;
    for (int i=0; i < 100; i++) {
      recordWriter.startMessage();
      recordWriter.startField("String_Node_Str",0);
      if (i % 10 != 0) {
        recordWriter.addInteger(i);
      }
      recordWriter.endField("String_Node_Str",0);
      recordWriter.endMessage();
      ++recordCount;
    }
    store.flush();
    writeToFile(testFile,configuration,schema,pageStore,recordCount);
  }
{
    readTestFile(testFile,configuration);
  }
}

Fixed version (ground truth):
public static void main(String[] args) throws Throwable {
  File out=new File("String_Node_Str");
  if (out.exists()) {
    if (!out.delete()) {
      throw new RuntimeException("String_Node_Str" + out.getAbsolutePath());
    }
  }
  Path testFile=new Path(out.toURI());
  Configuration configuration=new Configuration();
{
    MessageType schema=new MessageType("String_Node_Str",new PrimitiveType(Repetition.OPTIONAL,PrimitiveTypeName.INT32,"String_Node_Str"));
    MemPageStore pageStore=new MemPageStore(100);
    ColumnWriteStoreImpl store=new ColumnWriteStoreImpl(pageStore,8 * 1024,8 * 1024,8 * 1024,false);
    MessageColumnIO columnIO=new ColumnIOFactory().getColumnIO(schema);
    RecordConsumer recordWriter=columnIO.getRecordWriter(store);
    int recordCount=0;
    for (int i=0; i < 100; i++) {
      recordWriter.startMessage();
      recordWriter.startField("String_Node_Str",0);
      if (i % 10 != 0) {
        recordWriter.addInteger(i);
      }
      recordWriter.endField("String_Node_Str",0);
      recordWriter.endMessage();
      ++recordCount;
    }
    store.flush();
    writeToFile(testFile,configuration,schema,pageStore,recordCount);
  }
{
    readTestFile(testFile,configuration);
  }
}