nus-yam/ex-repair huggingface dataset:
Program: 30787
Project: 30787
Buggy source:
private void createColumnInstanceAt(Path path,ObjList<ReadOnlyColumn> columns,LongList columnTops,int columnIndex,int columnBase,long partitionRowCount){
  int plen=path.length();
  try {
    String name=metadata.getColumnName(columnIndex);
    if (ff.exists(TableUtils.dFile(path.trimTo(plen),name))) {
      int type=metadata.getColumnQuick(columnIndex).getType();
      ReadOnlyColumn mem1=new ReadOnlyMemory(ff,path,ff.getMapPageSize(),0);
switch (type) {
case ColumnType.BINARY:
case ColumnType.STRING:
        ReadOnlyColumn mem2=new ReadOnlyMemory(ff,TableUtils.iFile(path.trimTo(plen),name),ff.getMapPageSize(),0);
      columns.setQuick(getPrimaryColumnIndex(columnBase,columnIndex),mem1);
    columns.setQuick(getSecondaryColumnIndex(columnBase,columnIndex),mem2);
  growColumn(mem1,mem2,type,partitionRowCount);
break;
default :
columns.setQuick(getPrimaryColumnIndex(columnBase,columnIndex),mem1);
growColumn(mem1,null,type,partitionRowCount);
break;
}
columnTops.setQuick(columnBase / 2 + columnIndex,TableUtils.readColumnTop(ff,path.trimTo(plen),name,plen,tempMem8b));
}
 else {
columns.setQuick(getPrimaryColumnIndex(columnBase,columnIndex),NullColumn.INSTANCE);
columns.setQuick(getSecondaryColumnIndex(columnBase,columnIndex),NullColumn.INSTANCE);
}
}
  finally {
path.trimTo(plen);
}
}

Fixed version (ground truth):
private void createColumnInstanceAt(Path path,ObjList<ReadOnlyColumn> columns,LongList columnTops,int columnIndex,int columnBase,long partitionRowCount){
  int plen=path.length();
  try {
    String name=metadata.getColumnName(columnIndex);
    if (ff.exists(TableUtils.dFile(path.trimTo(plen),name))) {
      int type=metadata.getColumnQuick(columnIndex).getType();
      ReadOnlyColumn mem1=new ReadOnlyMemory(ff,path,ff.getMapPageSize(),0);
      long columnTop=TableUtils.readColumnTop(ff,path.trimTo(plen),name,plen,tempMem8b);
switch (type) {
case ColumnType.BINARY:
case ColumnType.STRING:
        ReadOnlyColumn mem2=new ReadOnlyMemory(ff,TableUtils.iFile(path.trimTo(plen),name),ff.getMapPageSize(),0);
      columns.setQuick(getPrimaryColumnIndex(columnBase,columnIndex),mem1);
    columns.setQuick(getSecondaryColumnIndex(columnBase,columnIndex),mem2);
  growColumn(mem1,mem2,type,partitionRowCount - columnTop);
break;
default :
columns.setQuick(getPrimaryColumnIndex(columnBase,columnIndex),mem1);
growColumn(mem1,null,type,partitionRowCount - columnTop);
break;
}
columnTops.setQuick(columnBase / 2 + columnIndex,columnTop);
}
 else {
columns.setQuick(getPrimaryColumnIndex(columnBase,columnIndex),NullColumn.INSTANCE);
columns.setQuick(getSecondaryColumnIndex(columnBase,columnIndex),NullColumn.INSTANCE);
}
}
  finally {
path.trimTo(plen);
}
}
Program: 30788
Project: 30788
Buggy source:
private long openPartition(int partitionIndex,int columnBase,boolean last){
  try {
    Path path=partitionPathGenerator.generate(this,partitionIndex);
    final long partitionSize;
    if (ff.exists(path)) {
      path.chopZ();
      if (last) {
        partitionSize=transientRowCount;
      }
 else {
        partitionSize=readPartitionSize(ff,path,tempMem8b);
      }
      LOG.info().$("String_Node_Str").$(path.$()).$("String_Node_Str").$(partitionSize).$(']').$();
      if (partitionSize > -1) {
        openPartitionColumns(path,columnBase,partitionSize);
        partitionRowCounts.setQuick(partitionIndex,partitionSize);
      }
    }
 else {
      partitionSize=-1;
    }
    return partitionSize;
  }
  finally {
    path.trimTo(rootLen);
  }
}

Fixed version (ground truth):
private long openPartition(int partitionIndex,int columnBase,boolean last){
  try {
    Path path=partitionPathGenerator.generate(this,partitionIndex);
    final long partitionSize;
    if (ff.exists(path)) {
      path.chopZ();
      if (last) {
        partitionSize=transientRowCount;
      }
 else {
        partitionSize=readPartitionSize(ff,path,tempMem8b);
      }
      LOG.info().$("String_Node_Str").$(path.$()).$("String_Node_Str").$(partitionSize).$("String_Node_Str").$(last).$("String_Node_Str").$(transientRowCount).$(']').$();
      if (partitionSize > 0) {
        openPartitionColumns(path,columnBase,partitionSize);
        partitionRowCounts.setQuick(partitionIndex,partitionSize);
      }
    }
 else {
      partitionSize=-1;
    }
    return partitionSize;
  }
  finally {
    path.trimTo(rootLen);
  }
}
Program: 30789
Project: 30789
Buggy source:
/** 
 * Updates boundaries of all columns in partition.
 * @param partitionIndex index of partition
 * @param rowCount       number of rows in partition
 */
private void reloadPartition(int partitionIndex,long rowCount){
  int symbolMapIndex=0;
  int columnBase=getColumnBase(partitionIndex);
  for (int i=0; i < columnCount; i++) {
    growColumn(columns.getQuick(getPrimaryColumnIndex(columnBase,i)),columns.getQuick(getSecondaryColumnIndex(columnBase,i)),metadata.getColumnQuick(i).getType(),rowCount);
    SymbolMapReader reader=symbolMapReaders.getQuick(i);
    if (reader != null) {
      reader.updateSymbolCount(symbolCountSnapshot.getQuick(symbolMapIndex++));
    }
  }
  partitionRowCounts.setQuick(partitionIndex,rowCount);
}

Fixed version (ground truth):
/** 
 * Updates boundaries of all columns in partition.
 * @param partitionIndex index of partition
 * @param rowCount       number of rows in partition
 */
private void reloadPartition(int partitionIndex,long rowCount){
  int symbolMapIndex=0;
  int columnBase=getColumnBase(partitionIndex);
  for (int i=0; i < columnCount; i++) {
    growColumn(columns.getQuick(getPrimaryColumnIndex(columnBase,i)),columns.getQuick(getSecondaryColumnIndex(columnBase,i)),metadata.getColumnQuick(i).getType(),rowCount - this.columnTops.getQuick(columnBase / 2 + i));
    SymbolMapReader reader=symbolMapReaders.getQuick(i);
    if (reader != null) {
      reader.updateSymbolCount(symbolCountSnapshot.getQuick(symbolMapIndex++));
    }
  }
  partitionRowCounts.setQuick(partitionIndex,rowCount);
}
Program: 30791
Project: 30791
Buggy source:
private long openPartition0(int partitionIndex){
  try {
    Path path=partitionPathGenerator.generate(this,partitionIndex);
    if (ff.exists(path)) {
      path.chopZ();
      final long partitionSize=partitionIndex == partitionCount - 1 ? transientRowCount : readPartitionSize(ff,path,tempMem8b);
      LOG.info().$("String_Node_Str").utf8(path.$()).$("String_Node_Str").$(partitionSize).$("String_Node_Str").$(transientRowCount).$("String_Node_Str").$(partitionIndex).$("String_Node_Str").$(partitionCount).$();
      if (partitionSize > 0) {
        openPartitionColumns(path,getColumnBase(partitionIndex),partitionSize);
        partitionRowCounts.setQuick(partitionIndex,partitionSize);
      }
      return partitionSize;
    }
    return -1;
  }
  finally {
    path.trimTo(rootLen);
  }
}

