[Commits] Rev 3489: MDEV-431: Cassandra storage engine in file:///data0/psergey/dev2/5.5-cassandra-r01/

Sergey Petrunya psergey at askmonty.org
Sun Aug 19 12:21:24 EEST 2012


At file:///data0/psergey/dev2/5.5-cassandra-r01/

------------------------------------------------------------
revno: 3489
revision-id: psergey at askmonty.org-20120819092123-m3yxpg9n76aycu5z
parent: psergey at askmonty.org-20120819085053-ehoiekekjbwz0udm
committer: Sergey Petrunya <psergey at askmonty.org>
branch nick: 5.5-cassandra-r01
timestamp: Sun 2012-08-19 13:21:23 +0400
message:
  MDEV-431: Cassandra storage engine
  - Partial support for DELETE ... WHERE.
=== modified file 'mysql-test/r/cassandra.result'
--- a/mysql-test/r/cassandra.result	2012-08-19 08:50:53 +0000
+++ b/mysql-test/r/cassandra.result	2012-08-19 09:21:23 +0000
@@ -14,8 +14,11 @@
 create table t1 (rowkey char(10) primary key, column1 char(10)) engine=cassandra 
 thrift_host='localhost' keyspace='no_such_keyspace';
 ERROR HY000: Unable to connect to foreign data source: thrift_host, keyspace, and column_family table options must be s
+# Now, create a table for real and insert data
 create table t1 (rowkey varchar(36) primary key, data1 varchar(60), data2 bigint) engine=cassandra 
 thrift_host='localhost' keyspace='mariadbtest2' column_family='cf1';
+# Just in case there were left-overs from previous:
+delete from t1;
 select * from t1;
 rowkey	data1	data2
 insert into t1 values ('rowkey10', 'data1-value', 123456);
@@ -33,6 +36,12 @@
 select * from t1 where rowkey='rowkey11';
 rowkey	data1	data2
 rowkey11	data1-value2	34543
+delete from t1 where rowkey='rowkey11';
+select * from t1;
+rowkey	data1	data2
+rowkey12	data1-value3	454
+rowkey10	data1-value	123456
+rowkey11	NULL	NULL
 delete from t1;
 select * from t1;
 rowkey	data1	data2

=== modified file 'mysql-test/t/cassandra.test'
--- a/mysql-test/t/cassandra.test	2012-08-19 08:50:53 +0000
+++ b/mysql-test/t/cassandra.test	2012-08-19 09:21:23 +0000
@@ -48,9 +48,12 @@
 ## Cassandra initialization ends
 ############################################################################
 
-# Now, create a table for real and insert data
+--echo # Now, create a table for real and insert data
 create table t1 (rowkey varchar(36) primary key, data1 varchar(60), data2 bigint) engine=cassandra 
   thrift_host='localhost' keyspace='mariadbtest2' column_family='cf1';
+
+--echo # Just in case there were left-overs from previous:
+delete from t1;
 select * from t1;
 
 insert into t1 values ('rowkey10', 'data1-value', 123456);
@@ -62,7 +65,22 @@
 select * from t1 where rowkey='rowkey11';
 select * from t1 where rowkey='rowkey11';
 
-# Check if deletion works
+# Deletion functions weirdly: it sets all columns to NULL
+#   but when If I do this in cassandra-cli:
+#
+#     del cf1[ascii('rowkey10')]
+#
+# Subsequent 'list cf1' command also gives
+#
+#    RowKey: rowkey10
+#
+# without any columns.
+#
+# CQL seems to simply ignore all "incomplete" records. 
+
+delete from t1 where rowkey='rowkey11';
+select * from t1;
+
 delete from t1;
 select * from t1;
 

=== modified file 'storage/cassandra/cassandra_se.cc'
--- a/storage/cassandra/cassandra_se.cc	2012-08-19 08:50:53 +0000
+++ b/storage/cassandra/cassandra_se.cc	2012-08-19 09:21:23 +0000
@@ -101,6 +101,10 @@
   void add_read_column(const char *name);
   
   bool truncate();
