nus-yam/ex-repair huggingface dataset:
Program: 61129
Project: 61129
Buggy source:
/** 
 * Builds a scan object with the same specs as get.
 * @param get get to model scan after
 */
public Scan(Get get){
  this.startRow=get.getRow();
  this.stopRow=get.getRow();
  this.filter=get.getFilter();
  this.cacheBlocks=get.getCacheBlocks();
  this.maxVersions=get.getMaxVersions();
  this.storeLimit=get.getMaxResultsPerColumnFamily();
  this.storeOffset=get.getRowOffsetPerColumnFamily();
  this.tr=get.getTimeRange();
  this.familyMap=get.getFamilyMap();
  this.getScan=true;
  this.asyncPrefetch=false;
  this.consistency=get.getConsistency();
  for (  Map.Entry<String,byte[]> attr : get.getAttributesMap().entrySet()) {
    setAttribute(attr.getKey(),attr.getValue());
  }
  for (  Map.Entry<byte[],TimeRange> entry : get.getColumnFamilyTimeRange().entrySet()) {
    TimeRange tr=entry.getValue();
    setColumnFamilyTimeRange(entry.getKey(),tr.getMin(),tr.getMax());
  }
}

Fixed version (ground truth):
/** 
 * Builds a scan object with the same specs as get.
 * @param get get to model scan after
 */
public Scan(Get get){
  this.startRow=get.getRow();
  this.stopRow=get.getRow();
  this.filter=get.getFilter();
  this.cacheBlocks=get.getCacheBlocks();
  this.maxVersions=get.getMaxVersions();
  this.storeLimit=get.getMaxResultsPerColumnFamily();
  this.storeOffset=get.getRowOffsetPerColumnFamily();
  this.tr=get.getTimeRange();
  this.familyMap=get.getFamilyMap();
  this.getScan=true;
  this.asyncPrefetch=false;
  this.consistency=get.getConsistency();
  this.setIsolationLevel(get.getIsolationLevel());
  for (  Map.Entry<String,byte[]> attr : get.getAttributesMap().entrySet()) {
    setAttribute(attr.getKey(),attr.getValue());
  }
  for (  Map.Entry<byte[],TimeRange> entry : get.getColumnFamilyTimeRange().entrySet()) {
    TimeRange tr=entry.getValue();
    setColumnFamilyTimeRange(entry.getKey(),tr.getMin(),tr.getMax());
  }
}
Program: 61130
Project: 61130
Buggy source:
/** 
 * Util method to iterate through the tags in the given cell.
 * @param cell The Cell over which tags iterator is needed.
 * @return iterator for the tags
 */
public static Iterator<Tag> tagsIterator(final Cell cell){
  final int tagsLength=cell.getTagsLength();
  if (tagsLength == 0) {
    return EMPTY_TAGS_ITR;
  }
  if (cell instanceof ByteBufferedCell) {
    return tagsIterator(((ByteBufferedCell)cell).getTagsByteBuffer(),((ByteBufferedCell)cell).getTagsPosition(),tagsLength);
  }
  return tagsIterator(cell.getTagsArray(),cell.getTagsOffset(),tagsLength);
}

Fixed version (ground truth):
/** 
 * Util method to iterate through the tags in the given cell.
 * @param cell The Cell over which tags iterator is needed.
 * @return iterator for the tags
 */
public static Iterator<Tag> tagsIterator(final Cell cell){
  final int tagsLength=cell.getTagsLength();
  if (tagsLength == 0) {
    return TagUtil.EMPTY_TAGS_ITR;
  }
  if (cell instanceof ByteBufferedCell) {
    return tagsIterator(((ByteBufferedCell)cell).getTagsByteBuffer(),((ByteBufferedCell)cell).getTagsPosition(),tagsLength);
  }
  return tagsIterator(cell.getTagsArray(),cell.getTagsOffset(),tagsLength);
}
Program: 61131
Project: 61131
Buggy source:
/** 
 * Write a list of tags into a byte array
 * @param tags The list of tags
 * @return the serialized tag data as bytes
 */
public static byte[] fromList(List<Tag> tags){
  if (tags.isEmpty()) {
    return HConstants.EMPTY_BYTE_ARRAY;
  }
  int length=0;
  for (  Tag tag : tags) {
    length+=tag.getValueLength() + Tag.INFRASTRUCTURE_SIZE;
  }
  byte[] b=new byte[length];
  int pos=0;
  int tlen;
  for (  Tag tag : tags) {
    tlen=tag.getValueLength();
    pos=Bytes.putAsShort(b,pos,tlen + Tag.TYPE_LENGTH_SIZE);
    pos=Bytes.putByte(b,pos,tag.getType());
    if (tag.hasArray()) {
      pos=Bytes.putBytes(b,pos,tag.getValueArray(),tag.getValueOffset(),tlen);
    }
 else {
      ByteBufferUtils.copyFromBufferToArray(b,tag.getValueByteBuffer(),tag.getValueOffset(),pos,tlen);
      pos+=tlen;
    }
  }
  return b;
}

Fixed version (ground truth):
/** 
 * Write a list of tags into a byte array
 * @param tags The list of tags
 * @return the serialized tag data as bytes
 */
public static byte[] fromList(List<Tag> tags){
  if (tags == null || tags.isEmpty()) {
    return HConstants.EMPTY_BYTE_ARRAY;
  }
  int length=0;
  for (  Tag tag : tags) {
    length+=tag.getValueLength() + Tag.INFRASTRUCTURE_SIZE;
  }
  byte[] b=new byte[length];
  int pos=0;
  int tlen;
  for (  Tag tag : tags) {
    tlen=tag.getValueLength();
    pos=Bytes.putAsShort(b,pos,tlen + Tag.TYPE_LENGTH_SIZE);
    pos=Bytes.putByte(b,pos,tag.getType());
    if (tag.hasArray()) {
      pos=Bytes.putBytes(b,pos,tag.getValueArray(),tag.getValueOffset(),tlen);
    }
 else {
      ByteBufferUtils.copyFromBufferToArray(b,tag.getValueByteBuffer(),tag.getValueOffset(),pos,tlen);
      pos+=tlen;
    }
  }
  return b;
}
Program: 61132
Project: 61132
Buggy source:
@Override public KeyValueScanner preStoreScannerOpen(final ObserverContext<RegionCoprocessorEnvironment> c,final Store store,final Scan scan,final NavigableSet<byte[]> targetCols,final KeyValueScanner s) throws IOException {
  ScanInfo scanInfo=getScanInfo(store,c.getEnvironment());
  if (scanInfo == null) {
    return null;
  }
  return new StoreScanner(store,scanInfo,scan,targetCols,((HStore)store).getHRegion().getReadpoint(IsolationLevel.READ_COMMITTED));
}

