<s> from hadoop . io . NullWritable import NullWritable <EOL> from hadoop . io . Text import Text <EOL> from hadoop . io import SequenceFile <EOL> from argparse import ArgumentParser <EOL> import sys <EOL> def make_text_null_seq ( filename , reader ) : <EOL> writer = SequenceFile . createWriter ( filename , Text , NullWritable ) <EOL> key = Text ( ) <EOL> value = NullWritable ( ) <EOL> count = <NUM_LIT:0> <EOL> for x in reader : <EOL> key . set ( x ) <EOL> writer . append ( key , value ) <EOL> count += <NUM_LIT:1> <EOL> writer . close ( ) <EOL> return count <EOL> def count_file ( filename ) : <EOL> reader = SequenceFile . Reader ( filename ) <EOL> key = Text ( ) <EOL> value = NullWritable ( ) <EOL> count = <NUM_LIT:0> <EOL> while reader . next ( key , value ) : <EOL> count += <NUM_LIT:1> <EOL> return count <EOL> def main ( ) : <EOL> parser = ArgumentParser ( ) <EOL> parser . add_argument ( '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , action = '<STR_LIT:store_true>' ) <EOL> r = parser . parse_args ( ) <EOL> if r . count : <EOL> print ( count_file ( r . seqfile ) ) <EOL> elif r . copyfrom : <EOL> with open ( r . copyfrom ) as fh : <EOL> make_text_null_seq ( r . seqfile , fh ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> main ( ) </s>
