From ead2e3cff3936967a8666770c4fb7db8d27ec36a Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Wed, 21 Jan 2015 15:28:10 +0200 Subject: [PATCH 1/3] cql3: Cql.g native types Signed-off-by: Pekka Enberg --- cql3/Cql.g | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/cql3/Cql.g b/cql3/Cql.g index 53550dbc67..d76928c250 100644 --- a/cql3/Cql.g +++ b/cql3/Cql.g @@ -27,6 +27,7 @@ options { @parser::includes { #include "cql3/statements/use_statement.hh" +#include "cql3/cql3_type.hh" #include "cql3/cf_name.hh" #include "core/sstring.hh" #include "CqlLexer.hpp" @@ -1276,26 +1277,32 @@ comparatorType returns [CQL3Type.Raw t] } } ; +#endif -native_type returns [CQL3Type t] - : K_ASCII { $t = CQL3Type.Native.ASCII; } - | K_BIGINT { $t = CQL3Type.Native.BIGINT; } - | K_BLOB { $t = CQL3Type.Native.BLOB; } - | K_BOOLEAN { $t = CQL3Type.Native.BOOLEAN; } +native_type returns [shared_ptr t] + : K_ASCII { $t = native_cql3_type::ascii; } + | K_BIGINT { $t = native_cql3_type::bigint; } + | K_BLOB { $t = native_cql3_type::blob; } + | K_BOOLEAN { $t = native_cql3_type::boolean; } +#if 0 | K_COUNTER { $t = CQL3Type.Native.COUNTER; } | K_DECIMAL { $t = CQL3Type.Native.DECIMAL; } | K_DOUBLE { $t = CQL3Type.Native.DOUBLE; } | K_FLOAT { $t = CQL3Type.Native.FLOAT; } | K_INET { $t = CQL3Type.Native.INET;} - | K_INT { $t = CQL3Type.Native.INT; } - | K_TEXT { $t = CQL3Type.Native.TEXT; } - | K_TIMESTAMP { $t = CQL3Type.Native.TIMESTAMP; } - | K_UUID { $t = CQL3Type.Native.UUID; } - | K_VARCHAR { $t = CQL3Type.Native.VARCHAR; } +#endif + | K_INT { $t = native_cql3_type::int_; } + | K_TEXT { $t = native_cql3_type::text; } + | K_TIMESTAMP { $t = native_cql3_type::timestamp; } + | K_UUID { $t = native_cql3_type::uuid; } + | K_VARCHAR { $t = native_cql3_type::varchar; } +#if 0 | K_VARINT { $t = CQL3Type.Native.VARINT; } - | K_TIMEUUID { $t = CQL3Type.Native.TIMEUUID; } +#endif + | K_TIMEUUID { $t = native_cql3_type::timeuuid; } ; +#if 0 collection_type returns [CQL3Type.Raw pt] : K_MAP '<' t1=comparatorType ',' t2=comparatorType '>' { From a88c49ede8b9675e105ad4669910105686f73d91 Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Wed, 21 Jan 2015 15:37:01 +0200 Subject: [PATCH 2/3] cql3: Make column_identifier instantiable The class inherits from abstract base class selectable so there's methods that we need to define. Signed-off-by: Pekka Enberg --- cql3/column_identifier.hh | 9 +++++---- cql3/selection/selectable.hh | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cql3/column_identifier.hh b/cql3/column_identifier.hh index 38507f88bd..0c43a70b32 100644 --- a/cql3/column_identifier.hh +++ b/cql3/column_identifier.hh @@ -162,9 +162,8 @@ public: } } + virtual ::shared_ptr prepare(::shared_ptr cfm) override { #if 0 - public ColumnIdentifier prepare(CFMetaData cfm) - { AbstractType comparator = cfm.comparator.asAbstractType(); if (cfm.getIsDense() || comparator instanceof CompositeType || comparator instanceof UTF8Type) return new ColumnIdentifier(text, true); @@ -179,13 +178,15 @@ public: return new ColumnIdentifier(text, true); } return new ColumnIdentifier(comparator.fromString(rawText), text); +#endif + throw std::runtime_error("not implemented"); } - public boolean processesSelection() - { + virtual bool processes_selection() const override { return false; } +#if 0 @Override public final int hashCode() { diff --git a/cql3/selection/selectable.hh b/cql3/selection/selectable.hh index 41be969d66..5441cf4eb0 100644 --- a/cql3/selection/selectable.hh +++ b/cql3/selection/selectable.hh @@ -74,7 +74,7 @@ public: /** * Returns true if any processing is performed on the selected column. **/ - virtual bool processesSelection() = 0; + virtual bool processes_selection() const = 0; }; #if 0 From 111f5415365ba13b112bf577979b8a972299387a Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Wed, 21 Jan 2015 15:36:48 +0200 Subject: [PATCH 3/3] cql3: Cql.g column identifiers Signed-off-by: Pekka Enberg --- cql3/Cql.g | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cql3/Cql.g b/cql3/Cql.g index d76928c250..0c77509a52 100644 --- a/cql3/Cql.g +++ b/cql3/Cql.g @@ -949,18 +949,22 @@ userOptions[UserOptions opts] userOption[UserOptions opts] : k=K_PASSWORD v=STRING_LITERAL { opts.put($k.text, $v.text); } ; +#endif /** DEFINITIONS **/ // Column Identifiers. These need to be treated differently from other // identifiers because the underlying comparator is not necessarily text. See // CASSANDRA-8178 for details. -cident returns [ColumnIdentifier.Raw id] - : t=IDENT { $id = new ColumnIdentifier.Raw($t.text, false); } +cident returns [shared_ptr id] + : t=IDENT { $id = make_shared(sstring{$t.text}, false); } +#if 0 | t=QUOTED_NAME { $id = new ColumnIdentifier.Raw($t.text, true); } | k=unreserved_keyword { $id = new ColumnIdentifier.Raw(k, false); } +#endif ; +#if 0 // Identifiers that do not refer to columns or where the comparator is known to be text ident returns [ColumnIdentifier id] : t=IDENT { $id = new ColumnIdentifier($t.text, false); }