Fixed version (ground truth):
private long openPartition0(int partitionIndex){
  try {
    Path path=partitionPathGenerator.generate(this,partitionIndex);
    if (ff.exists(path)) {
      if (reloadMethod == FIRST_TIME_PARTITIONED_RELOAD_METHOD) {
        reloadMethod=PARTITIONED_RELOAD_METHOD;
      }
 else       if (reloadMethod == FIRST_TIME_NON_PARTITIONED_RELOAD_METHOD) {
        reloadMethod=NON_PARTITIONED_RELOAD_METHOD;
      }
      path.chopZ();
      final long partitionSize=partitionIndex == partitionCount - 1 ? transientRowCount : readPartitionSize(ff,path,tempMem8b);
      LOG.info().$("String_Node_Str").utf8(path.$()).$("String_Node_Str").$(partitionSize).$("String_Node_Str").$(transientRowCount).$("String_Node_Str").$(partitionIndex).$("String_Node_Str").$(partitionCount).$();
      if (partitionSize > 0) {
        openPartitionColumns(path,getColumnBase(partitionIndex),partitionSize);
        partitionRowCounts.setQuick(partitionIndex,partitionSize);
      }
      return partitionSize;
    }
    return -1;
  }
  finally {
    path.trimTo(rootLen);
  }
}
Program: 30792
Project: 30792
Buggy source:
private void updateCapacities(){
  int capacity=getColumnBase(partitionCount);
  columns.setPos(capacity);
  this.partitionRowCounts.seed(partitionCount,-1);
  this.columnTops=new LongList(capacity / 2);
  this.columnTops.setPos(capacity / 2);
}

Fixed version (ground truth):
private void updateCapacities(){
  int capacity=getColumnBase(partitionCount);
  columns.setPos(capacity);
  this.partitionRowCounts.seed(partitionCount,-1);
  this.columnTops.setPos(capacity / 2);
}
Program: 30793
Project: 30793
Buggy source:
private void removeColumnFiles(CharSequence name){
  try {
    ff.iterateDir(path.$(),(file,type) -> {
      nativeLPSZ.of(file);
      if (type == Files.DT_DIR && !IGNORED_FILES.contains(nativeLPSZ)) {
        path.trimTo(rootLen);
        path.concat(nativeLPSZ);
        int plen=path.length();
        removeFileAndOrLog(ff,TableUtils.dFile(path,name));
        removeFileAndOrLog(ff,TableUtils.iFile(path.trimTo(plen),name));
        removeFileAndOrLog(ff,TableUtils.topFile(path.trimTo(plen),name));
      }
    }
);
  }
  finally {
    path.trimTo(rootLen);
  }
}

Fixed version (ground truth):
private void removeColumnFiles(CharSequence name,RemoveFileLambda removeLambda){
  try {
    ff.iterateDir(path.$(),(file,type) -> {
      nativeLPSZ.of(file);
      if (type == Files.DT_DIR && !IGNORED_FILES.contains(nativeLPSZ)) {
        path.trimTo(rootLen);
        path.concat(nativeLPSZ);
        int plen=path.length();
        removeLambda.remove(ff,TableUtils.dFile(path,name));
        removeLambda.remove(ff,TableUtils.iFile(path.trimTo(plen),name));
        removeLambda.remove(ff,TableUtils.topFile(path.trimTo(plen),name));
      }
    }
);
  }
  finally {
    path.trimTo(rootLen);
  }
}
Program: 30795
Project: 30795
Buggy source:
private static void removeOrException(FilesFacade ff,Path path){
  if (ff.exists(path) && !ff.remove(path)) {
    throw CairoException.instance(ff.errno()).put("String_Node_Str").put(path);
  }
}

Fixed version (ground truth):
private static void removeOrException(FilesFacade ff,LPSZ path){
  if (ff.exists(path) && !ff.remove(path)) {
    throw CairoException.instance(ff.errno()).put("String_Node_Str").put(path);
  }
}
Program: 30797
Project: 30797
Buggy source:
@Override public boolean remove(LPSZ name){
  if (counter > 0 && Chars.endsWith(name,"String_Node_Str") || Chars.endsWith(name,"String_Node_Str")) {
    counter--;
    return false;
  }
  return super.remove(name);
}

Fixed version (ground truth):
@Override public boolean remove(LPSZ name){
  if (counter > 0 && (Chars.endsWith(name,"String_Node_Str") || Chars.endsWith(name,"String_Node_Str"))) {
    counter--;
    return false;
  }
  return super.remove(name);
}
Program: 30798
Project: 30798
Buggy source:
private void updateKeyCount(){
  int keyCount;
  long timestamp=clock.getTicks();
  while (true) {
    long seq=this.keyMem.getLong(BitmapIndexUtils.KEY_RESERVED_OFFSET_SEQUENCE);
    Unsafe.getUnsafe().loadFence();
    keyCount=this.keyMem.getInt(BitmapIndexUtils.KEY_RESERVED_OFFSET_KEY_COUNT);
    Unsafe.getUnsafe().loadFence();
    if (this.keyMem.getLong(BitmapIndexUtils.KEY_RESERVED_OFFSET_SEQUENCE_CHECK) == seq) {
      break;
    }
    if (clock.getTicks() - timestamp > spinLockTimeoutUs) {
      this.keyCount=0;
      LOG.error().$("String_Node_Str").$(spinLockTimeoutUs).utf8("String_Node_Str").$();
      throw CairoException.instance(0).put("String_Node_Str");
    }
  }
  if (keyCount > this.keyCount) {
    this.keyCount=keyCount;
  }
}