Fixed version (ground truth):
@Override public KeyValueScanner preStoreScannerOpen(final ObserverContext<RegionCoprocessorEnvironment> c,final Store store,final Scan scan,final NavigableSet<byte[]> targetCols,final KeyValueScanner s) throws IOException {
  ScanInfo scanInfo=getScanInfo(store,c.getEnvironment());
  if (scanInfo == null) {
    return null;
  }
  return new StoreScanner(store,scanInfo,scan,targetCols,((HStore)store).getHRegion().getReadPoint(IsolationLevel.READ_COMMITTED));
}
Program: 61133
Project: 61133
Buggy source:
@Override public int reseekTo(Cell key) throws IOException {
  int compared;
  if (isSeeked()) {
    compared=compareKey(reader.getComparator(),key);
    if (compared < 1) {
      return compared;
    }
 else {
      if (this.nextIndexedKey != null && (this.nextIndexedKey == HConstants.NO_NEXT_INDEXED_KEY || reader.getComparator().compareKeyIgnoresMvcc(key,nextIndexedKey) < 0)) {
        return loadBlockAndSeekToKey(this.curBlock,nextIndexedKey,false,key,false);
      }
    }
  }
  return seekTo(key,false);
}

Fixed version (ground truth):
@Override public int reseekTo(Cell key) throws IOException {
  int compared;
  if (isSeeked()) {
    compared=compareKey(reader.getComparator(),key);
    if (compared < 1) {
      return compared;
    }
 else {
      if (this.nextIndexedKey != null && (this.nextIndexedKey == KeyValueScanner.NO_NEXT_INDEXED_KEY || reader.getComparator().compareKeyIgnoresMvcc(key,nextIndexedKey) < 0)) {
        return loadBlockAndSeekToKey(this.curBlock,nextIndexedKey,false,key,false);
      }
    }
  }
  return seekTo(key,false);
}
Program: 61134
Project: 61134
Buggy source:
protected synchronized void close(){
  disposeSasl();
  data=null;
  if (!channel.isOpen())   return;
  try {
    socket.shutdownOutput();
  }
 catch (  Exception ignored) {
  }
  if (channel.isOpen()) {
    try {
      channel.close();
    }
 catch (    Exception ignored) {
    }
  }
  try {
    socket.close();
  }
 catch (  Exception ignored) {
  }
}

Fixed version (ground truth):
protected synchronized void close(){
  disposeSasl();
  data=null;
  if (!channel.isOpen())   return;
  try {
    socket.shutdownOutput();
  }
 catch (  Exception ignored) {
    if (LOG.isTraceEnabled()) {
      LOG.trace("String_Node_Str",ignored);
    }
  }
  if (channel.isOpen()) {
    try {
      channel.close();
    }
 catch (    Exception ignored) {
    }
  }
  try {
    socket.close();
  }
 catch (  Exception ignored) {
    if (LOG.isTraceEnabled()) {
      LOG.trace("String_Node_Str",ignored);
    }
  }
}
Program: 61136
Project: 61136
Buggy source:
/** 
 * Processes list of regions in transition at startup
 */
void processRegionsInTransition(Collection<RegionState> regionsInTransition){
  for (  RegionState regionState : regionsInTransition) {
    LOG.info("String_Node_Str" + regionState);
    ServerName serverName=regionState.getServerName();
    if (serverName != null && !serverManager.getOnlineServers().containsKey(serverName)) {
      LOG.info("String_Node_Str" + serverName + "String_Node_Str");
      continue;
    }
    HRegionInfo regionInfo=regionState.getRegion();
    RegionState.State state=regionState.getState();
switch (state) {
case CLOSED:
      invokeAssign(regionState.getRegion());
    break;
case PENDING_OPEN:
  retrySendRegionOpen(regionState);
break;
case PENDING_CLOSE:
retrySendRegionClose(regionState);
break;
case FAILED_CLOSE:
case FAILED_OPEN:
invokeUnAssign(regionInfo);
break;
default :
}
}
}

Fixed version (ground truth):
/** 
 * Processes list of regions in transition at startup
 */
void processRegionsInTransition(Collection<RegionState> regionsInTransition){
  for (  RegionState regionState : regionsInTransition) {
    LOG.info("String_Node_Str" + regionState);
    ServerName serverName=regionState.getServerName();
    if (serverName != null && !serverManager.getOnlineServers().containsKey(serverName)) {
      LOG.info("String_Node_Str" + serverName + "String_Node_Str");
      continue;
    }
    HRegionInfo regionInfo=regionState.getRegion();
    RegionState.State state=regionState.getState();
switch (state) {
case CLOSED:
      invokeAssign(regionState.getRegion());
    break;
case PENDING_OPEN:
  retrySendRegionOpen(regionState);
break;
case PENDING_CLOSE:
retrySendRegionClose(regionState);
break;
case FAILED_CLOSE:
case FAILED_OPEN:
invokeUnAssign(regionInfo);
break;
default :
break;
}
}
}
Program: 61137
Project: 61137
Buggy source:
public void run(){
  zkLeader.start();
  zkLeader.waitToBecomeLeader();
  isMaster=true;
  while (!stopped) {
    long now=EnvironmentEdgeManager.currentTime();
    removeExpiredKeys();
    long localLastKeyUpdate;
synchronized (this) {
      localLastKeyUpdate=lastKeyUpdate;
    }
    if (localLastKeyUpdate + keyUpdateInterval < now) {
      rollCurrentKey();
    }
    try {
      Thread.sleep(5000);
    }
 catch (    InterruptedException ie) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("String_Node_Str",ie);
      }
    }
  }
}

Fixed version (ground truth):
public void run(){
  zkLeader.start();
  zkLeader.waitToBecomeLeader();
  isMaster=true;
  while (!stopped) {
    long now=EnvironmentEdgeManager.currentTime();
    removeExpiredKeys();
    long localLastKeyUpdate=getLastKeyUpdate();
    if (localLastKeyUpdate + keyUpdateInterval < now) {
      rollCurrentKey();
    }
    try {
      Thread.sleep(5000);
    }
 catch (    InterruptedException ie) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("String_Node_Str",ie);
      }
    }
  }
}
Program: 61139
Project: 61139
Buggy source:
public void stopConnectorServer() throws IOException {
synchronized (JMXListener.class) {
    if (jmxCS != null) {
      jmxCS.stop();
      LOG.info("String_Node_Str");
      jmxCS=null;
    }
  }
}

Fixed version (ground truth):
public void stopConnectorServer() throws IOException {
synchronized (JMXListener.class) {
    if (JMX_CS != null) {
      JMX_CS.stop();
      LOG.info("String_Node_Str");
      JMX_CS=null;
    }
  }
}
Program: 61140
Project: 61140
Buggy source:
@Override public void start(CoprocessorEnvironment env) throws IOException {
  int rmiRegistryPort=-1;
  int rmiConnectorPort=-1;
  Configuration conf=env.getConfiguration();
  if (env instanceof MasterCoprocessorEnvironment) {
    rmiRegistryPort=conf.getInt("String_Node_Str" + RMI_REGISTRY_PORT_CONF_KEY,defMasterRMIRegistryPort);
    rmiConnectorPort=conf.getInt("String_Node_Str" + RMI_CONNECTOR_PORT_CONF_KEY,rmiRegistryPort);
    LOG.info("String_Node_Str" + rmiRegistryPort + "String_Node_Str"+ rmiConnectorPort);
  }
 else   if (env instanceof RegionServerCoprocessorEnvironment) {
    rmiRegistryPort=conf.getInt("String_Node_Str" + RMI_REGISTRY_PORT_CONF_KEY,defRegionserverRMIRegistryPort);
    rmiConnectorPort=conf.getInt("String_Node_Str" + RMI_CONNECTOR_PORT_CONF_KEY,rmiRegistryPort);
    LOG.info("String_Node_Str" + rmiRegistryPort + "String_Node_Str"+ rmiConnectorPort);
  }
 else   if (env instanceof RegionCoprocessorEnvironment) {
    LOG.error("String_Node_Str");
    return;
  }
synchronized (JMXListener.class) {
    if (jmxCS != null) {
      LOG.info("String_Node_Str" + rmiRegistryPort);
    }
 else {
      startConnectorServer(rmiRegistryPort,rmiConnectorPort);
    }
  }
}

