Created
July 1, 2011 03:40
-
-
Save matpalm/1057825 to your computer and use it in GitHub Desktop.
hadoop 0.18 counter grammar
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
# "a.b:1" => [["a", "b", 1]] | |
# "a.b:1,c.d:2" => [["a", "b", 1], ["c", "d", 2]] | |
grammar Hadoop18Counters | |
rule counter_records | |
counter_record ("," counter_record)* { | |
def to_list | |
items = elements[0].to_list | |
if elements[1] | |
elements[1].elements.each do |e| | |
items << e.elements[1].to_list | |
end | |
end | |
items | |
end | |
} | |
end | |
rule counter_record | |
group:string "." name:string ":" count:int { | |
def to_list | |
[group.text_value, name.text_value, count.text_value.to_i] | |
end | |
} | |
end | |
rule string | |
[^:\.]+ | |
end | |
rule int | |
[0-9]+ | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment