Search in sources :

Example 1 with FacetCount

use of com.google.refine.expr.functions.FacetCount in project OpenRefine by OpenRefine.

the class CacheTests method testIssue567.

/**
     * Test for issue 567.  Problem doesn't seem to occur when testing
     * interactively, but this demonstrates that the facet count cache
     * can get stale after row removal operations
     * 
     * @throws Exception
     */
@Test
public void testIssue567() throws Exception {
    for (int i = 0; i < 5; i++) {
        Row row = new Row(5);
        row.setCell(0, new Cell(i < 4 ? "a" : "b", null));
        project.rows.add(row);
    }
    engine.getAllRows().accept(project, new CountingRowVisitor(5));
    engine.getAllFilteredRows().accept(project, new CountingRowVisitor(4));
    Function fc = new FacetCount();
    Integer count = (Integer) fc.call(bindings, new Object[] { "a", "value", "Column A" });
    Assert.assertEquals(count.intValue(), 4);
    EngineDependentOperation op = new RowRemovalOperation(engine_config);
    op.createProcess(project, options).performImmediate();
    engine.getAllRows().accept(project, new CountingRowVisitor(1));
    engine.getAllFilteredRows().accept(project, new CountingRowVisitor(0));
    count = (Integer) fc.call(bindings, new Object[] { "a", "value", "Column A" });
    Assert.assertEquals(count.intValue(), 0);
}
Also used : RowRemovalOperation(com.google.refine.operations.row.RowRemovalOperation) Function(com.google.refine.grel.Function) EngineDependentOperation(com.google.refine.operations.EngineDependentOperation) JSONObject(org.json.JSONObject) Row(com.google.refine.model.Row) FacetCount(com.google.refine.expr.functions.FacetCount) Cell(com.google.refine.model.Cell) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest) RefineTest(com.google.refine.tests.RefineTest)

Aggregations

FacetCount (com.google.refine.expr.functions.FacetCount)1 Function (com.google.refine.grel.Function)1 Cell (com.google.refine.model.Cell)1 Row (com.google.refine.model.Row)1 EngineDependentOperation (com.google.refine.operations.EngineDependentOperation)1 RowRemovalOperation (com.google.refine.operations.row.RowRemovalOperation)1 RefineTest (com.google.refine.tests.RefineTest)1 JSONObject (org.json.JSONObject)1 BeforeTest (org.testng.annotations.BeforeTest)1 Test (org.testng.annotations.Test)1