Merge branch 'penberg/cql3' of github.com:cloudius-systems/seastar-dev into db

More cql3 statement conversions from Pekka.
This commit is contained in:
Avi Kivity
2015-01-12 17:11:51 +02:00
8 changed files with 205 additions and 92 deletions

View File

@@ -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;
}
}

View File

@@ -18,9 +18,13 @@
#include "functions/function_call.hh"
#include "functions/uuid_fcts.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"
#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"
@@ -31,6 +35,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"

View File

@@ -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 <memory>
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<ks_prop_defs> _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<ks_prop_defs>&& 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

View File

@@ -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<ut_name> _name;
protected AlterTypeStatement(UTName name)
{
super();
this.name = name;
}
alter_type_statement(::shared_ptr<ut_name> 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

View File

@@ -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

View File

@@ -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<String, Object> properties = new HashMap<String, Object>();
@@ -140,4 +156,11 @@ public class PropertyDefinitions
}
}
}
#endif
};
}
}
#endif

View File

@@ -28,6 +28,8 @@
#include "cql3/statements/cf_statement.hh"
#include "cql3/cql_statement.hh"
#include "core/shared_ptr.hh"
#include <experimental/optional>
namespace cql3 {
@@ -37,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<use_statement> {
class schema_altering_statement : public cf_statement, public virtual cql_statement, public ::enable_shared_from_this<schema_altering_statement> {
private:
const bool _is_column_family_level;

72
cql3/ut_name.hh Normal file
View File

@@ -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 <experimental/optional>
namespace cql3 {
class ut_name final {
std::experimental::optional<sstring> _ks_name;
const ::shared_ptr<column_identifier> _ut_name;
public:
ut_name(std::experimental::optional<::shared_ptr<column_identifier>> ks_name, ::shared_ptr<column_identifier> ut_name)
: _ks_name{!ks_name ? std::experimental::optional<sstring>{} : std::experimental::optional<sstring>{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<sstring>{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