cassandra trigger

to run the cassandra 2.1.1 InvertedIndex trigger sample from
https://github.com/apache/cassandra/tree/trunk/examples/triggers

 

git clone https://github.com/apache/cassandra.git
cd cassandra
ant
cd examples/triggers/
ant jar
sudo cp build/trigger-example.jar /etc/cassandra/triggers
sudo cp conf/* /etc/cassandra/
nodetool -h localhost reloadtriggers
cqlsh

cqlsh>CREATE KEYSPACE "Keyspace1" WITH replication = {'class':'SimpleStrategy', 'replication_factor':3};

cqlsh>CREATE TABLE IF NOT EXISTS "Keyspace1"."InvertedIndex"(
user_id text PRIMARY KEY,
user_name text
);

cqlsh>CREATE TABLE IF NOT EXISTS "Keyspace1"."Standard1"(
user_id text PRIMARY KEY,
user_name text
);

cqlsh>CREATE TRIGGER test1 ON "Keyspace1"."Standard1" USING 'org.apache.cassandra.triggers.InvertedIndex';

cqlsh>INSERT INTO "Keyspace1"."Standard1"(user_id,user_name) VALUES('1','Bob');

cqlsh> select  * from "Keyspace1"."Standard1";

user_id | user_name
---------+-----------
1 |       Bob

(1 rows)
cqlsh> select  * from "Keyspace1"."InvertedIndex";

user_id | user_name
---------+-----------
Bob |         1

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s