Fixed version (ground truth):
private void updateKeyCount(){
  int keyCount;
  final long deadline=clock.getTicks() + spinLockTimeoutUs;
  while (true) {
    long seq=this.keyMem.getLong(BitmapIndexUtils.KEY_RESERVED_OFFSET_SEQUENCE);
    Unsafe.getUnsafe().loadFence();
    if (this.keyMem.getLong(BitmapIndexUtils.KEY_RESERVED_OFFSET_SEQUENCE_CHECK) == seq) {
      keyCount=this.keyMem.getInt(BitmapIndexUtils.KEY_RESERVED_OFFSET_KEY_COUNT);
      Unsafe.getUnsafe().loadFence();
      if (seq == this.keyMem.getLong(BitmapIndexUtils.KEY_RESERVED_OFFSET_SEQUENCE)) {
        break;
      }
    }
    if (clock.getTicks() > deadline) {
      this.keyCount=0;
      LOG.error().$("String_Node_Str").$(spinLockTimeoutUs).utf8("String_Node_Str").$();
      throw CairoException.instance(0).put("String_Node_Str");
    }
  }
  if (keyCount > this.keyCount) {
    this.keyCount=keyCount;
  }
}
Program: 30801
Project: 30801
Buggy source:
private int addColumnToMeta(CharSequence name,int type,boolean indexFlag,int indexValueBlockCapacity){
  int index;
  try {
    index=TableUtils.openMetaSwapFile(ff,ddlMem,path,rootLen,30);
    int columnCount=metaMem.getInt(TableUtils.META_OFFSET_COUNT);
    ddlMem.putInt(columnCount + 1);
    ddlMem.putInt(metaMem.getInt(TableUtils.META_OFFSET_PARTITION_BY));
    ddlMem.putInt(metaMem.getInt(TableUtils.META_OFFSET_TIMESTAMP_INDEX));
    ddlMem.jumpTo(TableUtils.META_OFFSET_COLUMN_TYPES);
    for (int i=0; i < columnCount; i++) {
      ddlMem.putByte((byte)TableUtils.getColumnType(metaMem,i));
      ddlMem.putBool(TableUtils.isColumnIndexed(metaMem,i));
      ddlMem.putInt(TableUtils.getIndexBlockCapacity(metaMem,i));
      ddlMem.skip(10);
    }
    ddlMem.putByte((byte)type);
    ddlMem.putBool(indexFlag);
    ddlMem.putInt(indexValueBlockCapacity);
    ddlMem.skip(10);
    long nameOffset=TableUtils.getColumnNameOffset(columnCount);
    for (int i=0; i < columnCount; i++) {
      CharSequence columnName=metaMem.getStr(nameOffset);
      ddlMem.putStr(columnName);
      nameOffset+=VirtualMemory.getStorageLength(columnName);
    }
    ddlMem.putStr(name);
  }
  finally {
    ddlMem.close();
  }
  return index;
}

Fixed version (ground truth):
private int addColumnToMeta(CharSequence name,int type,boolean indexFlag,int indexValueBlockCapacity){
  int index;
  try {
    index=TableUtils.openMetaSwapFile(ff,ddlMem,path,rootLen,configuration.getMaxNumberOfSwapFiles());
    int columnCount=metaMem.getInt(TableUtils.META_OFFSET_COUNT);
    ddlMem.putInt(columnCount + 1);
    ddlMem.putInt(metaMem.getInt(TableUtils.META_OFFSET_PARTITION_BY));
    ddlMem.putInt(metaMem.getInt(TableUtils.META_OFFSET_TIMESTAMP_INDEX));
    ddlMem.jumpTo(TableUtils.META_OFFSET_COLUMN_TYPES);
    for (int i=0; i < columnCount; i++) {
      ddlMem.putByte((byte)TableUtils.getColumnType(metaMem,i));
      ddlMem.putBool(TableUtils.isColumnIndexed(metaMem,i));
      ddlMem.putInt(TableUtils.getIndexBlockCapacity(metaMem,i));
      ddlMem.skip(10);
    }
    ddlMem.putByte((byte)type);
    ddlMem.putBool(indexFlag);
    ddlMem.putInt(indexValueBlockCapacity);
    ddlMem.skip(10);
    long nameOffset=TableUtils.getColumnNameOffset(columnCount);
    for (int i=0; i < columnCount; i++) {
      CharSequence columnName=metaMem.getStr(nameOffset);
      ddlMem.putStr(columnName);
      nameOffset+=VirtualMemory.getStorageLength(columnName);
    }
    ddlMem.putStr(name);
  }
  finally {
    ddlMem.close();
  }
  return index;
}
Program: 30803
Project: 30803
Buggy source:
public final void close(boolean truncate){
  long sz=getAppendOffset();
  releaseCurrentPage();
  super.close();
  if (fd != -1) {
    try {
      if (truncate) {
        if (ff.truncate(fd,sz)) {
          LOG.info().$("String_Node_Str").$(fd).$(']').$();
        }
 else {
          if (!ff.supportsTruncateMappedFiles()) {
            long n=sz / getMapPageSize();
            if (ff.truncate(fd,(n + 1) * getMapPageSize())) {
              LOG.info().$("String_Node_Str").$(fd).$(']').$();
              return;
            }
          }
          LOG.info().$("String_Node_Str").$(fd).$("String_Node_Str").$(ff.errno()).$(']').$();
        }
      }
 else {
        LOG.info().$("String_Node_Str").$(fd).$(']').$();
      }
    }
  finally {
      closeFd();
    }
  }
}

Fixed version (ground truth):
public final void close(boolean truncate){
  long sz=getAppendOffset();
  releaseCurrentPage();
  super.close();
  if (fd != -1) {
    try {
      if (truncate) {
        if (ff.truncate(fd,sz)) {
          LOG.info().$("String_Node_Str").$(fd).$(']').$();
        }
 else {
          if (ff.isRestrictedFileSystem()) {
            long n=sz / getMapPageSize();
            if (ff.truncate(fd,(n + 1) * getMapPageSize())) {
              LOG.info().$("String_Node_Str").$(fd).$(']').$();
              return;
            }
          }
          LOG.info().$("String_Node_Str").$(fd).$("String_Node_Str").$(ff.errno()).$(']').$();
        }
      }
 else {
        LOG.info().$("String_Node_Str").$(fd).$(']').$();
      }
    }
  finally {
      closeFd();
    }
  }
}
Program: 30804
Project: 30804
Buggy source:
@Override public void close(){
  long size=getAppendOffset();
  super.close();
  if (fd != -1) {
    try {
      if (ff.truncate(fd,size)) {
        LOG.info().$("String_Node_Str").$(fd).$(']').$();
      }
 else {
        if (!ff.supportsTruncateMappedFiles()) {
          long n=size / getMapPageSize();
          if (ff.truncate(fd,(n + 1) * getMapPageSize())) {
            LOG.info().$("String_Node_Str").$(fd).$(']').$();
            return;
          }
        }
        LOG.info().$("String_Node_Str").$(fd).$("String_Node_Str").$(ff.errno()).$(']').$();
      }
    }
  finally {
      ff.close(fd);
      fd=-1;
    }
  }
}

Fixed version (ground truth):
@Override public void close(){
  long size=getAppendOffset();
  super.close();
  if (fd != -1) {
    try {
      if (ff.truncate(fd,size)) {
        LOG.info().$("String_Node_Str").$(fd).$(']').$();
      }
 else {
        if (ff.isRestrictedFileSystem()) {
          long n=size / getMapPageSize();
          if (ff.truncate(fd,(n + 1) * getMapPageSize())) {
            LOG.info().$("String_Node_Str").$(fd).$(']').$();
            return;
          }
        }
        LOG.info().$("String_Node_Str").$(fd).$("String_Node_Str").$(ff.errno()).$(']').$();
      }
    }
  finally {
      ff.close(fd);
      fd=-1;
    }
  }
}
Program: 30805
Project: 30805
Buggy source:
public void updateSymbolCount(int symbolCount){
  if (symbolCount > this.symbolCount) {
    this.symbolCount=symbolCount;
    this.maxOffset=SymbolMapWriter.keyToOffset(symbolCount - 1);
    this.offsetMem.grow(maxOffset);
    growCharMemToSymbolCount(symbolCount);
  }
}

