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

    https://github.com/apache/spark/pull/1297#discussion_r14908709
  
    --- Diff: core/src/main/scala/org/apache/spark/rdd/IndexedRDDLike.scala ---
    @@ -0,0 +1,338 @@
    +/*
    + * 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._
    +import org.apache.spark.SparkContext._
    +import org.apache.spark.storage.StorageLevel
    +
    +import IndexedRDD.Id
    +
    +/**
    + * Contains members that are shared among all variants of IndexedRDD 
(e.g., IndexedRDD,
    + * VertexRDD).
    + *
    + * @tparam V the type of the values stored in the IndexedRDD
    + * @tparam P the type of the partitions making up the IndexedRDD
    + * @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 IndexedRDDLike[
    +    @specialized(Long, Int, Double) V,
    +    P[X] <: IndexedRDDPartitionLike[X, P],
    +    Self[X] <: IndexedRDDLike[X, P, Self]]
    +  extends RDD[(Id, V)] {
    +
    +  /** A generator for ClassTags of the value type V. */
    +  protected implicit def vTag: ClassTag[V]
    +
    +  /** A generator for ClassTags of the partition type P. */
    +  protected implicit def pTag[V2]: ClassTag[P[V2]]
    +
    +  /** Accessor for the IndexedRDD variant that is mixing in this trait. */
    +  protected def self: Self[V]
    +
    +  /** The underlying representation of the IndexedRDD as an RDD of 
partitions. */
    +  def partitionsRDD: RDD[P[V]]
    +  require(partitionsRDD.partitioner.isDefined)
    +
    +  def withPartitionsRDD[V2: ClassTag](partitionsRDD: RDD[P[V2]]): Self[V2]
    +
    +  override val partitioner = partitionsRDD.partitioner
    +
    +  override protected def getPartitions: Array[Partition] = 
partitionsRDD.partitions
    +
    +  override protected def getPreferredLocations(s: Partition): Seq[String] =
    +    partitionsRDD.preferredLocations(s)
    +
    +  override def persist(newLevel: StorageLevel): this.type = {
    +    partitionsRDD.persist(newLevel)
    +    this
    +  }
    +
    +  override def unpersist(blocking: Boolean = true): this.type = {
    +    partitionsRDD.unpersist(blocking)
    +    this
    +  }
    +
    +  override def count(): Long = {
    +    partitionsRDD.map(_.size).reduce(_ + _)
    +  }
    +
    +  /** Provides the `RDD[(Id, V)]` equivalent output. */
    +  override def compute(part: Partition, context: TaskContext): 
Iterator[(Id, V)] = {
    +    firstParent[P[V]].iterator(part, context).next.iterator
    +  }
    +
    +  /** Gets the value corresponding to the specified key, if any. */
    +  def get(k: Id): Option[V] = multiget(Array(k)).get(k)
    --- End diff --
    
    We should also override `PairRDDFunctions.lookup` to use this fast 
implementation.


---
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.
---

Reply via email to