Fixed version (ground truth):
@Override public void start(CoprocessorEnvironment env) throws IOException {
  int rmiRegistryPort=-1;
  int rmiConnectorPort=-1;
  Configuration conf=env.getConfiguration();
  if (env instanceof MasterCoprocessorEnvironment) {
    rmiRegistryPort=conf.getInt("String_Node_Str" + RMI_REGISTRY_PORT_CONF_KEY,defMasterRMIRegistryPort);
    rmiConnectorPort=conf.getInt("String_Node_Str" + RMI_CONNECTOR_PORT_CONF_KEY,rmiRegistryPort);
    LOG.info("String_Node_Str" + rmiRegistryPort + "String_Node_Str"+ rmiConnectorPort);
  }
 else   if (env instanceof RegionServerCoprocessorEnvironment) {
    rmiRegistryPort=conf.getInt("String_Node_Str" + RMI_REGISTRY_PORT_CONF_KEY,defRegionserverRMIRegistryPort);
    rmiConnectorPort=conf.getInt("String_Node_Str" + RMI_CONNECTOR_PORT_CONF_KEY,rmiRegistryPort);
    LOG.info("String_Node_Str" + rmiRegistryPort + "String_Node_Str"+ rmiConnectorPort);
  }
 else   if (env instanceof RegionCoprocessorEnvironment) {
    LOG.error("String_Node_Str");
    return;
  }
synchronized (JMXListener.class) {
    if (JMX_CS != null) {
      LOG.info("String_Node_Str" + rmiRegistryPort);
    }
 else {
      startConnectorServer(rmiRegistryPort,rmiConnectorPort);
    }
  }
}
Program: 61141
Project: 61141
Buggy source:
/** 
 * It is possible for a task to stay in UNASSIGNED state indefinitely - say SplitLogManager wants to resubmit a task. It forces the task to UNASSIGNED state but it dies before it could create the RESCAN task node to signal the SplitLogWorkers to pick up the task. To prevent this scenario the SplitLogManager resubmits all orphan and UNASSIGNED tasks at startup.
 * @param path
 */
private void handleUnassignedTask(String path){
  if (ZKSplitLog.isRescanNode(watcher,path)) {
    return;
  }
  Task task=findOrCreateOrphanTask(path);
  if (task.isOrphan() && (task.incarnation == 0)) {
    LOG.info("String_Node_Str" + path);
    resubmitTask(path,task,FORCE);
  }
}

Fixed version (ground truth):
/** 
 * It is possible for a task to stay in UNASSIGNED state indefinitely - say SplitLogManager wants to resubmit a task. It forces the task to UNASSIGNED state but it dies before it could create the RESCAN task node to signal the SplitLogWorkers to pick up the task. To prevent this scenario the SplitLogManager resubmits all orphan and UNASSIGNED tasks at startup.
 * @param path
 */
private void handleUnassignedTask(String path){
  if (ZKSplitLog.isRescanNode(watcher,path)) {
    return;
  }
  Task task=findOrCreateOrphanTask(path);
  if (task.isOrphan() && (task.incarnation.get() == 0)) {
    LOG.info("String_Node_Str" + path);
    resubmitTask(path,task,FORCE);
  }
}
Program: 61144
Project: 61144
Buggy source:
/** 
 * Override handler from   {@link ZooKeeperListener}
 */
@Override public void nodeChildrenChanged(String path){
  if (path.equals(watcher.splitLogZNode)) {
    if (LOG.isTraceEnabled())     LOG.trace("String_Node_Str" + path);
synchronized (taskReadyLock) {
      taskReadySeq++;
      taskReadyLock.notify();
    }
  }
}

Fixed version (ground truth):
/** 
 * Override handler from   {@link ZooKeeperListener}
 */
@Override public void nodeChildrenChanged(String path){
  if (path.equals(watcher.splitLogZNode)) {
    if (LOG.isTraceEnabled())     LOG.trace("String_Node_Str" + path);
synchronized (taskReadyLock) {
      this.taskReadySeq.incrementAndGet();
      taskReadyLock.notify();
    }
  }
}
Program: 61145
Project: 61145
Buggy source:
@Override public int getTaskReadySeq(){
  return taskReadySeq;
}

Fixed version (ground truth):
@Override public int getTaskReadySeq(){
  return taskReadySeq.get();
}
Program: 61147
Project: 61147
Buggy source:
/** 
 * Method returns the reader given the specified arguments. TODO This is a bad abstraction.  See HBASE-6635.
 * @param path hfile's path
 * @param fsdis stream of path's file
 * @param size max size of the trailer.
 * @param cacheConf Cache configuation values, cannot be null.
 * @param hfs
 * @return an appropriate instance of HFileReader
 * @throws IOException If file is invalid, will throw CorruptHFileException flavored IOException
 */
private static Reader pickReaderVersion(Path path,FSDataInputStreamWrapper fsdis,long size,CacheConfig cacheConf,HFileSystem hfs,Configuration conf) throws IOException {
}

Fixed version (ground truth):
/** 
 * Method returns the reader given the specified arguments. TODO This is a bad abstraction.  See HBASE-6635.
 * @param path hfile's path
 * @param fsdis stream of path's file
 * @param size max size of the trailer.
 * @param cacheConf Cache configuation values, cannot be null.
 * @param hfs
 * @return an appropriate instance of HFileReader
 * @throws IOException If file is invalid, will throw CorruptHFileException flavored IOException
 */
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value="String_Node_Str",justification="String_Node_Str") private static Reader pickReaderVersion(Path path,FSDataInputStreamWrapper fsdis,long size,CacheConfig cacheConf,HFileSystem hfs,Configuration conf) throws IOException {
}
Program: 61148
Project: 61148
Buggy source:
/** 
 * Internal method to create the copy on write matrix. Once created, all further operations are performed on the CoW matrix
 */
private void cow(){
  if (cow != null) {
    return;
  }
  if (chks[0].isSparse()) {
    cow=new SparseMatrix(chks[0].len(),chks.length);
  }
 else {
    cow=new DenseMatrix(chks[0].len(),chks.length);
  }
  for (int c=0; c < chks.length; c++) {
    for (int r=0; r < chks[0].len(); r++) {
      cow.setQuick(r,c,chks[c].at0(r));
    }
  }
}

Fixed version (ground truth):
/** 
 * Internal method to create the copy on write matrix. Once created, all further operations are performed on the CoW matrix
 */
private void cow(){
  if (cow != null) {
    return;
  }
  if (chks[0].isSparse()) {
    cow=new SparseMatrix(chks[0].len(),chks.length);
  }
 else {
    cow=new DenseMatrix(chks[0].len(),chks.length);
  }
  for (int c=0; c < chks.length; c++) {
    for (int r=0; r < chks[0].len(); r++) {
      cow.setQuick(r,c,chks[c].atd(r));
    }
  }
}
Program: 61149
Project: 61149
Buggy source:
@Override public double getQuick(int row,int col){
  if (cow != null) {
    return cow.getQuick(row,col);
  }
 else {
    return chks[col].at0(row);
  }
}