Fixed version (ground truth):
@Override public void updateSymbolCount(int symbolCount){
  if (symbolCount > this.symbolCount) {
    this.symbolCount=symbolCount;
    this.maxOffset=SymbolMapWriter.keyToOffset(symbolCount - 1);
    this.offsetMem.grow(maxOffset);
    growCharMemToSymbolCount(symbolCount);
  }
}
Program: 30806
Project: 30806
Buggy source:
private void growCharMemToSymbolCount(int symbolCount){
  if (symbolCount > 0) {
    long lastSymbolOffset=this.offsetMem.getLong(SymbolMapWriter.keyToOffset(symbolCount - 1));
    int l=VirtualMemory.getStorageLength(this.charMem.getStr(lastSymbolOffset));
    this.charMem.grow(lastSymbolOffset + l);
  }
 else {
    this.charMem.grow(0);
  }
}

Fixed version (ground truth):
private void growCharMemToSymbolCount(int symbolCount){
  if (symbolCount > 0) {
    long lastSymbolOffset=this.offsetMem.getLong(SymbolMapWriter.keyToOffset(symbolCount - 1));
    this.charMem.grow(lastSymbolOffset + 4);
    this.charMem.grow(lastSymbolOffset + this.charMem.getStrLen(lastSymbolOffset) * 2 + 4);
  }
 else {
    this.charMem.grow(0);
  }
}
Program: 30808
Project: 30808
Buggy source:
private void removeColumn(int index){
  Misc.free(getPrimaryColumn(index));
  Misc.free(getSecondaryColumn(index));
  columns.remove(getSecondaryColumnIndex(index));
  columns.remove(getPrimaryColumnIndex(index));
  columnTops.removeIndex(index);
}

Fixed version (ground truth):
private void removeColumn(int index){
  Misc.free(getPrimaryColumn(index));
  Misc.free(getSecondaryColumn(index));
  columns.remove(getSecondaryColumnIndex(index));
  columns.remove(getPrimaryColumnIndex(index));
  columnTops.removeIndex(index);
  nullers.remove(index);
}
Program: 30809
Project: 30809
Buggy source:
public void truncate(){
  if (fd == -1) {
    return;
  }
  releaseCurrentPage();
  if (!ff.truncate(fd,getMapPageSize())) {
    throw CairoException.instance(Os.errno()).put("String_Node_Str").put(fd).put("String_Node_Str").put(getMapPageSize()).put("String_Node_Str");
  }
  updateLimits(0,pageAddress=mapPage(0));
}

Fixed version (ground truth):
public void truncate(){
  if (fd == -1) {
    return;
  }
  releaseCurrentPage();
  if (!ff.truncate(fd,getMapPageSize())) {
    throw CairoException.instance(ff.errno()).put("String_Node_Str").put(fd).put("String_Node_Str").put(getMapPageSize()).put("String_Node_Str");
  }
  updateLimits(0,pageAddress=mapPage(0));
}
Program: 30810
Project: 30810
Buggy source:
public final void close(boolean truncate){
  long sz=getAppendOffset();
  releaseCurrentPage();
  super.close();
  if (fd != -1) {
    try {
      if (truncate) {
        if (ff.truncate(fd,sz)) {
          LOG.info().$("String_Node_Str").$(fd).$(']').$();
        }
 else {
          if (!ff.supportsTruncateMappedFiles()) {
            long n=sz / getMapPageSize();
            if (ff.truncate(fd,(n + 1) * getMapPageSize())) {
              LOG.info().$("String_Node_Str").$(fd).$(']').$();
              return;
            }
          }
          LOG.info().$("String_Node_Str").$(fd).$("String_Node_Str").$(Os.errno()).$(']').$();
        }
      }
 else {
        LOG.info().$("String_Node_Str").$(fd).$(']').$();
      }
    }
  finally {
      closeFd();
    }
  }
}

Fixed version (ground truth):
public final void close(boolean truncate){
  long sz=getAppendOffset();
  releaseCurrentPage();
  super.close();
  if (fd != -1) {
    try {
      if (truncate) {
        if (ff.truncate(fd,sz)) {
          LOG.info().$("String_Node_Str").$(fd).$(']').$();
        }
 else {
          if (!ff.supportsTruncateMappedFiles()) {
            long n=sz / getMapPageSize();
            if (ff.truncate(fd,(n + 1) * getMapPageSize())) {
              LOG.info().$("String_Node_Str").$(fd).$(']').$();
              return;
            }
          }
          LOG.info().$("String_Node_Str").$(fd).$("String_Node_Str").$(ff.errno()).$(']').$();
        }
      }
 else {
        LOG.info().$("String_Node_Str").$(fd).$(']').$();
      }
    }
  finally {
      closeFd();
    }
  }
}
Program: 30812
Project: 30812
Buggy source:
@Override public void close(){
  long size=getAppendOffset();
  super.close();
  if (fd != -1) {
    ff.truncate(fd,size);
    ff.close(fd);
    LOG.info().$("String_Node_Str").$(fd).$(']').$();
    fd=-1;
  }
}

Fixed version (ground truth):
@Override public void close(){
  long size=getAppendOffset();
  super.close();
  if (fd != -1) {
    try {
      if (ff.truncate(fd,size)) {
        LOG.info().$("String_Node_Str").$(fd).$(']').$();
      }
 else {
        if (!ff.supportsTruncateMappedFiles()) {
          long n=size / getMapPageSize();
          if (ff.truncate(fd,(n + 1) * getMapPageSize())) {
            LOG.info().$("String_Node_Str").$(fd).$(']').$();
            return;
          }
        }
        LOG.info().$("String_Node_Str").$(fd).$("String_Node_Str").$(ff.errno()).$(']').$();
      }
    }
  finally {
      ff.close(fd);
      fd=-1;
    }
  }
}
Program: 30813
Project: 30813
Buggy source:
public void applyTransitionIndex(long address){
  this.metaMem.of(ff,path,ff.getPageSize());
  this.columnNameIndexMap.clear();
  final int columnCount=Unsafe.getUnsafe().getInt(address + 4);
  final long index=address + 8;
  final long stateAddress=index + columnCount * 8;
  boolean timestampRequired=true;
  if (columnCount > this.columnCount) {
    columnMetadata.setPos(columnCount);
    this.columnCount=columnCount;
  }
  Unsafe.getUnsafe().setMemory(stateAddress,columnCount,(byte)0);
  for (int i=0; i < columnCount; i++) {
    if (Unsafe.getUnsafe().getByte(stateAddress + i) == -1) {
      continue;
    }
    Unsafe.getUnsafe().putByte(stateAddress + i,(byte)-1);
    int copyFrom=Unsafe.getUnsafe().getInt(index + i * 8);
    if (copyFrom == i + 1) {
      columnNameIndexMap.put(columnMetadata.getQuick(i).getName(),i);
      continue;
    }
    if (copyFrom > 0) {
      TableColumnMetadata tmp=moveMetadata(copyFrom - 1,null);
      columnNameIndexMap.put(tmp.getName(),i);
      tmp=moveMetadata(i,tmp);
      if (copyFrom - 1 == timestampIndex && timestampRequired) {
        timestampIndex=i;
        timestampRequired=false;
      }
      int copyTo=Unsafe.getUnsafe().getInt(index + i * 8 + 4);
      while (copyTo > 0) {
        if (Unsafe.getUnsafe().getByte(stateAddress + copyTo - 1) == -1) {
          break;
        }
        Unsafe.getUnsafe().putByte(stateAddress + copyTo - 1,(byte)-1);
        columnNameIndexMap.put(tmp.getName(),copyTo - 1);
        tmp=moveMetadata(copyTo - 1,tmp);
        copyFrom=copyTo;
        copyTo=Unsafe.getUnsafe().getInt(index + (copyTo - 1) * 8 + 4);
        if ((copyFrom - 1) == timestampIndex && timestampRequired) {
          timestampIndex=copyTo - 1;
          timestampRequired=false;
        }
      }
      if (tmp != null && i == timestampIndex && timestampRequired) {
        timestampIndex=-1;
        timestampRequired=false;
      }
    }
 else {
      TableColumnMetadata m=newInstance(i,columnCount);
      moveMetadata(i,m);
      columnNameIndexMap.put(m.getName(),i);
    }
  }
  if (columnCount < this.columnCount) {
    if (timestampIndex >= columnCount && timestampRequired) {
      timestampIndex=-1;
    }
    columnMetadata.setPos(columnCount);
    this.columnCount=columnCount;
  }
}

Fixed version (ground truth):
public void applyTransitionIndex(long address){
}
Program: 30815
Project: 30815
Buggy source:
public SymbolMapWriter(CairoConfiguration configuration,CharSequence name,int capacity,int maxHash){
  this.writer=new BitmapIndexWriter(configuration,name,capacity);
  this.reader=new BitmapIndexBackwardReader(configuration,name);
  long mapPageSize=configuration.getFilesFacade().getMapPageSize();
  try (Path path=new Path()){
    this.charMem=new ReadWriteMemory(configuration.getFilesFacade(),path.of(configuration.getRoot()).concat(name).put("String_Node_Str").$(),mapPageSize);
    this.offsetMem=new ReadWriteMemory(configuration.getFilesFacade(),path.of(configuration.getRoot()).concat(name).put("String_Node_Str").$(),mapPageSize);
  }
   this.maxHash=maxHash;
}

Fixed version (ground truth):
public SymbolMapWriter(CairoConfiguration configuration,CharSequence name,int capacity,int maxHash){
  this.writer=new BitmapIndexWriter(configuration,name,capacity);
  long mapPageSize=configuration.getFilesFacade().getMapPageSize();
  try (Path path=new Path()){
    this.charMem=new ReadWriteMemory(configuration.getFilesFacade(),path.of(configuration.getRoot()).concat(name).put("String_Node_Str").$(),mapPageSize);
    this.offsetMem=new ReadWriteMemory(configuration.getFilesFacade(),path.of(configuration.getRoot()).concat(name).put("String_Node_Str").$(),mapPageSize);
  }
   this.maxHash=maxHash;
}
Program: 30816
Project: 30816
Buggy source:
@Override public void close(){
  Misc.free(writer);
  Misc.free(reader);
  Misc.free(charMem);
  Misc.free(offsetMem);
}

Fixed version (ground truth):
@Override public void close(){
  Misc.free(writer);
  Misc.free(charMem);
  Misc.free(offsetMem);
}
Program: 30817
Project: 30817
Buggy source:
public long put(CharSequence symbol){
  int key=Hash.boundedHash(symbol,maxHash - 1);
  BitmapIndexCursor cursor=reader.getCursor(key,Long.MAX_VALUE);
  while (cursor.hasNext()) {
    long offsetOffset=cursor.next();
    long offset=offsetMem.getLong(offsetOffset);
    if (Chars.equals(symbol,charMem.getStr(offset))) {
      return offsetOffset / 8;
    }
  }
  long offset=charMem.putStr(symbol);
  long offsetOffset=offsetMem.getAppendOffset();
  offsetMem.putLong(offset);
  writer.add(key,offsetOffset);
  return offsetOffset / 8;
}

Fixed version (ground truth):
public long put(CharSequence symbol){
  int key=Hash.boundedHash(symbol,maxHash - 1);
  BitmapIndexCursor cursor=writer.getCursor(key);
  while (cursor.hasNext()) {
    long offsetOffset=cursor.next();
    long offset=offsetMem.getLong(offsetOffset);
    if (Chars.equals(symbol,charMem.getStr(offset))) {
      return offsetOffset / 8;
    }
  }
  long offset=charMem.putStr(symbol);
  long offsetOffset=offsetMem.getAppendOffset();
  offsetMem.putLong(offset);
  writer.add(key,offsetOffset);
  return offsetOffset / 8;
}
Program: 30818
Project: 30818
Buggy source:
char getCharBytes(int page,long pageOffset,long pageSize){
  char value=0;
  long pageAddress=getPageAddress(page);
  for (int i=0; i < 2; i++) {
    if (pageOffset == pageSize) {
      pageAddress=getPageAddress(++page);
      pageOffset=0;
    }
    char b=(char)(Unsafe.getUnsafe().getByte(pageAddress + pageOffset++));
    value=(char)((value << (8 * i)) | b);
  }
  return value;
}

Fixed version (ground truth):
char getCharBytes(int page,long pageOffset,long pageSize){
  char value=0;
  long pageAddress=getPageAddress(page);
  for (int i=0; i < 2; i++) {
    if (pageOffset == pageSize) {
      pageAddress=getPageAddress(++page);
      pageOffset=0;
    }
    char b=(char)(Unsafe.getUnsafe().getByte(pageAddress + pageOffset++));
    value=(char)((b << (8 * i)) | value);
  }
  return value;
}
Program: 30819
Project: 30819
Buggy source:
private void putSplitChar(char c){
  Unsafe.getUnsafe().putByte(pageHi - 1,(byte)(c >> 8));
  pageAt(baseOffset + pageHi);
  Unsafe.getUnsafe().putByte(appendPointer++,(byte)c);
}

Fixed version (ground truth):
private void putSplitChar(char c){
  Unsafe.getUnsafe().putByte(pageHi - 1,(byte)c);
  pageAt(baseOffset + pageHi);
  Unsafe.getUnsafe().putByte(appendPointer++,(byte)(c >> 8));
}
Program: 30820
Project: 30820
Buggy source:
private long offsetInPage(long offset){
  return offset & mod;
}

Fixed version (ground truth):
long offsetInPage(long offset){
  return offset & mod;
}
Program: 30821
Project: 30821
Buggy source:
@Test public void testSimpleAdd() throws Exception {
  TestUtils.assertMemoryLeak(() -> {
    int N=10000000;
    try (SymbolMapWriter writer=new SymbolMapWriter(configuration,"String_Node_Str",48,Numbers.ceilPow2(N))){
      Rnd rnd=new Rnd();
      long prev=-1L;
      for (int i=0; i < N; i++) {
        CharSequence cs=rnd.nextChars(10);
        long key=writer.put(cs);
        Assert.assertEquals(prev + 1,key);
        Assert.assertEquals(key,writer.put(cs));
        prev=key;
      }
    }
   }
);
}

