From f2a4309675832c0887eed060eac5cc3dbc76890c Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Tue, 14 Feb 2012 12:48:33 -0600 Subject: [PATCH] Update readme/example for 3371 --- contrib/pig/README.txt | 6 ++++-- contrib/pig/example-script.pig | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/contrib/pig/README.txt b/contrib/pig/README.txt index 93eceb24bb..1058870194 100644 --- a/contrib/pig/README.txt +++ b/contrib/pig/README.txt @@ -43,7 +43,7 @@ contrib/pig$ bin/pig_cassandra -x local Once the 'grunt>' shell has loaded, try a simple program like the following, which will determine the top 50 column names: -grunt> rows = LOAD 'cassandra://MyKeyspace/MyColumnFamily' USING CassandraStorage() AS (key, columns: bag {T: tuple(name, value)}); +grunt> rows = LOAD 'cassandra://MyKeyspace/MyColumnFamily' USING CassandraStorage(); grunt> cols = FOREACH rows GENERATE flatten(columns); grunt> colnames = FOREACH cols GENERATE $0; grunt> namegroups = GROUP colnames BY (chararray) $0; @@ -53,7 +53,7 @@ grunt> topnames = LIMIT orderednames 50; grunt> dump topnames; Slices on columns can also be specified: -grunt> rows = LOAD 'cassandra://MyKeyspace/MyColumnFamily&slice_start=C2&slice_end=C4&i&limit=1&reversed=true' USING CassandraStorage() AS (key, columns: bag {T: tuple(name, value)}); +grunt> rows = LOAD 'cassandra://MyKeyspace/MyColumnFamily&slice_start=C2&slice_end=C4&limit=1&reversed=true' USING CassandraStorage(); Binary values for slice_start and slice_end can be escaped such as '\u0255' @@ -64,3 +64,5 @@ grunt> STORE rows into 'cassandra://MyKeyspace/MyColumnFamily' USING CassandraSt Which will copy the ColumnFamily. Note that the destination ColumnFamily must already exist for this to work. + +See the example in test/ to see how schema is inferred. diff --git a/contrib/pig/example-script.pig b/contrib/pig/example-script.pig index f88d77365c..74a46025d9 100644 --- a/contrib/pig/example-script.pig +++ b/contrib/pig/example-script.pig @@ -1,8 +1,8 @@ -rows = LOAD 'cassandra://MyKeyspace/MyColumnFamily' USING CassandraStorage() AS (key, columns: bag {T: tuple(name, value)}); +rows = LOAD 'cassandra://MyKeyspace/MyColumnFamily' USING CassandraStorage(); cols = FOREACH rows GENERATE flatten(columns); colnames = FOREACH cols GENERATE $0; namegroups = GROUP colnames BY (chararray) $0; namecounts = FOREACH namegroups GENERATE COUNT($1), group; orderednames = ORDER namecounts BY $0; topnames = LIMIT orderednames 50; -dump topnames; \ No newline at end of file +dump topnames;