mirror of
https://github.com/MariaDB/server.git
synced 2025-09-11 05:52:26 +03:00
Cassandra SE: added support for boolean type.
This commit is contained in:
@@ -266,3 +266,13 @@ rowkey col1
|
||||
9b5658dc-f32f-11e1-94cd-f46d046e9f09 1234
|
||||
delete from t2;
|
||||
drop table t2;
|
||||
CREATE TABLE t2 (rowkey int PRIMARY KEY, boolcol varchar(12)) ENGINE=CASSANDRA
|
||||
thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf7';
|
||||
insert into t2 values (0, 0);
|
||||
insert into t2 values (1, 1);
|
||||
select * from t2;
|
||||
rowkey boolcol
|
||||
0 0
|
||||
1 1
|
||||
delete from t2;
|
||||
drop table t2;
|
||||
|
@@ -53,6 +53,8 @@ create columnfamily cf5 (rowkey bigint primary key, uuidcol uuid);
|
||||
|
||||
create columnfamily cf6 (rowkey uuid primary key, col1 int);
|
||||
|
||||
create columnfamily cf7 (rowkey int primary key, boolcol boolean);
|
||||
|
||||
./cassandra-cli
|
||||
|
||||
CREATE COLUMN FAMILY cf10
|
||||
@@ -329,6 +331,16 @@ select * from t2;
|
||||
delete from t2;
|
||||
drop table t2;
|
||||
|
||||
|
||||
# create columnfamily cf7 (rowkey int primary key, boolcol boolean);
|
||||
CREATE TABLE t2 (rowkey int PRIMARY KEY, boolcol varchar(12)) ENGINE=CASSANDRA
|
||||
thrift_host='localhost' keyspace='mariadbtest2' column_family = 'cf7';
|
||||
insert into t2 values (0, 0);
|
||||
insert into t2 values (1, 1);
|
||||
select * from t2;
|
||||
delete from t2;
|
||||
drop table t2;
|
||||
|
||||
############################################################################
|
||||
## Cassandra cleanup
|
||||
############################################################################
|
||||
@@ -337,6 +349,9 @@ drop columnfamily cf1;
|
||||
drop columnfamily cf2;
|
||||
drop columnfamily cf3;
|
||||
drop columnfamily cf4;
|
||||
drop columnfamily cf5;
|
||||
drop columnfamily cf6;
|
||||
drop columnfamily cf7;
|
||||
--enable_parsing
|
||||
############################################################################
|
||||
## Cassandra cleanup ends
|
||||
|
@@ -529,6 +529,28 @@ static void flip32(const char *from, char* to)
|
||||
to[3]= from[0];
|
||||
}
|
||||
|
||||
|
||||
class TinyintDataConverter : public ColumnDataConverter
|
||||
{
|
||||
char buf;
|
||||
public:
|
||||
void cassandra_to_mariadb(const char *cass_data, int cass_data_len)
|
||||
{
|
||||
DBUG_ASSERT(cass_data_len == 1);
|
||||
field->store(cass_data[0]);
|
||||
}
|
||||
|
||||
bool mariadb_to_cassandra(char **cass_data, int *cass_data_len)
|
||||
{
|
||||
buf= field->val_int()? 1 : 0; /* TODO: error handling? */
|
||||
*cass_data= (char*)&buf;
|
||||
*cass_data_len= 1;
|
||||
return false;
|
||||
}
|
||||
~TinyintDataConverter(){}
|
||||
};
|
||||
|
||||
|
||||
class Int32DataConverter : public ColumnDataConverter
|
||||
{
|
||||
int32_t buf;
|
||||
@@ -683,6 +705,7 @@ public:
|
||||
~UuidDataConverter(){}
|
||||
};
|
||||
|
||||
|
||||
const char * const validator_bigint= "org.apache.cassandra.db.marshal.LongType";
|
||||
const char * const validator_int= "org.apache.cassandra.db.marshal.Int32Type";
|
||||
const char * const validator_counter= "org.apache.cassandra.db.marshal.CounterColumnType";
|
||||
@@ -698,12 +721,20 @@ const char * const validator_timestamp="org.apache.cassandra.db.marshal.DateType
|
||||
|
||||
const char * const validator_uuid= "org.apache.cassandra.db.marshal.UUIDType";
|
||||
|
||||
const char * const validator_boolean= "org.apache.cassandra.db.marshal.BooleanType";
|
||||
|
||||
ColumnDataConverter *map_field_to_validator(Field *field, const char *validator_name)
|
||||
{
|
||||
ColumnDataConverter *res= NULL;
|
||||
|
||||
switch(field->type()) {
|
||||
case MYSQL_TYPE_TINY:
|
||||
if (!strcmp(validator_name, validator_boolean))
|
||||
{
|
||||
res= new TinyintDataConverter;
|
||||
break;
|
||||
}
|
||||
/* fall through: */
|
||||
case MYSQL_TYPE_SHORT:
|
||||
case MYSQL_TYPE_LONGLONG:
|
||||
if (!strcmp(validator_name, validator_bigint))
|
||||
|
Reference in New Issue
Block a user