Skip to content

Commit

Permalink
remove a lot of unused code
Browse files Browse the repository at this point in the history
bye bye!
  • Loading branch information
mfussenegger committed Dec 2, 2014
1 parent bc3c604 commit 68d89ff
Show file tree
Hide file tree
Showing 132 changed files with 42 additions and 1,295 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ private Plan genCountStarPlan(TableInfo table) {
}

private void addColumnToTable(AddColumnAnalyzedStatement analysis, final SettableFuture<Long> result) {
boolean updateTemplate = analysis.table().isPartitioned() && !analysis.partitionName().isPresent();
boolean updateTemplate = analysis.table().isPartitioned();
final AtomicInteger operations = new AtomicInteger(updateTemplate ? 2 : 1);
final Map<String, Object> mapping = analysis.analyzedTableElements().toMapping();

Expand All @@ -211,7 +211,7 @@ private void addColumnToTable(AddColumnAnalyzedStatement analysis, final Settabl
// need to merge the _meta part of the mapping mapping before-hand because ES doesn't
// update the _meta column recursively. Instead it is overwritten and therefore partitioned by
// and collection_type information would be lost.
String[] indexNames = getIndexNames(analysis.table(), analysis.partitionName().orNull());
String[] indexNames = getIndexNames(analysis.table(), null);
if (indexNames.length == 0) {
// if there are no indices yet we can return because we don't need to update existing mapping
if (operations.decrementAndGet() == 0) {
Expand Down
13 changes: 0 additions & 13 deletions sql/src/main/java/io/crate/action/sql/TransportBaseSQLAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import io.crate.sql.tree.Statement;
import io.crate.types.DataType;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.search.ReduceSearchPhaseException;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.TransportAction;
import org.elasticsearch.cluster.ClusterService;
Expand Down Expand Up @@ -275,18 +274,6 @@ public Throwable esToCrateException(Throwable e) {
return new InvalidTableNameException(((InvalidIndexNameException) e).index().getName(), e);
} else if (e instanceof IndexMissingException) {
return new TableUnknownException(((IndexMissingException)e).index().name(), e);
} else if (e instanceof ReduceSearchPhaseException && e.getCause() instanceof VersionConflictException) {
/**
* For update or search requests we use upstream ES SearchRequests
* These requests are executed using the transportSearchAction.
*
* The transportSearchAction (or the more specific QueryThenFetch/../ Action inside it
* executes the TransportSQLAction.SearchResponseListener onResponse/onFailure
* but adds its own error handling around it.
* By doing so it wraps every exception raised inside our onResponse in its own ReduceSearchPhaseException
* Here we unwrap it to get the original exception.
*/
return e.getCause();
} else if (e instanceof org.elasticsearch.common.breaker.CircuitBreakingException) {
return new CircuitBreakingException(e.getMessage());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,4 @@ public class SQLParseSourceException extends ElasticsearchException {
public SQLParseSourceException(SQLXContentSourceContext context, String msg) {
super("Parse Failure [" + msg + "]");
}

public SQLParseSourceException(SQLXContentSourceContext context, String msg, Throwable cause) {
super("Parse Failure [" + msg + "]", cause);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ private Reference allocateReference(ReferenceIdent ident, boolean unique, boolea
}
reference = tableInfo.getDynamic(ident.columnIdent(), forWrite);
if (reference == null) {
throw new ColumnUnknownException(ident.tableIdent().name(), ident.columnIdent().fqn());
throw new ColumnUnknownException(ident.columnIdent().fqn());
}
info = reference.info();
}
Expand Down Expand Up @@ -229,10 +229,6 @@ public FunctionInfo getFunctionInfo(FunctionIdent ident) {
return functions.getSafe(ident).info();
}

public Collection<Reference> references() {
return referenceSymbols.values();
}

public Collection<Function> functions() {
return functionSymbols.values();
}
Expand Down
13 changes: 0 additions & 13 deletions sql/src/main/java/io/crate/analyze/AddColumnAnalyzedStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

import com.google.common.base.Optional;
import io.crate.PartitionName;
import io.crate.exceptions.InvalidTableNameException;
import io.crate.exceptions.SchemaUnknownException;
import io.crate.exceptions.TableUnknownException;
import io.crate.metadata.FulltextAnalyzerResolver;
Expand All @@ -38,7 +37,6 @@ public class AddColumnAnalyzedStatement extends AbstractDDLAnalyzedStatement {

private final ReferenceInfos referenceInfos;
private final FulltextAnalyzerResolver fulltextAnalyzerResolver;
private Optional<PartitionName> partitionName = Optional.absent();
private TableInfo tableInfo;
private AnalyzedTableElements analyzedTableElements;
private boolean newPrimaryKeys = false;
Expand All @@ -51,19 +49,8 @@ protected AddColumnAnalyzedStatement(ReferenceInfos referenceInfos,
this.fulltextAnalyzerResolver = fulltextAnalyzerResolver;
}

public void partitionName(@Nullable PartitionName partitionName) {
this.partitionName = Optional.fromNullable(partitionName);
}

public Optional<PartitionName> partitionName() {
return partitionName;
}

@Override
public void table(TableIdent tableIdent) {
if (!isValidTableName(tableIdent.name())) {
throw new InvalidTableNameException(tableIdent.name());
}
SchemaInfo schemaInfo = referenceInfos.getSchemaInfo(tableIdent.schema());
if (schemaInfo == null) {
throw new SchemaUnknownException(tableIdent.schema());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import io.crate.exceptions.TableUnknownException;
import io.crate.metadata.ReferenceInfos;
import io.crate.metadata.TableIdent;
import io.crate.metadata.table.ColumnPolicy;
import io.crate.metadata.table.SchemaInfo;
import io.crate.metadata.table.TableInfo;

Expand All @@ -38,7 +37,6 @@ public class AlterTableAnalyzedStatement extends AbstractDDLAnalyzedStatement {
private final ReferenceInfos referenceInfos;
private TableInfo tableInfo;
private Optional<PartitionName> partitionName = Optional.absent();
private Optional<ColumnPolicy> columnPolicy = Optional.absent();

public AlterTableAnalyzedStatement(ParameterContext parameterContext, ReferenceInfos referenceInfos) {
super(parameterContext);
Expand Down
4 changes: 2 additions & 2 deletions sql/src/main/java/io/crate/analyze/AnalyzedTableElements.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ private void validateIndexDefinitions() {
for (Map.Entry<String, Set<String>> entry : copyToMap.entrySet()) {
ColumnIdent columnIdent = ColumnIdent.fromPath(entry.getKey());
if (!columnIdents.contains(columnIdent)) {
throw new ColumnUnknownException(columnIdent.sqlFqn());
throw new ColumnUnknownException(columnIdent.fqn());
}
if (!columnTypes.get(columnIdent).equalsIgnoreCase("string")) {
throw new IllegalArgumentException("INDEX definition only support 'string' typed source columns");
Expand Down Expand Up @@ -268,7 +268,7 @@ public void changeToPartitionedByColumn(ColumnIdent partitionedByIdent, boolean
if (skipIfNotFound) {
return;
}
throw new ColumnUnknownException(partitionedByIdent.sqlFqn());
throw new ColumnUnknownException(partitionedByIdent.fqn());
}
if (columnDefinition.dataType().equals("object")) {
throw new IllegalArgumentException(String.format(Locale.ENGLISH,
Expand Down
30 changes: 0 additions & 30 deletions sql/src/main/java/io/crate/analyze/BlobTableAnalyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,11 @@
package io.crate.analyze;

import com.google.common.base.Preconditions;
import io.crate.core.NumberOfReplicas;
import io.crate.metadata.TableIdent;
import io.crate.metadata.blob.BlobSchemaInfo;
import io.crate.sql.tree.Expression;
import io.crate.sql.tree.GenericProperties;
import io.crate.sql.tree.Table;

import java.util.List;
import java.util.Locale;
import java.util.Map;

public abstract class BlobTableAnalyzer<TypeAnalysis extends AnalyzedStatement>
extends AbstractStatementAnalyzer<Void, TypeAnalysis> {
Expand All @@ -50,29 +45,4 @@ protected static TableIdent tableToIdent(Table table) {
assert tableNameParts.size() == 1;
return new TableIdent(BlobSchemaInfo.NAME, tableNameParts.get(0));
}

protected static NumberOfReplicas extractNumberOfReplicas(
GenericProperties genericProperties,
Object[] parameters) {
Map<String,Expression> properties = genericProperties.properties();
Expression number_of_replicas = properties.remove("number_of_replicas");

NumberOfReplicas numberOfReplicas = null;
if (number_of_replicas != null) {
try {
Integer numReplicas = ExpressionToNumberVisitor.convert(number_of_replicas, parameters).intValue();
numberOfReplicas = new NumberOfReplicas(numReplicas);
} catch (IllegalArgumentException e) {
String numReplicas = ExpressionToObjectVisitor.convert(number_of_replicas, parameters).toString();
numberOfReplicas = new NumberOfReplicas(numReplicas);
}
}

if (properties.size() > 0) {
throw new IllegalArgumentException(
String.format(Locale.ENGLISH, "Invalid properties \"%s\" passed to [ALTER | CREATE] BLOB TABLE statement",
properties.keySet()));
}
return numberOfReplicas;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,6 @@ public String extendedAnalyzerName() {
return extendedAnalyzerName;
}

@Nullable
public Settings extendedCustomAnalyzer() {
return extendedCustomAnalyzer;
}

public void tokenDefinition(String name, Settings settings) {
tokenizerDefinition = new Tuple<>(name, settings);
}
Expand All @@ -117,10 +112,6 @@ public Tuple<String, Settings> tokenizerDefinition() {
return tokenizerDefinition;
}

public void genericAnalyzerSettings(Settings settings) {
genericAnalyzerSettings = settings;
}

public Settings genericAnalyzerSettings() {
if (genericAnalyzerSettings == null) {
genericAnalyzerSettings = genericAnalyzerSettingsBuilder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,9 @@

import io.crate.metadata.TableIdent;
import io.crate.metadata.table.TableInfo;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings;

public class CreateBlobTableAnalyzedStatement extends AbstractDDLAnalyzedStatement {

private final ImmutableSettings.Builder indexSettingsBuilder = ImmutableSettings.builder();

private Settings builtSettings;

public CreateBlobTableAnalyzedStatement(ParameterContext parameterContext) {
super(parameterContext);
Expand Down
35 changes: 0 additions & 35 deletions sql/src/main/java/io/crate/analyze/Normalizable.java

This file was deleted.

20 changes: 1 addition & 19 deletions sql/src/main/java/io/crate/analyze/PrimaryKeyVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import io.crate.types.DataTypes;
import io.crate.types.LongType;
import io.crate.types.SetType;
import org.apache.lucene.util.BytesRef;

import javax.annotation.Nullable;
import java.util.*;
Expand All @@ -60,9 +59,6 @@
*/
public class PrimaryKeyVisitor extends SymbolVisitor<PrimaryKeyVisitor.Context, Symbol> {

public static final BytesRef EMPTY_BYTESREF = new BytesRef("");
public static final byte ASCII_COMMA = (byte) 0x2c;

private static final ImmutableSet<String> logicalBinaryExpressions = ImmutableSet.of(
AndOperator.NAME, OrOperator.NAME
);
Expand All @@ -74,7 +70,6 @@ public class PrimaryKeyVisitor extends SymbolVisitor<PrimaryKeyVisitor.Context,
public static class Context {

private final TableInfo table;
private Symbol whereClause;
private final ArrayList<KeyBucket> buckets;

private KeyBucket currentBucket;
Expand Down Expand Up @@ -114,19 +109,6 @@ public Literal clusteredByLiteral() {
return clusteredBy;
}

@Nullable
public BytesRef clusteredBy() {
if (clusteredBy != null) {
return BytesRefValueSymbolVisitor.INSTANCE.process(clusteredBy);
}
return null;
}


public Symbol whereClause() {
return whereClause;
}

void newBucket() {
currentBucket = new KeyBucket(table.primaryKey().size());
buckets.add(currentBucket);
Expand Down Expand Up @@ -204,7 +186,7 @@ private static class KeyBucket {
public Context process(TableInfo tableInfo, Symbol whereClause) {
if (tableInfo.primaryKey().size() > 0 || tableInfo.clusteredBy() != null) {
Context context = new Context(tableInfo);
context.whereClause = process(whereClause, context);
process(whereClause, context);
context.finish();
return context;
}
Expand Down
4 changes: 0 additions & 4 deletions sql/src/main/java/io/crate/analyze/SetAnalyzedStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ public boolean isPersistent() {
return persistent;
}

public boolean isTransient() {
return !persistent;
}

public boolean isReset() {
return isReset;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,12 @@

public class AlterTableAliasException extends ValidationException {

private String aliasName;

public AlterTableAliasException(String aliasName) {
super("Alter table using a table alias is not supported");
this.aliasName = aliasName;
public AlterTableAliasException(String tableAlias) {
super(String.format("Alter table using a \"%s\" as table alias is not supported", tableAlias));
}

@Override
public int errorCode() {
return 5;
}

@Override
public Object[] args() {
return new Object[]{aliasName};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,12 @@

public class AmbiguousColumnAliasException extends ValidationException {

private final String alias;

public AmbiguousColumnAliasException(String alias) {
super(String.format("Column alias \"%s\" is ambiguous", alias));
this.alias = alias;
}

@Override
public int errorCode() {
return 6;
}

@Override
public Object[] args() {
return new Object[]{alias};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,4 @@ public AnalyzerInvalidException(String reason) {
public int errorCode() {
return 1;
}

@Override
public Object[] args() {
return new Object[0];
}

}
Loading

0 comments on commit 68d89ff

Please sign in to comment.