Fixed version (ground truth):
@Override public double getQuick(int row,int col){
  if (cow != null) {
    return cow.getQuick(row,col);
  }
 else {
    return chks[col].atd(row);
  }
}
Program: 61150
Project: 61150
Buggy source:
/** 
 * Calculate Sums of elements in a column, and return as a Vector. Run an MRTask Job to add up sums. WARNING: Vulnerable to overflow. No way around it.
 * @param frame Frame backing the H2O DRM.
 * @return Vector of calculated sums.
 */
public static Vector colSums(Frame frame){
  /** 
 * MRTask to calculate sums of elements in all columns.
 */
class MRTaskSum extends MRTask<MRTaskSum> {
    public double sums[];
    @Override public void map(    Chunk chks[]){
      sums=new double[chks.length];
      for (int c=0; c < chks.length; c++) {
        for (int r=0; r < chks[c].len(); r++) {
          sums[c]+=chks[c].at0(r);
        }
      }
    }
    @Override public void reduce(    MRTaskSum other){
      ArrayUtils.add(sums,other.sums);
    }
  }
  return new DenseVector(new MRTaskSum().doAll(frame).sums);
}

Fixed version (ground truth):
/** 
 * Calculate Sums of elements in a column, and return as a Vector. Run an MRTask Job to add up sums. WARNING: Vulnerable to overflow. No way around it.
 * @param frame Frame backing the H2O DRM.
 * @return Vector of calculated sums.
 */
public static Vector colSums(Frame frame){
  /** 
 * MRTask to calculate sums of elements in all columns.
 */
class MRTaskSum extends MRTask<MRTaskSum> {
    public double sums[];
    @Override public void map(    Chunk chks[]){
      sums=new double[chks.length];
      for (int c=0; c < chks.length; c++) {
        for (int r=0; r < chks[c].len(); r++) {
          sums[c]+=chks[c].atd(r);
        }
      }
    }
    @Override public void reduce(    MRTaskSum other){
      ArrayUtils.add(sums,other.sums);
    }
  }
  return new DenseVector(new MRTaskSum().doAll(frame).sums);
}
Program: 61151
Project: 61151
Buggy source:
/** 
 * Calculate Sum of squares of all elements in the DRM. Run an MRTask Job to add up sums of squares. WARNING: Vulnerable to overflow. No way around it.
 * @param frame Frame backing the H2O DRM.
 * @return Sum of squares of all elements in the DRM.
 */
public static double sumSqr(Frame frame){
  /** 
 * MRTask to calculate sums of squares of all elements.
 */
class MRTaskSumSqr extends MRTask<MRTaskSumSqr> {
    public double sumSqr;
    @Override public void map(    Chunk chks[]){
      for (int c=0; c < chks.length; c++) {
        for (int r=0; r < chks[c].len(); r++) {
          sumSqr+=(chks[c].at0(r) * chks[c].at0(r));
        }
      }
    }
    @Override public void reduce(    MRTaskSumSqr other){
      sumSqr+=other.sumSqr;
    }
  }
  return new MRTaskSumSqr().doAll(frame).sumSqr;
}

Fixed version (ground truth):
/** 
 * Calculate Sum of squares of all elements in the DRM. Run an MRTask Job to add up sums of squares. WARNING: Vulnerable to overflow. No way around it.
 * @param frame Frame backing the H2O DRM.
 * @return Sum of squares of all elements in the DRM.
 */
public static double sumSqr(Frame frame){
  /** 
 * MRTask to calculate sums of squares of all elements.
 */
class MRTaskSumSqr extends MRTask<MRTaskSumSqr> {
    public double sumSqr;
    @Override public void map(    Chunk chks[]){
      for (int c=0; c < chks.length; c++) {
        for (int r=0; r < chks[c].len(); r++) {
          sumSqr+=(chks[c].atd(r) * chks[c].atd(r));
        }
      }
    }
    @Override public void reduce(    MRTaskSumSqr other){
      sumSqr+=other.sumSqr;
    }
  }
  return new MRTaskSumSqr().doAll(frame).sumSqr;
}
Program: 61152
Project: 61152
Buggy source:
/** 
 * Count non-zero elements in all columns, and return as a Vector. Run an MRTask Job to count non-zero elements per column.
 * @param frame Frame backing the H2O DRM.
 * @return Vector of counted non-zero elements.
 */
public static Vector nonZeroCnt(Frame frame){
  /** 
 * MRTask to count all non-zero elements.
 */
class MRTaskNonZero extends MRTask<MRTaskNonZero> {
    public double sums[];
    @Override public void map(    Chunk chks[]){
      sums=new double[chks.length];
      for (int c=0; c < chks.length; c++) {
        for (int r=0; r < chks[c].len(); r++) {
          if ((long)chks[c].at0(r) != 0) {
            sums[c]++;
          }
        }
      }
    }
    @Override public void reduce(    MRTaskNonZero other){
      ArrayUtils.add(sums,other.sums);
    }
  }
  return new DenseVector(new MRTaskNonZero().doAll(frame).sums);
}

Fixed version (ground truth):
/** 
 * Count non-zero elements in all columns, and return as a Vector. Run an MRTask Job to count non-zero elements per column.
 * @param frame Frame backing the H2O DRM.
 * @return Vector of counted non-zero elements.
 */
public static Vector nonZeroCnt(Frame frame){
  /** 
 * MRTask to count all non-zero elements.
 */
class MRTaskNonZero extends MRTask<MRTaskNonZero> {
    public double sums[];
    @Override public void map(    Chunk chks[]){
      sums=new double[chks.length];
      for (int c=0; c < chks.length; c++) {
        for (int r=0; r < chks[c].len(); r++) {
          if ((long)chks[c].atd(r) != 0) {
            sums[c]++;
          }
        }
      }
    }
    @Override public void reduce(    MRTaskNonZero other){
      ArrayUtils.add(sums,other.sums);
    }
  }
  return new DenseVector(new MRTaskNonZero().doAll(frame).sums);
}
Program: 61153
Project: 61153
Buggy source:
@Override public void map(Chunk chks[]){
  sums=new double[chks.length];
  for (int c=0; c < chks.length; c++) {
    for (int r=0; r < chks[c].len(); r++) {
      if ((long)chks[c].at0(r) != 0) {
        sums[c]++;
      }
    }
  }
}

Fixed version (ground truth):
@Override public void map(Chunk chks[]){
  sums=new double[chks.length];
  for (int c=0; c < chks.length; c++) {
    for (int r=0; r < chks[c].len(); r++) {
      if ((long)chks[c].atd(r) != 0) {
        sums[c]++;
      }
    }
  }
}
Program: 61154
Project: 61154
Buggy source:
public void map(Chunk chks[],NewChunk ncs[]){
  int chunkSize=chks[0].len();
  Vec B_vecs[]=B.vecs();
  for (int c=0; c < ncs.length; c++) {
    for (int r=0; r < chunkSize; r++) {
      double v=0;
      for (int i=0; i < chks.length; i++) {
        v+=(chks[i].at0(r) * B_vecs[i].at(c));
      }
      ncs[c].addNum(v);
    }
  }
}