Fixed version (ground truth):
@Test public void testSimpleAdd() throws Exception {
  TestUtils.assertMemoryLeak(() -> {
    int N=100000;
    try (SymbolMapWriter writer=new SymbolMapWriter(configuration,"String_Node_Str",4,Numbers.ceilPow2(N / 2))){
      Rnd rnd=new Rnd();
      long prev=-1L;
      for (int i=0; i < N; i++) {
        CharSequence cs=rnd.nextChars(10);
        long key=writer.put(cs);
        Assert.assertEquals(prev + 1,key);
        Assert.assertEquals(key,writer.put(cs));
        prev=key;
      }
    }
   }
);
}
Program: 30822
Project: 30822
Buggy source:
private void assertStrings(VirtualMemory mem,boolean b){
  if (b) {
    mem.putByte((byte)1);
  }
  long o1=mem.putStr("String_Node_Str");
  long o2=mem.putStr("String_Node_Str");
  long o3=mem.putStr(null);
  long o4=mem.putStr("String_Node_Str");
  long o5=mem.putNullStr();
  long o6=mem.putStr("String_Node_Str",3,3);
  long o7=mem.putStr(null,0,2);
  if (b) {
    assertEquals(1,mem.getByte(0));
  }
  TestUtils.assertEquals("String_Node_Str",mem.getStr(o1));
  Assert.assertEquals(3,mem.getStrLen(o1));
  TestUtils.assertEquals("String_Node_Str",mem.getStr2(o1));
  TestUtils.assertEquals("String_Node_Str",mem.getStr(o2));
  TestUtils.assertEquals("String_Node_Str",mem.getStr2(o2));
  assertNull(mem.getStr(o3));
  assertNull(mem.getStr2(o3));
  TestUtils.assertEquals("String_Node_Str",mem.getStr(o4));
  TestUtils.assertEquals("String_Node_Str",mem.getStr2(o4));
  assertNull(mem.getStr(o5));
  assertNull(mem.getStr2(o5));
  Assert.assertEquals(-1,mem.getStrLen(o5));
  TestUtils.assertEquals("String_Node_Str",mem.getStr(o6));
  Assert.assertNull(mem.getStr(o7));
  CharSequence s1=mem.getStr(o1);
  CharSequence s2=mem.getStr2(o2);
  Assert.assertFalse(Chars.equals(s1,s2));
}

Fixed version (ground truth):
private void assertStrings(VirtualMemory mem,boolean b){
  if (b) {
    mem.putByte((byte)1);
  }
  long o1=mem.putStr("String_Node_Str");
  long o2=mem.putStr("String_Node_Str");
  long o3=mem.putStr(null);
  long o4=mem.putStr("String_Node_Str");
  long o5=mem.putNullStr();
  long o6=mem.putStr("String_Node_Str",3,3);
  long o7=mem.putStr(null,0,2);
  if (b) {
    assertEquals(1,mem.getByte(0));
  }
  TestUtils.assertEquals("String_Node_Str",mem.getStr(o1));
  Assert.assertEquals(3,mem.getStrLen(o1));
  TestUtils.assertEquals("String_Node_Str",mem.getStr2(o1));
  String expected="String_Node_Str";
  TestUtils.assertEquals("String_Node_Str",mem.getStr(o2));
  TestUtils.assertEquals("String_Node_Str",mem.getStr2(o2));
  for (int i=0; i < expected.length(); i++) {
    long offset=o2 + 4 + i * 2;
    int page=mem.pageIndex(offset);
    long pageOffset=mem.offsetInPage(offset);
    final long pageSize=mem.getPageSize(page);
    Assert.assertEquals(expected.charAt(i),mem.getCharBytes(page,pageOffset,pageSize));
  }
  assertNull(mem.getStr(o3));
  assertNull(mem.getStr2(o3));
  TestUtils.assertEquals("String_Node_Str",mem.getStr(o4));
  TestUtils.assertEquals("String_Node_Str",mem.getStr2(o4));
  assertNull(mem.getStr(o5));
  assertNull(mem.getStr2(o5));
  Assert.assertEquals(-1,mem.getStrLen(o5));
  TestUtils.assertEquals("String_Node_Str",mem.getStr(o6));
  Assert.assertNull(mem.getStr(o7));
  CharSequence s1=mem.getStr(o1);
  CharSequence s2=mem.getStr2(o2);
  Assert.assertFalse(Chars.equals(s1,s2));
}
Program: 30824
Project: 30824
Buggy source:
private long openPartition(int partitionIndex,int columnBase,boolean last){
  try {
    Path path=partitionPathGenerator.generate(this,partitionIndex);
    final long partitionSize;
    if (ff.exists(path)) {
      path.chopZ();
      if (last) {
        partitionSize=transientRowCount;
      }
 else {
        partitionSize=readPartitionSize(ff,path,tempMem8b);
      }
      LOG.info().$("String_Node_Str").$(path.$()).$("String_Node_Str").$(partitionSize).$(']').$();
      if (partitionSize > 0) {
        openPartitionColumns(path,columnBase);
      }
    }
 else {
      partitionSize=-1;
    }
    partitionRowCounts.setQuick(partitionIndex,partitionSize);
    return partitionSize;
  }
  finally {
    path.trimTo(rootLen);
  }
}

Fixed version (ground truth):
private long openPartition(int partitionIndex,int columnBase,boolean last){
  try {
    Path path=partitionPathGenerator.generate(this,partitionIndex);
    final long partitionSize;
    if (ff.exists(path)) {
      path.chopZ();
      if (last) {
        partitionSize=transientRowCount;
      }
 else {
        partitionSize=readPartitionSize(ff,path,tempMem8b);
      }
      LOG.info().$("String_Node_Str").$(path.$()).$("String_Node_Str").$(partitionSize).$(']').$();
      if (partitionSize > -1) {
        openPartitionColumns(path,columnBase);
      }
    }
 else {
      partitionSize=-1;
    }
    partitionRowCounts.setQuick(partitionIndex,partitionSize);
    return partitionSize;
  }
  finally {
    path.trimTo(rootLen);
  }
}
Program: 30825
Project: 30825
Buggy source:
private int calculatePartitionCount(){
  if (partitionMin == Long.MAX_VALUE) {
    return 0;
  }
 else {
    return (int)(intervalLengthMethod.calculate(partitionMin,timestampFloorMethod.floor(maxTimestamp)) + 1);
  }
}

Fixed version (ground truth):
private int calculatePartitionCount(){
  if (partitionMin == Long.MAX_VALUE) {
    return 0;
  }
 else {
    return maxTimestamp == Numbers.LONG_NaN ? 1 : (int)(intervalLengthMethod.calculate(partitionMin,timestampFloorMethod.floor(maxTimestamp)) + 1);
  }
}
Program: 30826
Project: 30826
Buggy source:
private boolean switchPartition(){
  while (partitionIndex < partitionCount) {
    final int columnBase=getColumnBase(partitionIndex);
    long partitionSize=partitionRowCounts.getQuick(partitionIndex);
    if (partitionSize == -1) {
      partitionSize=openPartition(partitionIndex++,columnBase,partitionIndex == partitionCount);
    }
 else {
      partitionIndex++;
    }
    if (partitionSize != 0) {
      record.maxRecordIndex=partitionSize - 1;
      record.recordIndex=-1;
      record.columnBase=columnBase;
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
private boolean switchPartition(){
  while (partitionIndex < partitionCount) {
    final int columnBase=getColumnBase(partitionIndex);
    long partitionSize=partitionRowCounts.getQuick(partitionIndex);
    if (partitionSize == -1) {
      partitionSize=openPartition(partitionIndex++,columnBase,partitionIndex == partitionCount);
    }
 else {
      partitionIndex++;
    }
    if (partitionSize > 0) {
      record.maxRecordIndex=partitionSize - 1;
      record.recordIndex=-1;
      record.columnBase=columnBase;
      return true;
    }
  }
  return false;
}
Program: 30827
Project: 30827
Buggy source:
public void grow(long size){
  if (size > this.size) {
    grow0(size);
  }
}

Fixed version (ground truth):
void grow(long size){
  if (size > this.size) {
    grow0(size);
  }
}
Program: 30828
Project: 30828
Buggy source:
@Override public void trackFileSize(){
  long size=ff.length(fd);
  if (size < this.size) {
    setInitialSize(size);
  }
 else {
    grow(size);
  }
}

Fixed version (ground truth):
@Override public void trackFileSize(){
  long size=ff.length(fd);
  grow(size);
}
Program: 30829
Project: 30829
Buggy source:
public void of(FilesFacade ff,LPSZ name,long maxPageSize){
  close();
  this.ff=ff;
  boolean exists=ff.exists(name);
  if (!exists) {
    throw CairoException.instance(0).put("String_Node_Str").put(name);
  }
  fd=ff.openRO(name);
  if (fd == -1) {
    throw CairoException.instance(ff.errno()).put("String_Node_Str").put(name);
  }
  this.maxPageSize=maxPageSize;
  setInitialSize(ff.length(fd));
  LOG.info().$("String_Node_Str").$(name).$("String_Node_Str").$(fd).$(']').$();
}

Fixed version (ground truth):
public void of(FilesFacade ff,LPSZ name,long maxPageSize){
  close();
  this.ff=ff;
  boolean exists=ff.exists(name);
  if (!exists) {
    throw CairoException.instance(0).put("String_Node_Str").put(name);
  }
  fd=ff.openRO(name);
  if (fd == -1) {
    throw CairoException.instance(ff.errno()).put("String_Node_Str").put(name);
  }
  this.maxPageSize=maxPageSize;
  grow0(ff.length(fd));
  LOG.info().$("String_Node_Str").$(name).$("String_Node_Str").$(fd).$(']').$();
}
Program: 30830
Project: 30830
Buggy source:
private void grow0(long size){
  pages.ensureCapacity((int)(size / getMapPageSize() + 1));
  if (lastPageSize < getMapPageSize()) {
    int lastIndex=pages.size() - 1;
    if (lastIndex > -1) {
      long address=pages.getQuick(lastIndex);
      if (address != 0) {
        release(lastIndex,address);
        pages.setQuick(lastIndex,0);
      }
      clearHotPage();
    }
    this.lastPageIndex=0;
    this.lastPageSize=getMapPageSize();
  }
  this.size=size;
}

Fixed version (ground truth):
private void grow0(long size){
  long targetPageSize=computePageSize(size);
  if (targetPageSize != getMapPageSize()) {
    setPageSize(targetPageSize);
    ensurePagesListCapacity(size);
    this.lastPageSize=targetPageSize < size ? targetPageSize : size;
  }
 else {
    ensurePagesListCapacity(size);
    if (lastPageSize < getMapPageSize()) {
      int lastIndex=pages.size() - 1;
      if (lastIndex > -1) {
        long address=pages.getQuick(lastIndex);
        if (address != 0) {
          release(lastIndex,address);
          pages.setQuick(lastIndex,0);
        }
        clearHotPage();
      }
      this.lastPageIndex=0;
      this.lastPageSize=getMapPageSize();
    }
  }
  this.size=size;
}
Program: 30831
Project: 30831
Buggy source:
private void configurePageSize(long size,long maxPageSize){
  setPageSize(maxPageSize);
  pages.ensureCapacity((int)(size / getMapPageSize() + 1));
  this.size=size;
}

Fixed version (ground truth):
private void configurePageSize(long size,long maxPageSize){
  setPageSize(maxPageSize);
  ensurePagesListCapacity(size);
  this.size=size;
}
Program: 30832
Project: 30832
Buggy source:
@Test @Ignore public void testConcurrentWriterAndReadHeight() throws Exception {
  testConcurrentRW(10000000,5000000);
}

Fixed version (ground truth):
@Test public void testConcurrentWriterAndReadHeight() throws Exception {
  testConcurrentRW(1000000,1000000);
}
Program: 30833
Project: 30833
Buggy source:
private boolean readTxn(){
  while (true) {
    long txn=txMem.getLong(TableUtils.TX_OFFSET_TXN);
    if (txn == this.txn) {
      return false;
    }
    Unsafe.getUnsafe().loadFence();
    long transientRowCount=txMem.getLong(TableUtils.TX_OFFSET_TRANSIENT_ROW_COUNT);
    long fixedRowCount=txMem.getLong(TableUtils.TX_OFFSET_FIXED_ROW_COUNT);
    long maxTimestamp=txMem.getLong(TableUtils.TX_OFFSET_MAX_TIMESTAMP);
    long structVersion=txMem.getLong(TableUtils.TX_OFFSET_STRUCT_VERSION);
    Unsafe.getUnsafe().loadFence();
    if (txn == txMem.getLong(TableUtils.TX_OFFSET_TXN)) {
      this.txn=txn;
      this.transientRowCount=transientRowCount;
      this.rowCount=fixedRowCount + transientRowCount;
      this.maxTimestamp=maxTimestamp;
      this.structVersion=structVersion;
      break;
    }
    LockSupport.parkNanos(1);
  }
  return true;
}

Fixed version (ground truth):
private boolean readTxn(){
  while (true) {
    long txn=txMem.getLong(TableUtils.TX_OFFSET_TXN);
    if (txn == this.txn) {
      return false;
    }
    Unsafe.getUnsafe().loadFence();
    long transientRowCount=txMem.getLong(TableUtils.TX_OFFSET_TRANSIENT_ROW_COUNT);
    long fixedRowCount=txMem.getLong(TableUtils.TX_OFFSET_FIXED_ROW_COUNT);
    long maxTimestamp=txMem.getLong(TableUtils.TX_OFFSET_MAX_TIMESTAMP);
    long structVersion=txMem.getLong(TableUtils.TX_OFFSET_STRUCT_VERSION);
    Unsafe.getUnsafe().loadFence();
    if (txn == txMem.getLong(TableUtils.TX_OFFSET_TXN_CHECK)) {
      this.txn=txn;
      this.transientRowCount=transientRowCount;
      this.rowCount=fixedRowCount + transientRowCount;
      this.maxTimestamp=maxTimestamp;
      this.structVersion=structVersion;
      break;
    }
    LockSupport.parkNanos(1);
  }
  return true;
}
Program: 30835
Project: 30835
Buggy source:
/** 
 * Updates boundaries of all columns in partition.
 * @param partitionIndex index of partition
 * @param rowCount       number of rows in partition
 */
private void reloadPartition(int partitionIndex,long rowCount){
  if (partitionRowCounts.getQuick(partitionIndex) > -1) {
    int columnBase=getColumnBase(partitionIndex);
    for (int i=0; i < columnCount; i++) {
      columns.getQuick(getPrimaryColumnIndex(columnBase,i)).trackFileSize();
      ReadOnlyColumn mem2=columns.getQuick(getSecondaryColumnIndex(columnBase,i));
      if (mem2 != null) {
        mem2.trackFileSize();
      }
    }
    partitionRowCounts.setQuick(partitionIndex,rowCount);
  }
}

Fixed version (ground truth):
/** 
 * Updates boundaries of all columns in partition.
 * @param partitionIndex index of partition
 * @param rowCount       number of rows in partition
 */
private void reloadPartition(int partitionIndex,long rowCount){
}
Program: 30836
Project: 30836
Buggy source:
public static void resetTxn(VirtualMemory txMem){
  txMem.putLong(-1);
  txMem.putLong(0);
  txMem.putLong(0);
  txMem.putLong(Long.MIN_VALUE);
  txMem.putLong(0);
  Unsafe.getUnsafe().storeFence();
  txMem.jumpTo(0);
  txMem.putLong(0);
  Unsafe.getUnsafe().storeFence();
  txMem.jumpTo(TX_EOF);
}

Fixed version (ground truth):
public static void resetTxn(VirtualMemory txMem){
  txMem.jumpTo(TX_OFFSET_TXN);
  txMem.putLong(0);
  Unsafe.getUnsafe().storeFence();
  txMem.putLong(0);
  txMem.putLong(0);
  txMem.putLong(Long.MIN_VALUE);
  txMem.putLong(0);
  Unsafe.getUnsafe().storeFence();
  txMem.putLong(0);
}
Program: 30837
Project: 30837
Buggy source:
/** 
 * Commits newly added rows of data. This method updates transaction file with pointers to end of appended data. <p> <b>Pending rows</b> <p>This method will cancel pending rows by calling   {@link #cancelRow()}. Data in partially appended row will be lost.</p>
 */
public void commit(){
  if ((masterRef & 1) != 0) {
    cancelRow();
  }
  if (inTransaction()) {
    txMem.jumpTo(TableUtils.TX_OFFSET_TRANSIENT_ROW_COUNT);
    txMem.putLong(transientRowCount);
    if (txPartitionCount > 1) {
      commitPendingPartitions();
      txMem.putLong(fixedRowCount);
      columnSizeMem.jumpTo(0);
      txPartitionCount=1;
    }
 else {
      txMem.skip(8);
    }
    txMem.putLong(maxTimestamp);
    fencedTxnBump();
    prevTransientRowCount=transientRowCount;
  }
}

Fixed version (ground truth):
/** 
 * Commits newly added rows of data. This method updates transaction file with pointers to end of appended data. <p> <b>Pending rows</b> <p>This method will cancel pending rows by calling   {@link #cancelRow()}. Data in partially appended row will be lost.</p>
 */
public void commit(){
  if ((masterRef & 1) != 0) {
    cancelRow();
  }
  if (inTransaction()) {
    txMem.jumpTo(TableUtils.TX_OFFSET_TXN);
    txMem.putLong(++txn);
    Unsafe.getUnsafe().storeFence();
    txMem.jumpTo(TableUtils.TX_OFFSET_TRANSIENT_ROW_COUNT);
    txMem.putLong(transientRowCount);
    if (txPartitionCount > 1) {
      commitPendingPartitions();
      txMem.putLong(fixedRowCount);
      columnSizeMem.jumpTo(0);
      txPartitionCount=1;
    }
 else {
      txMem.skip(8);
    }
    txMem.putLong(maxTimestamp);
    Unsafe.getUnsafe().storeFence();
    txMem.jumpTo(TableUtils.TX_OFFSET_TXN_CHECK);
    txMem.putLong(txn);
    prevTransientRowCount=transientRowCount;
  }
}
Program: 30839
Project: 30839
Buggy source:
/** 
 * Truncates table. When operation is unsuccessful it throws CairoException. With that truncate can be retried or alternatively table can be closed. Outcome of any other operation with the table is undefined and likely to cause segmentation fault. When table re-opens any partial truncate will be retried.
 */
public final void truncate(){
  if (size() == 0) {
    return;
  }
  writeTodo(TableUtils.TODO_TRUNCATE);
  for (int i=0; i < columnCount; i++) {
    getPrimaryColumn(i).truncate();
    AppendMemory mem=getSecondaryColumn(i);
    if (mem != null) {
      mem.truncate();
    }
  }
  if (partitionBy != PartitionBy.NONE) {
    closeColumns(false);
    removePartitionDirectories();
    rowFunction=openPartitionFunction;
  }
  prevTimestamp=Long.MIN_VALUE;
  maxTimestamp=Long.MIN_VALUE;
  partitionLo=Long.MIN_VALUE;
  prevTransientRowCount=0;
  transientRowCount=0;
  fixedRowCount=0;
  txn=0;
  txPartitionCount=1;
  txMem.jumpTo(TableUtils.TX_OFFSET_TXN);
  TableUtils.resetTxn(txMem);
  try {
    removeTodoFile();
  }
 catch (  CairoException err) {
    throw new CairoError(err);
  }
}

Fixed version (ground truth):
/** 
 * Truncates table. When operation is unsuccessful it throws CairoException. With that truncate can be retried or alternatively table can be closed. Outcome of any other operation with the table is undefined and likely to cause segmentation fault. When table re-opens any partial truncate will be retried.
 */
public final void truncate(){
  if (size() == 0) {
    return;
  }
  writeTodo(TableUtils.TODO_TRUNCATE);
  for (int i=0; i < columnCount; i++) {
    getPrimaryColumn(i).truncate();
    AppendMemory mem=getSecondaryColumn(i);
    if (mem != null) {
      mem.truncate();
    }
  }
  if (partitionBy != PartitionBy.NONE) {
    closeColumns(false);
    removePartitionDirectories();
    rowFunction=openPartitionFunction;
  }
  prevTimestamp=Long.MIN_VALUE;
  maxTimestamp=Long.MIN_VALUE;
  partitionLo=Long.MIN_VALUE;
  prevTransientRowCount=0;
  transientRowCount=0;
  fixedRowCount=0;
  txn=0;
  txPartitionCount=1;
  TableUtils.resetTxn(txMem);
  try {
    removeTodoFile();
  }
 catch (  CairoException err) {
    throw new CairoError(err);
  }
}
Program: 30840
Project: 30840
Buggy source:
private void repairTruncate(){
  LOG.info().$("String_Node_Str").$(path).$();
  if (partitionBy != PartitionBy.NONE) {
    removePartitionDirectories();
  }
  txMem.jumpTo(TableUtils.TX_OFFSET_TXN);
  TableUtils.resetTxn(txMem);
  removeTodoFile();
}

Fixed version (ground truth):
private void repairTruncate(){
  LOG.info().$("String_Node_Str").$(path).$();
  if (partitionBy != PartitionBy.NONE) {
    removePartitionDirectories();
  }
  TableUtils.resetTxn(txMem);
  removeTodoFile();
}