From ee953e2e7f649eb4bf13bcf995e1f9dca55a8c63 Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Mon, 12 Jan 2015 15:15:02 +0200 Subject: [PATCH 1/7] cql3: Add missing include to schema_altering_statement.hh Signed-off-by: Pekka Enberg --- cql3/statements/schema_altering_statement.hh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cql3/statements/schema_altering_statement.hh b/cql3/statements/schema_altering_statement.hh index 66ce8b2f6e..57afc58b2b 100644 --- a/cql3/statements/schema_altering_statement.hh +++ b/cql3/statements/schema_altering_statement.hh @@ -28,6 +28,8 @@ #include "cql3/statements/cf_statement.hh" #include "cql3/cql_statement.hh" +#include "core/shared_ptr.hh" + #include namespace cql3 { From 92ebf7989c5a85385eca3ca652f6d8962f6e9c46 Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Mon, 12 Jan 2015 15:15:15 +0200 Subject: [PATCH 2/7] cql3: Fix shared_from_this in schema_altering_statement Signed-off-by: Pekka Enberg --- cql3/statements/schema_altering_statement.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cql3/statements/schema_altering_statement.hh b/cql3/statements/schema_altering_statement.hh index 57afc58b2b..efbf30ae50 100644 --- a/cql3/statements/schema_altering_statement.hh +++ b/cql3/statements/schema_altering_statement.hh @@ -39,7 +39,7 @@ namespace statements { /** * Abstract class for statements that alter the schema. */ -class schema_altering_statement : public cf_statement, public virtual cql_statement, public ::enable_shared_from_this { +class schema_altering_statement : public cf_statement, public virtual cql_statement, public ::enable_shared_from_this { private: const bool _is_column_family_level; From ff714bdd35134f9859b9ff5864fd3584f5bcfe13 Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Mon, 12 Jan 2015 15:20:59 +0200 Subject: [PATCH 3/7] cql3: Convert PropertyDefinitions to C++ Signed-off-by: Pekka Enberg --- cql3/cql3.cc | 1 + ...finitions.java => property_definitions.hh} | 27 +++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) rename cql3/statements/{PropertyDefinitions.java => property_definitions.hh} (94%) diff --git a/cql3/cql3.cc b/cql3/cql3.cc index 61e21890a3..fcdd6b0a6f 100644 --- a/cql3/cql3.cc +++ b/cql3/cql3.cc @@ -20,6 +20,7 @@ #include "statements/cf_statement.hh" #include "statements/use_statement.hh" #include "statements/parsed_statement.hh" +#include "statements/property_definitions.hh" #include "statements/truncate_statement.hh" #include "statements/schema_altering_statement.hh" #include "cql_statement.hh" diff --git a/cql3/statements/PropertyDefinitions.java b/cql3/statements/property_definitions.hh similarity index 94% rename from cql3/statements/PropertyDefinitions.java rename to cql3/statements/property_definitions.hh index 793285bbdb..583e62accc 100644 --- a/cql3/statements/PropertyDefinitions.java +++ b/cql3/statements/property_definitions.hh @@ -15,6 +15,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +/* + * Copyright 2015 Cloudius Systems + * + * Modified by Cloudius Systems + */ + +#ifndef CQL3_STATEMENTS_PROPERTY_DEFINITIONS_HH +#define CQL3_STATEMENTS_PROPERTY_DEFINITIONS_HH + +namespace cql3 { + +namespace statements { + +#if 0 package org.apache.cassandra.cql3.statements; import java.util.*; @@ -23,9 +38,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.apache.cassandra.exceptions.SyntaxException; +#endif -public class PropertyDefinitions -{ +class property_definitions { +#if 0 protected static final Logger logger = LoggerFactory.getLogger(PropertyDefinitions.class); protected final Map properties = new HashMap(); @@ -140,4 +156,11 @@ public class PropertyDefinitions } } } +#endif +}; + } + +} + +#endif From db12a1ac2db4cd14e063f4dc477490f4ac3b86c0 Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Mon, 12 Jan 2015 15:16:35 +0200 Subject: [PATCH 4/7] cql3: Convert KSPropDefs to C++ Signed-off-by: Pekka Enberg --- cql3/cql3.cc | 1 + .../{KSPropDefs.java => ks_prop_defs.hh} | 29 +++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) rename cql3/statements/{KSPropDefs.java => ks_prop_defs.hh} (90%) diff --git a/cql3/cql3.cc b/cql3/cql3.cc index fcdd6b0a6f..2377f51e74 100644 --- a/cql3/cql3.cc +++ b/cql3/cql3.cc @@ -18,6 +18,7 @@ #include "functions/function_call.hh" #include "statements/cf_statement.hh" +#include "statements/ks_prop_defs.hh" #include "statements/use_statement.hh" #include "statements/parsed_statement.hh" #include "statements/property_definitions.hh" diff --git a/cql3/statements/KSPropDefs.java b/cql3/statements/ks_prop_defs.hh similarity index 90% rename from cql3/statements/KSPropDefs.java rename to cql3/statements/ks_prop_defs.hh index 7c054351df..4806368053 100644 --- a/cql3/statements/KSPropDefs.java +++ b/cql3/statements/ks_prop_defs.hh @@ -15,15 +15,33 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +/* + * Copyright 2015 Cloudius Systems + * + * Modified by Cloudius Systems + */ + +#ifndef CQL3_STATEMENTS_KS_PROP_DEFS_HH +#define CQL3_STATEMENTS_KS_PROP_DEFS_HH + +#include "cql3/statements/property_definitions.hh" + +namespace cql3 { + +namespace statements { + +#if 0 package org.apache.cassandra.cql3.statements; import java.util.*; import org.apache.cassandra.config.KSMetaData; import org.apache.cassandra.exceptions.*; +#endif -public class KSPropDefs extends PropertyDefinitions -{ +class ks_prop_defs : public property_definitions { +#if 0 public static final String KW_DURABLE_WRITES = "durable_writes"; public static final String KW_REPLICATION = "replication"; @@ -86,4 +104,11 @@ public class KSPropDefs extends PropertyDefinitions } return KSMetaData.newKeyspace(old.name, sClass, sOptions, getBoolean(KW_DURABLE_WRITES, old.durableWrites)); } +#endif +}; + } + +} + +#endif From dc7646a0c4a8aa2fa81d6a879ec790561d13806b Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Mon, 12 Jan 2015 15:13:11 +0200 Subject: [PATCH 5/7] cql3: Convert AlterKeyspaceStatement to C++ Signed-off-by: Pekka Enberg --- cql3/cql3.cc | 1 + ...ement.java => alter_keyspace_statement.hh} | 55 ++++++++++++++----- 2 files changed, 41 insertions(+), 15 deletions(-) rename cql3/statements/{AlterKeyspaceStatement.java => alter_keyspace_statement.hh} (83%) diff --git a/cql3/cql3.cc b/cql3/cql3.cc index 2377f51e74..7ee18efa0b 100644 --- a/cql3/cql3.cc +++ b/cql3/cql3.cc @@ -17,6 +17,7 @@ #include "functions/time_uuid_fcts.hh" #include "functions/function_call.hh" +#include "statements/alter_keyspace_statement.hh" #include "statements/cf_statement.hh" #include "statements/ks_prop_defs.hh" #include "statements/use_statement.hh" diff --git a/cql3/statements/AlterKeyspaceStatement.java b/cql3/statements/alter_keyspace_statement.hh similarity index 83% rename from cql3/statements/AlterKeyspaceStatement.java rename to cql3/statements/alter_keyspace_statement.hh index 50c3f00c78..1a28ddb71c 100644 --- a/cql3/statements/AlterKeyspaceStatement.java +++ b/cql3/statements/alter_keyspace_statement.hh @@ -15,6 +15,26 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +/* + * Copyright 2015 Cloudius Systems + * + * Modified by Cloudius Systems + */ + +#ifndef CQL3_STATEMENTS_ALTER_KEYSPACE_STATEMENT_HH +#define CQL3_STATEMENTS_ALTER_KEYSPACE_STATEMENT_HH + +#include "cql3/statements/schema_altering_statement.hh" +#include "cql3/statements/ks_prop_defs.hh" + +#include + +namespace cql3 { + +namespace statements { + +#if 0 package org.apache.cassandra.cql3.statements; import org.apache.cassandra.auth.Permission; @@ -28,25 +48,23 @@ import org.apache.cassandra.service.ClientState; import org.apache.cassandra.service.MigrationManager; import org.apache.cassandra.service.StorageService; import org.apache.cassandra.transport.Event; +#endif -public class AlterKeyspaceStatement extends SchemaAlteringStatement -{ - private final String name; - private final KSPropDefs attrs; +class alter_keyspace_statement : public schema_altering_statement { + sstring _name; + std::unique_ptr _attrs; - public AlterKeyspaceStatement(String name, KSPropDefs attrs) - { - super(); - this.name = name; - this.attrs = attrs; - } - - @Override - public String keyspace() - { - return name; +public: + alter_keyspace_statement(sstring name, std::unique_ptr&& attrs) + : _name{name} + , _attrs{std::move(attrs)} + { } + + virtual sstring keyspace() const override { + return _name; } +#if 0 public void checkAccess(ClientState state) throws UnauthorizedException, InvalidRequestException { state.hasKeyspaceAccess(name, Permission.ALTER); @@ -94,4 +112,11 @@ public class AlterKeyspaceStatement extends SchemaAlteringStatement { return new Event.SchemaChange(Event.SchemaChange.Change.UPDATED, keyspace()); } +#endif +}; + } + +} + +#endif From 9838901b387d47fa95037c5655f4e2f9ebd8f996 Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Mon, 12 Jan 2015 15:27:55 +0200 Subject: [PATCH 6/7] cql3: Convert UTName to C++ Signed-off-by: Pekka Enberg --- cql3/UTName.java | 63 ------------------------------------------ cql3/cql3.cc | 1 + cql3/ut_name.hh | 72 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 63 deletions(-) delete mode 100644 cql3/UTName.java create mode 100644 cql3/ut_name.hh diff --git a/cql3/UTName.java b/cql3/UTName.java deleted file mode 100644 index c8567977bd..0000000000 --- a/cql3/UTName.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.cassandra.cql3; - -import java.nio.ByteBuffer; - -public class UTName -{ - private String ksName; - private final ColumnIdentifier utName; - - public UTName(ColumnIdentifier ksName, ColumnIdentifier utName) - { - this.ksName = ksName == null ? null : ksName.toString(); - this.utName = utName; - } - - public boolean hasKeyspace() - { - return ksName != null; - } - - public void setKeyspace(String keyspace) - { - this.ksName = keyspace; - } - - public String getKeyspace() - { - return ksName; - } - - public ByteBuffer getUserTypeName() - { - return utName.bytes; - } - - public String getStringTypeName() - { - return utName.toString(); - } - - @Override - public String toString() - { - return (hasKeyspace() ? (ksName + ".") : "") + utName; - } -} diff --git a/cql3/cql3.cc b/cql3/cql3.cc index 7ee18efa0b..209016aa28 100644 --- a/cql3/cql3.cc +++ b/cql3/cql3.cc @@ -33,6 +33,7 @@ #include "column_identifier.hh" #include "column_specification.hh" #include "cf_name.hh" +#include "ut_name.hh" #include "abstract_marker.hh" #include "assignment_testable.hh" diff --git a/cql3/ut_name.hh b/cql3/ut_name.hh new file mode 100644 index 0000000000..752e8c596f --- /dev/null +++ b/cql3/ut_name.hh @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2015 Cloudius Systems + * + * Modified by Cloudius Systems + */ + +#ifndef CQL3_UT_NAME_HH +#define CQL3_UT_NAME_HH + +#include "core/shared_ptr.hh" + +#include + +namespace cql3 { + +class ut_name final { + std::experimental::optional _ks_name; + const ::shared_ptr _ut_name; + +public: + ut_name(std::experimental::optional<::shared_ptr> ks_name, ::shared_ptr ut_name) + : _ks_name{!ks_name ? std::experimental::optional{} : std::experimental::optional{ks_name.value()->to_string()}} + , _ut_name{ut_name} + { } + + bool has_keyspace() const { + return _ks_name ? true : false; + } + + void set_keyspace(sstring keyspace) { + _ks_name = std::experimental::optional{keyspace}; + } + + sstring get_keyspace() const { + return _ks_name.value(); + } + + bytes get_user_type_name() const { + return _ut_name->bytes_; + } + + sstring get_string_type_name() const + { + return _ut_name->to_string(); + } + + sstring to_string() const { + return (has_keyspace() ? (_ks_name.value() + ".") : "") + _ut_name->to_string(); + } +}; + +} + +#endif From d1969c01583f1dbd92e1e3e9678daff52aa0ec59 Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Mon, 12 Jan 2015 15:41:31 +0200 Subject: [PATCH 7/7] cql3: Convert AlterTypeStatement to C++ Signed-off-by: Pekka Enberg --- cql3/cql3.cc | 1 + ...Statement.java => alter_type_statement.hh} | 42 +++++++++++++++---- 2 files changed, 34 insertions(+), 9 deletions(-) rename cql3/statements/{AlterTypeStatement.java => alter_type_statement.hh} (96%) diff --git a/cql3/cql3.cc b/cql3/cql3.cc index 209016aa28..c8d5a2ae07 100644 --- a/cql3/cql3.cc +++ b/cql3/cql3.cc @@ -18,6 +18,7 @@ #include "functions/function_call.hh" #include "statements/alter_keyspace_statement.hh" +#include "statements/alter_type_statement.hh" #include "statements/cf_statement.hh" #include "statements/ks_prop_defs.hh" #include "statements/use_statement.hh" diff --git a/cql3/statements/AlterTypeStatement.java b/cql3/statements/alter_type_statement.hh similarity index 96% rename from cql3/statements/AlterTypeStatement.java rename to cql3/statements/alter_type_statement.hh index 576011fd50..6947a55885 100644 --- a/cql3/statements/AlterTypeStatement.java +++ b/cql3/statements/alter_type_statement.hh @@ -15,8 +15,25 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.cassandra.cql3.statements; +/* + * Copyright 2015 Cloudius Systems + * + * Modified by Cloudius Systems + */ + +#ifndef CQL_STATEMENTS_ALTER_TYPE_STATEMENT_HH +#define CQL_STATEMENTS_ALTER_TYPE_STATEMENT_HH + +#include "cql3/ut_name.hh" + +#include "core/shared_ptr.hh" + +namespace cql3 { + +namespace statements { + +#if 0 import java.nio.ByteBuffer; import java.util.*; @@ -29,17 +46,17 @@ import org.apache.cassandra.exceptions.*; import org.apache.cassandra.service.ClientState; import org.apache.cassandra.service.MigrationManager; import org.apache.cassandra.transport.Event; +#endif -public abstract class AlterTypeStatement extends SchemaAlteringStatement -{ - protected final UTName name; +class alter_type_statement : public schema_altering_statement { +protected: + const ::shared_ptr _name; - protected AlterTypeStatement(UTName name) - { - super(); - this.name = name; - } + alter_type_statement(::shared_ptr name) + : _name{name} + { } +#if 0 @Override public void prepareKeyspace(ClientState state) throws InvalidRequestException { @@ -345,4 +362,11 @@ public abstract class AlterTypeStatement extends SchemaAlteringStatement } } +#endif +}; + } + +} + +#endif