Fixed version (ground truth):
public void map(Chunk chks[],NewChunk ncs[]){
  int chunkSize=chks[0].len();
  Vec B_vecs[]=B.vecs();
  for (int c=0; c < ncs.length; c++) {
    for (int r=0; r < chunkSize; r++) {
      double v=0;
      for (int i=0; i < chks.length; i++) {
        v+=(chks[i].atd(r) * B_vecs[i].at(c));
      }
      ncs[c].addNum(v);
    }
  }
}
Program: 61155
Project: 61155
Buggy source:
/** 
 * Calculate AB' on two DRMs to create a new DRM holding the result.
 * @param drmA DRM representing matrix A
 * @param drmB DRM representing matrix B
 * @return new DRM containing AB'
 */
public static H2ODrm exec(H2ODrm drmA,H2ODrm drmB){
  Frame A=drmA.frame;
  Vec keys=drmA.keys;
  final Frame B=drmB.frame;
  int ABt_cols=(int)B.numRows();
  Frame ABt=new MRTask(){
    public void map(    Chunk chks[],    NewChunk ncs[]){
      int chunkSize=chks[0].len();
      Vec B_vecs[]=B.vecs();
      for (int c=0; c < ncs.length; c++) {
        for (int r=0; r < chunkSize; r++) {
          double v=0;
          for (int i=0; i < chks.length; i++) {
            v+=(chks[i].at0(r) * B_vecs[i].at(c));
          }
          ncs[c].addNum(v);
        }
      }
    }
  }
.doAll(ABt_cols,A).outputFrame(null,null);
  return new H2ODrm(ABt,keys);
}

Fixed version (ground truth):
/** 
 * Calculate AB' on two DRMs to create a new DRM holding the result.
 * @param drmA DRM representing matrix A
 * @param drmB DRM representing matrix B
 * @return new DRM containing AB'
 */
public static H2ODrm exec(H2ODrm drmA,H2ODrm drmB){
  Frame A=drmA.frame;
  Vec keys=drmA.keys;
  final Frame B=drmB.frame;
  int ABt_cols=(int)B.numRows();
  Frame ABt=new MRTask(){
    public void map(    Chunk chks[],    NewChunk ncs[]){
      int chunkSize=chks[0].len();
      Vec B_vecs[]=B.vecs();
      for (int c=0; c < ncs.length; c++) {
        for (int r=0; r < chunkSize; r++) {
          double v=0;
          for (int i=0; i < chks.length; i++) {
            v+=(chks[i].atd(r) * B_vecs[i].at(c));
          }
          ncs[c].addNum(v);
        }
      }
    }
  }
.doAll(ABt_cols,A).outputFrame(null,null);
  return new H2ODrm(ABt,keys);
}
Program: 61156
Project: 61156
Buggy source:
@Override public void map(Chunk chks[],NewChunk ncs[]){
  int chunkSize=chks[0].len();
  Vec B_vecs[]=B.vecs();
  long start=chks[0].start();
  for (int c=0; c < chks.length; c++) {
    for (int r=0; r < chunkSize; r++) {
      ncs[c].addNum(opfn(op,chks[c].at0(r),B_vecs[c].at(start + r)));
    }
  }
}

Fixed version (ground truth):
@Override public void map(Chunk chks[],NewChunk ncs[]){
  int chunkSize=chks[0].len();
  Vec B_vecs[]=B.vecs();
  long start=chks[0].start();
  for (int c=0; c < chks.length; c++) {
    for (int r=0; r < chunkSize; r++) {
      ncs[c].addNum(opfn(op,chks[c].atd(r),B_vecs[c].at(start + r)));
    }
  }
}
Program: 61157
Project: 61157
Buggy source:
/** 
 * Perform element-wise operation on two DRMs to create a new DRM.
 * @param drmA DRM representing matrix A.
 * @param drmB DRM representing matrix B.
 * @param op Element-wise operator encoded as a String.
 * @return new DRM containing A (element-wise) B.
 */
public static H2ODrm exec(H2ODrm drmA,H2ODrm drmB,final String op){
  final Frame A=drmA.frame;
  final Frame B=drmB.frame;
  Vec keys=drmA.keys;
  int AewB_cols=A.numCols();
  Frame AewB=new MRTask(){
    private double opfn(    String op,    double a,    double b){
      if (a == 0.0 && b == 0.0) {
        return 0.0;
      }
      if (op.equals("String_Node_Str")) {
        return a + b;
      }
 else       if (op.equals("String_Node_Str")) {
        return a - b;
      }
 else       if (op.equals("String_Node_Str")) {
        return a * b;
      }
 else       if (op.equals("String_Node_Str")) {
        return a / b;
      }
      return 0.0;
    }
    @Override public void map(    Chunk chks[],    NewChunk ncs[]){
      int chunkSize=chks[0].len();
      Vec B_vecs[]=B.vecs();
      long start=chks[0].start();
      for (int c=0; c < chks.length; c++) {
        for (int r=0; r < chunkSize; r++) {
          ncs[c].addNum(opfn(op,chks[c].at0(r),B_vecs[c].at(start + r)));
        }
      }
    }
  }
.doAll(AewB_cols,A).outputFrame(null,null);
  return new H2ODrm(AewB,keys);
}

Fixed version (ground truth):
/** 
 * Perform element-wise operation on two DRMs to create a new DRM.
 * @param drmA DRM representing matrix A.
 * @param drmB DRM representing matrix B.
 * @param op Element-wise operator encoded as a String.
 * @return new DRM containing A (element-wise) B.
 */
public static H2ODrm exec(H2ODrm drmA,H2ODrm drmB,final String op){
  final Frame A=drmA.frame;
  final Frame B=drmB.frame;
  Vec keys=drmA.keys;
  int AewB_cols=A.numCols();
  Frame AewB=new MRTask(){
    private double opfn(    String op,    double a,    double b){
      if (a == 0.0 && b == 0.0) {
        return 0.0;
      }
      if (op.equals("String_Node_Str")) {
        return a + b;
      }
 else       if (op.equals("String_Node_Str")) {
        return a - b;
      }
 else       if (op.equals("String_Node_Str")) {
        return a * b;
      }
 else       if (op.equals("String_Node_Str")) {
        return a / b;
      }
      return 0.0;
    }
    @Override public void map(    Chunk chks[],    NewChunk ncs[]){
      int chunkSize=chks[0].len();
      Vec B_vecs[]=B.vecs();
      long start=chks[0].start();
      for (int c=0; c < chks.length; c++) {
        for (int r=0; r < chunkSize; r++) {
          ncs[c].addNum(opfn(op,chks[c].atd(r),B_vecs[c].at(start + r)));
        }
      }
    }
  }
.doAll(AewB_cols,A).outputFrame(null,null);
  return new H2ODrm(AewB,keys);
}
Program: 61158
Project: 61158
Buggy source:
public void map(Chunk chks[],NewChunk ncs[]){
  int chunkSize=chks[0].len();
  long start=chks[0].start();
  for (int c=0; c < chks.length; c++) {
    for (int r=0; r < chunkSize; r++) {
      ncs[c].addNum(opfn(op,chks[c].at0(r),s));
    }
  }
}

