Skip to content

Commit

Permalink
Make AccumuloTable immutable
Browse files Browse the repository at this point in the history
  • Loading branch information
adamjshook authored and electrum committed Oct 19, 2016
1 parent 8215a39 commit 489f28d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,14 @@ public void renameTable(SchemaTableName oldName, SchemaTableName newName)
throw new TableNotFoundException(oldName);
}

AccumuloTable newTable = oldTable.clone();
newTable.setTable(newName.getTableName());
AccumuloTable newTable = new AccumuloTable(
oldTable.getSchema(),
newName.getTableName(),
oldTable.getColumns(),
oldTable.getRowId(),
oldTable.isExternal(),
oldTable.getSerializerClassName(),
oldTable.getScanAuthorizations());

// Validate table existence
if (!tableManager.exists(oldTable.getFullTableName())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.google.common.collect.ImmutableList;

import java.lang.reflect.InvocationTargetException;
Expand All @@ -46,10 +45,9 @@ public class AccumuloTable
private final List<ColumnMetadata> columnsMetadata;
private final boolean indexed;
private final List<AccumuloColumnHandle> columns;

private String rowId;
private String table;
private SchemaTableName schemaTableName;
private final String rowId;
private final String table;
private final SchemaTableName schemaTableName;

@JsonCreator
public AccumuloTable(
Expand Down Expand Up @@ -100,12 +98,6 @@ public String getRowId()
return rowId;
}

@JsonSetter
public void setRowId(String rowId)
{
this.rowId = rowId;
}

@JsonProperty
public String getSchema()
{
Expand All @@ -118,12 +110,6 @@ public String getTable()
return table;
}

public void setTable(String table)
{
this.table = table;
this.schemaTableName = new SchemaTableName(getSchema(), getTable());
}

@JsonIgnore
public String getIndexTableName()
{
Expand Down Expand Up @@ -207,13 +193,6 @@ public static String getFullTableName(SchemaTableName tableName)
return getFullTableName(tableName.getSchemaName(), tableName.getTableName());
}

@Override
@JsonIgnore
public AccumuloTable clone()
{
return new AccumuloTable(getSchema(), getTable(), getColumns(), getRowId(), isExternal(), getSerializerClassName(), getScanAuthorizations());
}

@JsonIgnore
public SchemaTableName getSchemaTableName()
{
Expand Down

0 comments on commit 489f28d

Please sign in to comment.