This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pyspark import SparkContext | |
from pyspark.accumulators import AccumulatorParam | |
# Spark only implements Accumulator parameter for numeric types. | |
# This class extends Accumulator support to the string type. | |
class StringAccumulatorParam(AccumulatorParam): | |
def zero(self, value): | |
return value | |
def addInPlace(self, val1, val2): | |
return val1 + val2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ClassName: | |
def __init__(self): | |
parser = argparse.ArgumentParser(description="") | |
parser.add_argument("task", help="select the task to perform,") | |
args = parser.parse_args(sys.argv[1:2]) | |
getattr(self, args.task)() | |
def task(self): | |
parser = argparse.ArgumentParser(description="") | |
parser.add_argument("--arg", help="") |