Fixed version (ground truth):
public void map(Chunk chks[],NewChunk ncs[]){
  int chunkSize=chks[0].len();
  long start=chks[0].start();
  for (int c=0; c < chks.length; c++) {
    for (int r=0; r < chunkSize; r++) {
      ncs[c].addNum(opfn(op,chks[c].atd(r),s));
    }
  }
}
Program: 61159
Project: 61159
Buggy source:
/** 
 * Perform element-wise operation on a DRM with a Scalar to create a new DRM.
 * @param drmA DRM representing matrix A.
 * @param s Scalar value represented as a double.
 * @param op Element-wise operator encoded as a String.
 * @return new DRM containing A (element-wise) B.
 */
public static H2ODrm exec(H2ODrm drmA,final double s,final String op){
  Frame A=drmA.frame;
  Vec keys=drmA.keys;
  int AewScalar_cols=A.numCols();
  Frame AewScalar=new MRTask(){
    private double opfn(    String op,    double a,    double b){
      if (a == 0.0 && b == 0.0) {
        return 0.0;
      }
      if (op.equals("String_Node_Str")) {
        return a + b;
      }
 else       if (op.equals("String_Node_Str")) {
        return a - b;
      }
 else       if (op.equals("String_Node_Str")) {
        return a * b;
      }
 else       if (op.equals("String_Node_Str")) {
        return a / b;
      }
      return 0.0;
    }
    public void map(    Chunk chks[],    NewChunk ncs[]){
      int chunkSize=chks[0].len();
      long start=chks[0].start();
      for (int c=0; c < chks.length; c++) {
        for (int r=0; r < chunkSize; r++) {
          ncs[c].addNum(opfn(op,chks[c].at0(r),s));
        }
      }
    }
  }
.doAll(AewScalar_cols,A).outputFrame(null,null);
  return new H2ODrm(AewScalar,keys);
}

Fixed version (ground truth):
/** 
 * Perform element-wise operation on a DRM with a Scalar to create a new DRM.
 * @param drmA DRM representing matrix A.
 * @param s Scalar value represented as a double.
 * @param op Element-wise operator encoded as a String.
 * @return new DRM containing A (element-wise) B.
 */
public static H2ODrm exec(H2ODrm drmA,final double s,final String op){
  Frame A=drmA.frame;
  Vec keys=drmA.keys;
  int AewScalar_cols=A.numCols();
  Frame AewScalar=new MRTask(){
    private double opfn(    String op,    double a,    double b){
      if (a == 0.0 && b == 0.0) {
        return 0.0;
      }
      if (op.equals("String_Node_Str")) {
        return a + b;
      }
 else       if (op.equals("String_Node_Str")) {
        return a - b;
      }
 else       if (op.equals("String_Node_Str")) {
        return a * b;
      }
 else       if (op.equals("String_Node_Str")) {
        return a / b;
      }
      return 0.0;
    }
    public void map(    Chunk chks[],    NewChunk ncs[]){
      int chunkSize=chks[0].len();
      long start=chks[0].start();
      for (int c=0; c < chks.length; c++) {
        for (int r=0; r < chunkSize; r++) {
          ncs[c].addNum(opfn(op,chks[c].atd(r),s));
        }
      }
    }
  }
.doAll(AewScalar_cols,A).outputFrame(null,null);
  return new H2ODrm(AewScalar,keys);
}
Program: 61160
Project: 61160
Buggy source:
public void map(Chunk chks[]){
  int chunkSize=chks[0].len();
  long start=chks[0].start();
  Vec A_vecs[]=A.vecs();
  for (int c=0; c < chks.length; c++) {
    for (int r=0; r < chunkSize; r++) {
      chks[c].set0(r,A_vecs[(int)(start + r)].at(c));
    }
  }
}

Fixed version (ground truth):
public void map(Chunk chks[]){
  int chunkSize=chks[0].len();
  long start=chks[0].start();
  Vec A_vecs[]=A.vecs();
  for (int c=0; c < chks.length; c++) {
    for (int r=0; r < chunkSize; r++) {
      chks[c].set(r,A_vecs[(int)(start + r)].at(c));
    }
  }
}
Program: 61161
Project: 61161
Buggy source:
/** 
 * Perform transpose operation on a DRM to create a new DRM.
 * @param drmA DRM representing matrix A.
 * @return new DRM containing A'.
 */
public static H2ODrm exec(H2ODrm drmA){
  final Frame A=drmA.frame;
  Frame At=H2OHelper.emptyFrame(A.numCols(),(int)A.numRows(),-1,-1);
  new MRTask(){
    public void map(    Chunk chks[]){
      int chunkSize=chks[0].len();
      long start=chks[0].start();
      Vec A_vecs[]=A.vecs();
      for (int c=0; c < chks.length; c++) {
        for (int r=0; r < chunkSize; r++) {
          chks[c].set0(r,A_vecs[(int)(start + r)].at(c));
        }
      }
    }
  }
.doAll(At);
  return new H2ODrm(At);
}

Fixed version (ground truth):
/** 
 * Perform transpose operation on a DRM to create a new DRM.
 * @param drmA DRM representing matrix A.
 * @return new DRM containing A'.
 */
public static H2ODrm exec(H2ODrm drmA){
  final Frame A=drmA.frame;
  Frame At=H2OHelper.emptyFrame(A.numCols(),(int)A.numRows(),-1,-1);
  new MRTask(){
    public void map(    Chunk chks[]){
      int chunkSize=chks[0].len();
      long start=chks[0].start();
      Vec A_vecs[]=A.vecs();
      for (int c=0; c < chks.length; c++) {
        for (int r=0; r < chunkSize; r++) {
          chks[c].set(r,A_vecs[(int)(start + r)].at(c));
        }
      }
    }
  }
.doAll(At);
  return new H2ODrm(At);
}
Program: 61162
Project: 61162
Buggy source:
public void map(Chunk chks[]){
  int chunkSize=chks[0].len();
  long start=chks[0].start();
  Vec A_vecs[]=A.vecs();
  long A_rows=A.numRows();
  for (int c=0; c < chks.length; c++) {
    for (int r=0; r < chunkSize; r++) {
      double v=0;
      for (long i=0; i < A_rows; i++) {
        v+=(A_vecs[(int)(start + r)].at(i) * A_vecs[c].at(i));
      }
      chks[c].set0(r,v);
    }
  }
}

Fixed version (ground truth):
public void map(Chunk chks[]){
  int chunkSize=chks[0].len();
  long start=chks[0].start();
  Vec A_vecs[]=A.vecs();
  long A_rows=A.numRows();
  for (int c=0; c < chks.length; c++) {
    for (int r=0; r < chunkSize; r++) {
      double v=0;
      for (long i=0; i < A_rows; i++) {
        v+=(A_vecs[(int)(start + r)].at(i) * A_vecs[c].at(i));
      }
      chks[c].set(r,v);
    }
  }
}
Program: 61163
Project: 61163
Buggy source:
/** 
 * Perform A'A operation on a DRM to create a new DRM.
 * @param drmA DRM representing matrix A.
 * @return new DRM containing A'A.
 */
