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

    https://github.com/apache/spark/pull/1297#discussion_r17945448
  
    --- Diff: 
core/src/main/scala/org/apache/spark/rdd/IndexedRDDPartitionLike.scala ---
    @@ -0,0 +1,426 @@
    +/*
    + * 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.spark.rdd
    +
    +import scala.collection.immutable.LongMap
    +import scala.language.higherKinds
    +import scala.reflect.ClassTag
    +
    +import org.apache.spark.Logging
    +import org.apache.spark.util.collection.BitSet
    +import org.apache.spark.util.collection.ImmutableBitSet
    +import org.apache.spark.util.collection.ImmutableLongOpenHashSet
    +import org.apache.spark.util.collection.ImmutableVector
    +import org.apache.spark.util.collection.OpenHashSet
    +import org.apache.spark.util.collection.PrimitiveKeyOpenHashMap
    +
    +import IndexedRDD.Id
    +import IndexedRDDPartition.Index
    +
    +/**
    + * Contains members that are shared among all variants of 
IndexedRDDPartition (e.g.,
    + * IndexedRDDPartition, ShippableVertexPartition).
    + *
    + * @tparam V the type of the values stored in the IndexedRDDPartition
    + * @tparam Self the type of the implementing container. This allows 
transformation methods on any
    + * implementing container to yield a result of the same type.
    + */
    +private[spark] trait IndexedRDDPartitionLike[
    +    @specialized(Long, Int, Double) V,
    +    Self[X] <: IndexedRDDPartitionLike[X, Self]]
    +  extends Serializable with Logging {
    +
    +  /** A generator for ClassTags of the value type V. */
    +  implicit def vTag: ClassTag[V]
    +
    +  /** Accessor for the IndexedRDDPartition variant that is mixing in this 
trait. */
    +  def self: Self[V]
    +
    +  def index: Index
    +  def values: ImmutableVector[V]
    +  def mask: ImmutableBitSet
    +
    +  def withIndex(index: Index): Self[V]
    +  def withValues[V2: ClassTag](values: ImmutableVector[V2]): Self[V2]
    +  def withMask(mask: ImmutableBitSet): Self[V]
    +
    +  val capacity: Int = index.capacity
    +
    +  def size: Int = mask.cardinality()
    +
    +  /** Return the value for the given key. */
    +  def apply(k: Id): V = values(index.getPos(k))
    +
    +  def isDefined(k: Id): Boolean = {
    +    val pos = index.getPos(k)
    +    pos >= 0 && mask.get(pos)
    +  }
    +
    +  def iterator: Iterator[(Id, V)] =
    +    mask.iterator.map(ind => (index.getValue(ind), values(ind)))
    +
    +  /**
    +   * Gets the values corresponding to the specified keys, if any.
    +   */
    +  def multiget(ks: Array[Id]): LongMap[V] = {
    +    var result = LongMap.empty[V]
    +    var i = 0
    +    while (i < ks.length) {
    +      val k = ks(i)
    +      if (self.isDefined(k)) {
    +        result = result.updated(k, self(k))
    +      }
    +      i += 1
    +    }
    +    result
    +  }
    +
    +  /**
    +   * Updates the keys in `kvs` to their corresponding values, running 
`merge` on old and new values
    +   * if necessary. Returns a new IndexedRDDPartition that reflects the 
modification.
    +   */
    +  def multiput(kvs: Seq[(Id, V)], merge: (Id, V, V) => V): Self[V] = {
    --- End diff --
    
    Bug: we don't use `merge` in the else branch


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to