FIXED - task 432: cross() failing - flush join cache table when column changes

http://code.google.com/p/google-refine/issues/detail?id=432

git-svn-id: http://google-refine.googlecode.com/svn/trunk@2539 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
Tom Morris 2012-08-30 16:31:22 +00:00
parent 9b54a8f29e
commit 83dce305cb
8 changed files with 35 additions and 8 deletions

View File

@ -62,12 +62,11 @@ public class Cross implements Function {
toColumnName != null && toColumnName instanceof String) {
ProjectJoin join = ProjectManager.singleton.getInterProjectModel().getJoin(
ProjectManager.singleton.getProjectMetadata(
((Project) bindings.get("project")).id).getName(),
((WrappedCell) wrappedCell).columnName,
(String) toProjectName,
(String) toColumnName
);
ProjectManager.singleton.getProjectMetadata(((Project) bindings.get("project")).id).getName(),
((WrappedCell) wrappedCell).columnName,
(String) toProjectName,
(String) toColumnName
);
return join.getRows(((WrappedCell) wrappedCell).cell.value);
}

View File

@ -42,6 +42,7 @@ import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONWriter;
import com.google.refine.InterProjectModel;
import com.google.refine.Jsonizable;
import com.google.refine.model.recon.ReconConfig;
import com.google.refine.util.ParsingUtilities;
@ -111,6 +112,14 @@ public class Column implements Jsonizable {
writer.endObject();
}
/**
* Clear all cached precomputed values.
* <p>
* If you are modifying something that requires this to be called, you
* probably also need to call
* {@link InterProjectModel#flushJoinsInvolvingProjectColumn(long, String)}.
* e.g. ProjectManager.singleton.getInterProjectModel().flushJoinsInvolvingProjectColumn(project.id, column.getName())
*/
public void clearPrecomputes() {
if (_precomputes != null) {
_precomputes.clear();

View File

@ -106,6 +106,7 @@ public class Project {
logger.warn("Error signaling overlay model before disposing", e);
}
}
ProjectManager.singleton.getInterProjectModel().flushJoinsInvolvingProject(this.id);
}
public Date getLastSave(){

View File

@ -38,8 +38,10 @@ import java.io.LineNumberReader;
import java.io.Writer;
import java.util.Properties;
import com.google.refine.ProjectManager;
import com.google.refine.history.Change;
import com.google.refine.model.Cell;
import com.google.refine.model.Column;
import com.google.refine.model.Project;
import com.google.refine.util.Pool;
@ -60,14 +62,18 @@ public class CellChange implements Change {
public void apply(Project project) {
project.rows.get(row).setCell(cellIndex, newCell);
project.columnModel.getColumnByCellIndex(cellIndex).clearPrecomputes();
Column column = project.columnModel.getColumnByCellIndex(cellIndex);
column.clearPrecomputes();
ProjectManager.singleton.getInterProjectModel().flushJoinsInvolvingProjectColumn(project.id, column.getName());
}
@Override
public void revert(Project project) {
project.rows.get(row).setCell(cellIndex, oldCell);
project.columnModel.getColumnByCellIndex(cellIndex).clearPrecomputes();
Column column = project.columnModel.getColumnByCellIndex(cellIndex);
column.clearPrecomputes();
ProjectManager.singleton.getInterProjectModel().flushJoinsInvolvingProjectColumn(project.id, column.getName());
}
@Override

View File

@ -38,6 +38,7 @@ import java.io.LineNumberReader;
import java.io.Writer;
import java.util.Properties;
import com.google.refine.ProjectManager;
import com.google.refine.history.Change;
import com.google.refine.model.Project;
import com.google.refine.util.Pool;
@ -54,6 +55,7 @@ public class ColumnRenameChange extends ColumnChange {
@Override
public void apply(Project project) {
synchronized (project) {
ProjectManager.singleton.getInterProjectModel().flushJoinsInvolvingProjectColumn(project.id, _oldColumnName);
project.columnModel.getColumnByName(_oldColumnName).setName(_newColumnName);
project.columnModel.update();
}
@ -62,6 +64,7 @@ public class ColumnRenameChange extends ColumnChange {
@Override
public void revert(Project project) {
synchronized (project) {
ProjectManager.singleton.getInterProjectModel().flushJoinsInvolvingProjectColumn(project.id, _newColumnName);
project.columnModel.getColumnByName(_newColumnName).setName(_oldColumnName);
project.columnModel.update();
}

View File

@ -45,6 +45,7 @@ import java.util.Properties;
import org.json.JSONObject;
import org.json.JSONTokener;
import com.google.refine.ProjectManager;
import com.google.refine.history.Change;
import com.google.refine.model.Cell;
import com.google.refine.model.Column;
@ -126,6 +127,7 @@ public class ColumnSplitChange implements Change {
project.columnModel.allocateNewCellIndex();
}
ProjectManager.singleton.getInterProjectModel().flushJoinsInvolvingProjectColumn(project.id, _columnName);
_column = project.columnModel.getColumnByName(_columnName);
_columnIndex = project.columnModel.getColumnIndexByName(_columnName);
@ -240,6 +242,7 @@ public class ColumnSplitChange implements Change {
for (int i = 0; i < _columnNames.size(); i++) {
project.columnModel.columns.remove(_columnIndex + 1);
ProjectManager.singleton.getInterProjectModel().flushJoinsInvolvingProjectColumn(project.id, _columnNames.get(i));
}
project.columnModel.columnGroups.clear();

View File

@ -39,6 +39,7 @@ import java.io.Writer;
import java.util.List;
import java.util.Properties;
import com.google.refine.ProjectManager;
import com.google.refine.history.Change;
import com.google.refine.model.Column;
import com.google.refine.model.Project;
@ -93,6 +94,7 @@ public class MassCellChange implements Change {
if (_commonColumnName != null) {
Column column = project.columnModel.getColumnByName(_commonColumnName);
column.clearPrecomputes();
ProjectManager.singleton.getInterProjectModel().flushJoinsInvolvingProjectColumn(project.id, _commonColumnName);
}
if (_updateRowContextDependencies) {
@ -113,6 +115,7 @@ public class MassCellChange implements Change {
if (_commonColumnName != null) {
Column column = project.columnModel.getColumnByName(_commonColumnName);
column.clearPrecomputes();
ProjectManager.singleton.getInterProjectModel().flushJoinsInvolvingProjectColumn(project.id, _commonColumnName);
}
if (_updateRowContextDependencies) {

View File

@ -42,6 +42,7 @@ import java.io.Writer;
import java.util.List;
import java.util.Properties;
import com.google.refine.ProjectManager;
import com.google.refine.history.Change;
import com.google.refine.model.Column;
import com.google.refine.model.Project;
@ -108,6 +109,7 @@ public class ReconChange extends MassCellChange {
column.setReconStats(_newReconStats);
column.clearPrecomputes();
ProjectManager.singleton.getInterProjectModel().flushJoinsInvolvingProjectColumn(project.id, _commonColumnName);
}
}
@ -121,6 +123,7 @@ public class ReconChange extends MassCellChange {
column.setReconStats(_oldReconStats);
column.clearPrecomputes();
ProjectManager.singleton.getInterProjectModel().flushJoinsInvolvingProjectColumn(project.id, _commonColumnName);
}
}