public static H2ODrm exec(H2ODrm drmA){
  final Frame A=drmA.frame;
  Frame AtA=H2OHelper.emptyFrame(A.numCols(),A.numCols(),-1,-1);
  new MRTask(){
    public void map(    Chunk chks[]){
      int chunkSize=chks[0].len();
      long start=chks[0].start();
      Vec A_vecs[]=A.vecs();
      long A_rows=A.numRows();
      for (int c=0; c < chks.length; c++) {
        for (int r=0; r < chunkSize; r++) {
          double v=0;
          for (long i=0; i < A_rows; i++) {
            v+=(A_vecs[(int)(start + r)].at(i) * A_vecs[c].at(i));
          }
          chks[c].set0(r,v);
        }
      }
    }
  }
.doAll(AtA);
  return new H2ODrm(AtA);
}

Fixed version (ground truth):
/** 
 * Perform A'A operation on a DRM to create a new DRM.
 * @param drmA DRM representing matrix A.
 * @return new DRM containing A'A.
 */
public static H2ODrm exec(H2ODrm drmA){
  final Frame A=drmA.frame;
  Frame AtA=H2OHelper.emptyFrame(A.numCols(),A.numCols(),-1,-1);
  new MRTask(){
    public void map(    Chunk chks[]){
      int chunkSize=chks[0].len();
      long start=chks[0].start();
      Vec A_vecs[]=A.vecs();
      long A_rows=A.numRows();
      for (int c=0; c < chks.length; c++) {
        for (int r=0; r < chunkSize; r++) {
          double v=0;
          for (long i=0; i < A_rows; i++) {
            v+=(A_vecs[(int)(start + r)].at(i) * A_vecs[c].at(i));
          }
          chks[c].set(r,v);
        }
      }
    }
  }
.doAll(AtA);
  return new H2ODrm(AtA);
}
Program: 61164
Project: 61164
Buggy source:
public void map(Chunk chks[]){
  int chunkSize=chks[0].len();
  long start=chks[0].start();
  long A_rows=A.numRows();
  Vec A_vecs[]=A.vecs();
  Vec B_vecs[]=B.vecs();
  for (int c=0; c < chks.length; c++) {
    for (int r=0; r < chunkSize; r++) {
      double v=0;
      for (long i=0; i < A_rows; i++) {
        v+=(A_vecs[(int)(start + r)].at(i) * B_vecs[c].at(i));
      }
      chks[c].set0(r,v);
    }
  }
}

Fixed version (ground truth):
public void map(Chunk chks[]){
  int chunkSize=chks[0].len();
  long start=chks[0].start();
  long A_rows=A.numRows();
  Vec A_vecs[]=A.vecs();
  Vec B_vecs[]=B.vecs();
  for (int c=0; c < chks.length; c++) {
    for (int r=0; r < chunkSize; r++) {
      double v=0;
      for (long i=0; i < A_rows; i++) {
        v+=(A_vecs[(int)(start + r)].at(i) * B_vecs[c].at(i));
      }
      chks[c].set(r,v);
    }
  }
}
Program: 61165
Project: 61165
Buggy source:
/** 
 * Perform A'B operation on two DRMs to create a new DRM.
 * @param drmA DRM representing matrix A.
 * @param drmB DRM representing matrix B.
 * @return new DRM containing A'B.
 */
public static H2ODrm exec(H2ODrm drmA,H2ODrm drmB){
  final Frame A=drmA.frame;
  final Frame B=drmB.frame;
  Frame AtB=H2OHelper.emptyFrame(A.numCols(),B.numCols(),-1,-1);
  new MRTask(){
    public void map(    Chunk chks[]){
      int chunkSize=chks[0].len();
      long start=chks[0].start();
      long A_rows=A.numRows();
      Vec A_vecs[]=A.vecs();
      Vec B_vecs[]=B.vecs();
      for (int c=0; c < chks.length; c++) {
        for (int r=0; r < chunkSize; r++) {
          double v=0;
          for (long i=0; i < A_rows; i++) {
            v+=(A_vecs[(int)(start + r)].at(i) * B_vecs[c].at(i));
          }
          chks[c].set0(r,v);
        }
      }
    }
  }
.doAll(AtB);
  return new H2ODrm(AtB);
}

Fixed version (ground truth):
/** 
 * Perform A'B operation on two DRMs to create a new DRM.
 * @param drmA DRM representing matrix A.
 * @param drmB DRM representing matrix B.
 * @return new DRM containing A'B.
 */
public static H2ODrm exec(H2ODrm drmA,H2ODrm drmB){
  final Frame A=drmA.frame;
  final Frame B=drmB.frame;
  Frame AtB=H2OHelper.emptyFrame(A.numCols(),B.numCols(),-1,-1);
  new MRTask(){
    public void map(    Chunk chks[]){
      int chunkSize=chks[0].len();
      long start=chks[0].start();
      long A_rows=A.numRows();
      Vec A_vecs[]=A.vecs();
      Vec B_vecs[]=B.vecs();
      for (int c=0; c < chks.length; c++) {
        for (int r=0; r < chunkSize; r++) {
          double v=0;
          for (long i=0; i < A_rows; i++) {
            v+=(A_vecs[(int)(start + r)].at(i) * B_vecs[c].at(i));
          }
          chks[c].set(r,v);
        }
      }
    }
  }
.doAll(AtB);
  return new H2ODrm(AtB);
}
Program: 61166
Project: 61166
Buggy source:
public void map(Chunk chks[]){
  int chunkSize=chks[0].len();
  Vector x=bx.value();
  long start=chks[0].start();
  atx=new double[chks.length];
  for (int r=0; r < chunkSize; r++) {
    double d=x.getQuick((int)start + r);
    for (int c=0; c < chks.length; c++) {
      atx[c]+=(chks[c].at0(r) * d);
    }
  }
}

Fixed version (ground truth):
public void map(Chunk chks[]){
  int chunkSize=chks[0].len();
  Vector x=bx.value();
  long start=chks[0].start();
  atx=new double[chks.length];
  for (int r=0; r < chunkSize; r++) {
    double d=x.getQuick((int)start + r);
    for (int c=0; c < chks.length; c++) {
      atx[c]+=(chks[c].atd(r) * d);
    }
  }
}
Program: 61167
Project: 61167
Buggy source:
/** 
 * Perform A'x operation with a DRM and an in-core Vector to create a new DRM.
 * @param drmA DRM representing matrix A.
 * @param x in-core Mahout Vector.
 * @return new DRM containing A'x.
 */
public static H2ODrm exec(H2ODrm drmA,Vector x){
  Frame A=drmA.frame;
  final H2OBCast<Vector> bx=new H2OBCast<Vector>(x);
class MRTaskAtx extends MRTask<MRTaskAtx> {
    double atx[];
    public void map(    Chunk chks[]){
      int chunkSize=chks[0].len();
      Vector x=bx.value();
      long start=chks[0].start();
      atx=new double[chks.length];
      for (int r=0; r < chunkSize; r++) {
        double d=x.getQuick((int)start + r);
        for (int c=0; c < chks.length; c++) {
          atx[c]+=(chks[c].at0(r) * d);
        }
      }
    }
    public void reduce(    MRTaskAtx other){
      ArrayUtils.add(atx,other.atx);
    }
  }
  Vector v=new DenseVector(new MRTaskAtx().doAll(A).atx);
  Matrix m=new DenseMatrix(A.numCols(),1);
  m.assignColumn(0,v);
  return H2OHelper.drmFromMatrix(m,-1,-1);
}

