Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
4986de84
Commit
4986de84
authored
Sep 07, 2012
by
Sergey Petrunya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cassandra SE: added support for boolean type.
parent
12ab6a4f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
0 deletions
+56
-0
mysql-test/r/cassandra.result
mysql-test/r/cassandra.result
+10
-0
mysql-test/t/cassandra.test
mysql-test/t/cassandra.test
+15
-0
storage/cassandra/ha_cassandra.cc
storage/cassandra/ha_cassandra.cc
+31
-0
No files found.
mysql-test/r/cassandra.result
View file @
4986de84
...
...
@@ -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;
mysql-test/t/cassandra.test
View file @
4986de84
...
...
@@ -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
...
...
storage/cassandra/ha_cassandra.cc
View file @
4986de84
...
...
@@ -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 @@ class UuidDataConverter : public ColumnDataConverter
~
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
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment