From fff2c085c4cc4b88cfa1d0eb072fedec7a654fe2 Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Fri, 29 Apr 2011 19:28:06 +0000 Subject: [PATCH 1/2] Update pig example script to work again. Patch by Jeremy Hanna, reviewed by brandonwilliams for CASSANDRA-2487 git-svn-id: https://svn.apache.org/repos/asf/cassandra/branches/cassandra-0.7@1097922 13f79535-47bb-0310-9956-ffa450edef68 --- contrib/pig/README.txt | 23 ++++++++++++++--------- contrib/pig/example-script.pig | 6 +++--- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/contrib/pig/README.txt b/contrib/pig/README.txt index e86b701b5b..93eceb24bb 100644 --- a/contrib/pig/README.txt +++ b/contrib/pig/README.txt @@ -18,17 +18,22 @@ also set PIG_CONF_DIR to the location of your Hadoop config. Finally, set the following as environment variables (uppercase, underscored), or as Hadoop configuration variables (lowercase, dotted): -* PIG_RPC_PORT or cassandra.thrift.port : the port thrift is listening on * PIG_INITIAL_ADDRESS or cassandra.thrift.address : initial address to connect to +* PIG_RPC_PORT or cassandra.thrift.port : the port thrift is listening on * PIG_PARTITIONER or cassandra.partitioner.class : cluster partitioner -Run: +For example, against a local node with the default settings, you'd use: +export PIG_INITIAL_ADDRESS=localhost +export PIG_RPC_PORT=9160 +export PIG_PARTITIONER=org.apache.cassandra.dht.RandomPartitioner + +Then you can build and run it like this: contrib/pig$ ant contrib/pig$ bin/pig_cassandra -x local example-script.pig This will run the test script against your Cassandra instance -and will assume that there is a Keyspace1/Standard1 with some +and will assume that there is a MyKeyspace/MyColumnFamily with some data in it. It will run in local mode (see pig docs for more info). If you'd like to get to a 'grunt>' shell prompt, run: @@ -38,24 +43,24 @@ 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://Keyspace1/Standard1' USING CassandraStorage(); -grunt> cols = FOREACH rows GENERATE flatten($1); +grunt> rows = LOAD 'cassandra://MyKeyspace/MyColumnFamily' USING CassandraStorage() AS (key, columns: bag {T: tuple(name, value)}); +grunt> cols = FOREACH rows GENERATE flatten(columns); grunt> colnames = FOREACH cols GENERATE $0; -grunt> namegroups = GROUP colnames BY $0; +grunt> namegroups = GROUP colnames BY (chararray) $0; grunt> namecounts = FOREACH namegroups GENERATE COUNT($1), group; grunt> orderednames = ORDER namecounts BY $0; grunt> topnames = LIMIT orderednames 50; grunt> dump topnames; Slices on columns can also be specified: -grunt> rows = LOAD 'cassandra://Keyspace1/Standard1&slice_start=C2&slice_end=C4&i&limit=1&reversed=true' USING CassandraStorage(); +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)}); Binary values for slice_start and slice_end can be escaped such as '\u0255' Outputting to Cassandra requires the same format from input, so the simplest example is: -grunt> rows = LOAD 'cassandra://Keyspace1/Standard1' USING CassandraStorage(); -grunt> STORE rows into 'cassandra://Keyspace1/Standard2' USING CassandraStorage(); +grunt> rows = LOAD 'cassandra://MyKeyspace/MyColumnFamily' USING CassandraStorage(); +grunt> STORE rows into 'cassandra://MyKeyspace/MyColumnFamily' USING CassandraStorage(); Which will copy the ColumnFamily. Note that the destination ColumnFamily must already exist for this to work. diff --git a/contrib/pig/example-script.pig b/contrib/pig/example-script.pig index 5b5c0329eb..f88d77365c 100644 --- a/contrib/pig/example-script.pig +++ b/contrib/pig/example-script.pig @@ -1,7 +1,7 @@ -rows = LOAD 'cassandra://Keyspace1/Standard1' USING CassandraStorage(); -cols = FOREACH rows GENERATE flatten($1); +rows = LOAD 'cassandra://MyKeyspace/MyColumnFamily' USING CassandraStorage() AS (key, columns: bag {T: tuple(name, value)}); +cols = FOREACH rows GENERATE flatten(columns); colnames = FOREACH cols GENERATE $0; -namegroups = GROUP colnames BY $0; +namegroups = GROUP colnames BY (chararray) $0; namecounts = FOREACH namegroups GENERATE COUNT($1), group; orderednames = ORDER namecounts BY $0; topnames = LIMIT orderednames 50; From 28414b198c579cdda7f1af47eda33108315afd81 Mon Sep 17 00:00:00 2001 From: Jonathan Ellis Date: Tue, 3 May 2011 15:48:00 +0000 Subject: [PATCH 2/2] fix excessively pessimistic rebuffering in BRAF writes patch by goffinet; reviewed by jbellis and Pavel Yaskevich for CASSANDRA-2581 git-svn-id: https://svn.apache.org/repos/asf/cassandra/branches/cassandra-0.7@1099096 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 2 ++ .../org/apache/cassandra/io/util/BufferedRandomAccessFile.java | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index 48e3ff8e8a..fe7ee11f4c 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -8,6 +8,8 @@ super column name in Deletion (CASSANDRA-2571) * refuse to apply migrations with older timestamps than the current schema (CASSANDRA-2536) + * faster flushes and compaction from fixing excessively pessimistic + rebuffering in BRAF (CASSANDRA-2581) 0.7.5 diff --git a/src/java/org/apache/cassandra/io/util/BufferedRandomAccessFile.java b/src/java/org/apache/cassandra/io/util/BufferedRandomAccessFile.java index 7317d1d1af..00aba8ddc7 100644 --- a/src/java/org/apache/cassandra/io/util/BufferedRandomAccessFile.java +++ b/src/java/org/apache/cassandra/io/util/BufferedRandomAccessFile.java @@ -343,7 +343,7 @@ public class BufferedRandomAccessFile extends RandomAccessFile implements FileDa current = newPosition; - if (newPosition >= bufferOffset + validBufferBytes || newPosition < bufferOffset) + if (newPosition > (bufferOffset + validBufferBytes) || newPosition < bufferOffset) reBuffer(); // this will set bufferEnd for us }