Github user tdas commented on a diff in the pull request: https://github.com/apache/spark/pull/1608#discussion_r15563085 --- Diff: external/hbase/src/main/scala/org/apache/spark/hbase/HBaseContext.scala --- @@ -0,0 +1,538 @@ +/* + * 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.hbase + +import org.apache.hadoop.hbase.HBaseConfiguration +import org.apache.spark.rdd.RDD +import java.io.ByteArrayOutputStream +import java.io.DataOutputStream +import java.io.ByteArrayInputStream +import java.io.DataInputStream +import org.apache.hadoop.conf.Configuration +import org.apache.hadoop.hbase.client.HConnectionManager +import org.apache.spark.api.java.JavaPairRDD +import java.io.OutputStream +import org.apache.hadoop.hbase.client.HTable +import org.apache.hadoop.hbase.client.Scan +import org.apache.hadoop.hbase.client.Get +import java.util.ArrayList +import org.apache.hadoop.hbase.client.Result +import scala.reflect.ClassTag +import org.apache.hadoop.hbase.client.HConnection +import org.apache.hadoop.hbase.client.Put +import org.apache.hadoop.hbase.client.Increment +import org.apache.hadoop.hbase.client.Delete +import org.apache.spark.SparkContext +import org.apache.hadoop.hbase.mapreduce.TableInputFormat +import org.apache.hadoop.hbase.mapreduce.TableMapReduceUtil +import org.apache.hadoop.hbase.io.ImmutableBytesWritable +import org.apache.hadoop.hbase.util.Bytes +import org.apache.hadoop.mapreduce.Job +import org.apache.hadoop.hbase.mapreduce.TableMapper +import org.apache.hadoop.hbase.mapreduce.IdentityTableMapper +import org.apache.hadoop.hbase.util.Base64 +import org.apache.spark.rdd.HadoopRDD +import org.apache.spark.broadcast.Broadcast +import org.apache.spark.SerializableWritable +import java.util.HashMap +import java.util.concurrent.atomic.AtomicInteger +import org.apache.hadoop.hbase.HConstants +import java.util.concurrent.atomic.AtomicLong +import java.util.Timer +import java.util.TimerTask +import org.apache.hadoop.hbase.client.Mutation +import scala.collection.mutable.MutableList +import org.apache.spark.streaming.dstream.DStream + +/** + * HBaseContext is a façade of simple and complex HBase operations + * like bulk put, get, increment, delete, and scan + * + * HBase Context will take the responsibilities to happen to + * complexity of disseminating the configuration information + * to the working and managing the life cycle of HConnections. + * + * First constructor: + * @param sc Active SparkContext + * @param broadcastedConf This is a Broadcast object that holds a + * serializable Configuration object + * + */ +@serializable class HBaseContext(@transient sc: SparkContext, + broadcastedConf: Broadcast[SerializableWritable[Configuration]]) { + + /** + * Second constructor option: + * @param sc Active SparkContext + * @param config Configuration object to make connection to HBase + */ + def this(@transient sc: SparkContext, @transient config: Configuration) { + this(sc, sc.broadcast(new SerializableWritable(config))) + } + + /** + * A simple enrichment of the traditional Spark RDD foreachPartition. --- End diff -- Please take a look at other the scala docs of RDD transformation to understand the style. For example, a better way to explain this method would be to do the following. `Applies a function on each partition of the given RDD using a HBase connection`.
--- 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. ---