Fixed version (ground truth):
/** 
 * Perform A'x operation with a DRM and an in-core Vector to create a new DRM.
 * @param drmA DRM representing matrix A.
 * @param x in-core Mahout Vector.
 * @return new DRM containing A'x.
 */
public static H2ODrm exec(H2ODrm drmA,Vector x){
  Frame A=drmA.frame;
  final H2OBCast<Vector> bx=new H2OBCast<Vector>(x);
class MRTaskAtx extends MRTask<MRTaskAtx> {
    double atx[];
    public void map(    Chunk chks[]){
      int chunkSize=chks[0].len();
      Vector x=bx.value();
      long start=chks[0].start();
      atx=new double[chks.length];
      for (int r=0; r < chunkSize; r++) {
        double d=x.getQuick((int)start + r);
        for (int c=0; c < chks.length; c++) {
          atx[c]+=(chks[c].atd(r) * d);
        }
      }
    }
    public void reduce(    MRTaskAtx other){
      ArrayUtils.add(atx,other.atx);
    }
  }
  Vector v=new DenseVector(new MRTaskAtx().doAll(A).atx);
  Matrix m=new DenseMatrix(A.numCols(),1);
  m.assignColumn(0,v);
  return H2OHelper.drmFromMatrix(m,-1,-1);
}
Program: 61168
Project: 61168
Buggy source:
public void map(Chunk chks[],NewChunk nc){
  int chunkSize=chks[0].len();
  Vector x=bx.value();
  for (int r=0; r < chunkSize; r++) {
    double v=0;
    for (int c=0; c < chks.length; c++) {
      v+=(chks[c].at0(r) * x.getQuick(c));
    }
    nc.addNum(v);
  }
}

Fixed version (ground truth):
public void map(Chunk chks[],NewChunk nc){
  int chunkSize=chks[0].len();
  Vector x=bx.value();
  for (int r=0; r < chunkSize; r++) {
    double v=0;
    for (int c=0; c < chks.length; c++) {
      v+=(chks[c].atd(r) * x.getQuick(c));
    }
    nc.addNum(v);
  }
}
Program: 61169
Project: 61169
Buggy source:
/** 
 * Perform Ax operation with a DRM and an in-core Vector to create a new DRM.
 * @param drmA DRM representing matrix A.
 * @param x in-core Mahout Vector.
 * @return new DRM containing Ax.
 */
public static H2ODrm exec(H2ODrm drmA,Vector x){
  Frame A=drmA.frame;
  Vec keys=drmA.keys;
  final H2OBCast<Vector> bx=new H2OBCast<Vector>(x);
  Frame Ax=new MRTask(){
    public void map(    Chunk chks[],    NewChunk nc){
      int chunkSize=chks[0].len();
      Vector x=bx.value();
      for (int r=0; r < chunkSize; r++) {
        double v=0;
        for (int c=0; c < chks.length; c++) {
          v+=(chks[c].at0(r) * x.getQuick(c));
        }
        nc.addNum(v);
      }
    }
  }
.doAll(1,A).outputFrame(null,null);
  return new H2ODrm(Ax,keys);
}

Fixed version (ground truth):
/** 
 * Perform Ax operation with a DRM and an in-core Vector to create a new DRM.
 * @param drmA DRM representing matrix A.
 * @param x in-core Mahout Vector.
 * @return new DRM containing Ax.
 */
public static H2ODrm exec(H2ODrm drmA,Vector x){
  Frame A=drmA.frame;
  Vec keys=drmA.keys;
  final H2OBCast<Vector> bx=new H2OBCast<Vector>(x);
  Frame Ax=new MRTask(){
    public void map(    Chunk chks[],    NewChunk nc){
      int chunkSize=chks[0].len();
      Vector x=bx.value();
      for (int r=0; r < chunkSize; r++) {
        double v=0;
        for (int c=0; c < chks.length; c++) {
          v+=(chks[c].atd(r) * x.getQuick(c));
        }
        nc.addNum(v);
      }
    }
  }
.doAll(1,A).outputFrame(null,null);
  return new H2ODrm(Ax,keys);
}
Program: 61170
Project: 61170
Buggy source:
/** 
 * Heavy weight join(), involves moving data 
 */
private static H2ODrm join(final Frame fra,final Vec keysa,final Frame frb,final Vec keysb){
  Vec bvecs[]=new Vec[frb.vecs().length];
  for (int i=0; i < bvecs.length; i++) {
    bvecs[i]=fra.anyVec().makeZero();
  }
  new MRTask(){
    public void map(    Chunk chks[]){
      int chunkSize=chks[0].len();
      long start=chks[0].start();
      Vec vecs[]=frb.vecs();
      for (int r=0; r < chunkSize; r++) {
        for (int c=0; c < chks.length; c++) {
          chks[c].set0(r,vecs[c].at(start + r));
        }
      }
    }
  }
.doAll(bvecs);
  return zip(fra,keysa,new Frame(bvecs),null);
}

Fixed version (ground truth):
/** 
 * Heavy weight join(), involves moving data 
 */
private static H2ODrm join(final Frame fra,final Vec keysa,final Frame frb,final Vec keysb){
  Vec bvecs[]=new Vec[frb.vecs().length];
  for (int i=0; i < bvecs.length; i++) {
    bvecs[i]=fra.anyVec().makeZero();
  }
  new MRTask(){
    public void map(    Chunk chks[]){
      int chunkSize=chks[0].len();
      long start=chks[0].start();
      Vec vecs[]=frb.vecs();
      for (int r=0; r < chunkSize; r++) {
        for (int c=0; c < chks.length; c++) {
          chks[c].set(r,vecs[c].at(start + r));
        }
      }
    }
  }
.doAll(bvecs);
  return zip(fra,keysa,new Frame(bvecs),null);
}
Program: 61171
Project: 61171
Buggy source:
public void map(Chunk chks[]){
  int chunkSize=chks[0].len();
  long start=chks[0].start();
  Vec vecs[]=frb.vecs();
  for (int r=0; r < chunkSize; r++) {
    for (int c=0; c < chks.length; c++) {
      chks[c].set0(r,vecs[c].at(start + r));
    }
  }
}

Fixed version (ground truth):
public void map(Chunk chks[]){
  int chunkSize=chks[0].len();
  long start=chks[0].start();
  Vec vecs[]=frb.vecs();
  for (int r=0; r < chunkSize; r++) {
    for (int c=0; c < chks.length; c++) {
      chks[c].set(r,vecs[c].at(start + r));
    }
  }
}
Program: 61172
Project: 61172
Buggy source:
public void map(Chunk chks[]){
  int chunkSize=chks[0].len();
  Vec vins[]=frin.vecs();
  long start=chks[0].start();
  for (int r=0; r < chunkSize; r++) {
    for (int c=0; c < chks.length; c++) {
      chks[c].set0(r,vins[c].at(start + r));
    }
  }
}

Fixed version (ground truth):
public void map(Chunk chks[]){
  int chunkSize=chks[0].len();
  Vec vins[]=frin.vecs();
  long start=chks[0].start();
  for (int r=0; r < chunkSize; r++) {
    for (int c=0; c < chks.length; c++) {
      chks[c].set(r,vins[c].at(start + r));
    }
  }
}