+  bool remove_row();
+
+  /* Non-inherited utility functions: */
+  int64_t get_i64_timestamp();
 };
 
 
@@ -215,6 +219,18 @@
 /////////////////////////////////////////////////////////////////////////////
 // Data writes
 /////////////////////////////////////////////////////////////////////////////
+int64_t Cassandra_se_impl::get_i64_timestamp()
+{
+  struct timeval td;
+  gettimeofday(&td, NULL);
+  int64_t ms = td.tv_sec;
+  ms = ms * 1000;
+  int64_t usec = td.tv_usec;
+  usec = usec / 1000;
+  ms += usec;
+  
+  return ms;
+}
 
 void Cassandra_se_impl::start_prepare_insert(const char *key, int key_len)
 {
@@ -226,14 +242,7 @@
   cf_mut[column_family]= std::vector<Mutation>();
   insert_list= &cf_mut[column_family];
 
-  struct timeval td;
-  gettimeofday(&td, NULL);
-  int64_t ms = td.tv_sec;
-  ms = ms * 1000;
-  int64_t usec = td.tv_usec;
-  usec = usec / 1000;
-  ms += usec;
-  insert_timestamp= ms;
+  insert_timestamp= get_i64_timestamp();
 }
 
 
@@ -448,3 +457,25 @@
   return res;
 }
 
+bool Cassandra_se_impl::remove_row()
+{
+  bool res= true;
+
+  ColumnPath column_path;
+  column_path.column_family= column_family;
+
+  try {
+    
+    cass->remove(rowkey, column_path, get_i64_timestamp(), cur_consistency_level);
+    res= false;
+
+  } catch (InvalidRequestException ire) {
+    print_error("%s [%s]", ire.what(), ire.why.c_str());
+  } catch (UnavailableException ue) {
+    print_error("UnavailableException: %s", ue.what());
+  } catch (TimedOutException te) {
+    print_error("TimedOutException: %s", te.what());
+  }
+
+  return res;
+}

=== modified file 'storage/cassandra/cassandra_se.h'
--- a/storage/cassandra/cassandra_se.h	2012-08-19 08:50:53 +0000
+++ b/storage/cassandra/cassandra_se.h	2012-08-19 09:21:23 +0000
@@ -48,6 +48,8 @@
   virtual void add_read_column(const char *name)=0;
   
   virtual bool truncate()=0;
+  virtual bool remove_row()=0;
+
   /* Passing error messages up to ha_cassandra */
   char err_buffer[512];
   const char *error_str() { return err_buffer; }

=== modified file 'storage/cassandra/ha_cassandra.cc'
--- a/storage/cassandra/ha_cassandra.cc	2012-08-19 08:50:53 +0000
+++ b/storage/cassandra/ha_cassandra.cc	2012-08-19 09:21:23 +0000
@@ -625,7 +625,7 @@
                                  key_part_map keypart_map,
                                  enum ha_rkey_function find_flag)
 {
-  int rc;
+  int rc= 0;
   DBUG_ENTER("ha_cassandra::index_read_map");
   
   if (find_flag != HA_READ_KEY_EXACT)
@@ -824,9 +824,15 @@
 
 int ha_cassandra::delete_row(const uchar *buf)
 {
+  bool bres;
   DBUG_ENTER("ha_cassandra::delete_row");
-  // todo: delete the row we've just read.
-  DBUG_RETURN(HA_ERR_WRONG_COMMAND);
+  
+  bres= se->remove_row();
+  
+  if (bres)
+    my_error(ER_INTERNAL_ERROR, MYF(0), se->error_str());
+  
+  DBUG_RETURN(bres? HA_ERR_INTERNAL_ERROR: 0);
 }
 
 



More information about the commits mailing list