[ 
https://issues.apache.org/jira/browse/MAHOUT-1596?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14069021#comment-14069021
 ] 

ASF GitHub Bot commented on MAHOUT-1596:
----------------------------------------

Github user dlyubimov commented on a diff in the pull request:

    https://github.com/apache/mahout/pull/30#discussion_r15187205
  
    --- Diff: 
spark/src/main/scala/org/apache/mahout/sparkbindings/blas/RbindAB.scala ---
    @@ -0,0 +1,77 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.mahout.sparkbindings.blas
    +
    +import org.apache.log4j.Logger
    +import scala.reflect.ClassTag
    +import org.apache.mahout.sparkbindings.drm.DrmRddInput
    +import org.apache.mahout.math._
    +import scalabindings._
    +import RLikeOps._
    +import org.apache.mahout.math.drm.logical.OpRbind
    +import org.apache.spark.SparkContext._
    +
    +/** Physical Rbind */
    +object RbindAB {
    +
    +  private val log = Logger.getLogger(RbindAB.getClass)
    +
    +  def rbindAB_int[K:ClassTag](op: OpRbind[K], srcA: DrmRddInput[K], srcB: 
DrmRddInput[K]): DrmRddInput[K] = {
    +
    +    val a = srcA.asInstanceOf[DrmRddInput[Int]].toDrmRdd()
    +    val b = srcB.asInstanceOf[DrmRddInput[Int]].toDrmRdd()
    +    val n1 = op.A.nrow.asInstanceOf[Int]
    +
    +    val rdd = a union (b map({ case (key, vec) => ((key + n1), vec) }))
    +
    +    new DrmRddInput(rowWiseSrc = Some(op.ncol -> 
rdd)).asInstanceOf[DrmRddInput[K]]
    +  }
    +
    +  def rbindAB_long[K:ClassTag](op: OpRbind[K], srcA: DrmRddInput[K], srcB: 
DrmRddInput[K]): DrmRddInput[K] = {
    +
    +    val a = srcA.asInstanceOf[DrmRddInput[Long]].toDrmRdd()
    +    val b = srcB.asInstanceOf[DrmRddInput[Long]].toDrmRdd()
    +    val n1 = op.A.nrow
    +
    +    val rdd = a union (b map({ case (key, vec) => ((key + n1), vec) }))
    --- End diff --
    
    style: (1) we don't use ( in closures, (2) we try to use -> here, i.e 
recommended style to reduce amount of punctuation: 
    
        // Adjust RHS keys
        val bAdjusted = b.map { case (key, vec) => (key + n1) -> vec }
       
        // dump a and b together 
        ....
    
    also definitely needs more comments on closures
    
    



> support for rbind() operator on DRMs
> ------------------------------------
>
>                 Key: MAHOUT-1596
>                 URL: https://issues.apache.org/jira/browse/MAHOUT-1596
>             Project: Mahout
>          Issue Type: Bug
>            Reporter: Anand Avati
>
> an R like operator, cbind(), for appending rows of second matrix below the 
> rows of first matrix to create a new matrix.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to