-
Notifications
You must be signed in to change notification settings - Fork 46
/
CatalogScanTest.java
73 lines (60 loc) · 1.83 KB
/
CatalogScanTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/**
*
*/
package edu.washington.escience.myria.operator;
import static org.junit.Assert.assertEquals;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import edu.washington.escience.myria.DbException;
import edu.washington.escience.myria.Schema;
import edu.washington.escience.myria.Type;
import edu.washington.escience.myria.api.encoding.QueryEncoding;
import edu.washington.escience.myria.coordinator.catalog.CatalogException;
import edu.washington.escience.myria.coordinator.catalog.MasterCatalog;
import edu.washington.escience.myria.storage.TupleBatch;
/**
*
*/
public class CatalogScanTest {
/**
* The catalog
*/
private MasterCatalog catalog;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
/* Turn off SQLite logging, it's annoying. */
Logger.getLogger("com.almworks.sqlite4java").setLevel(Level.OFF);
catalog = MasterCatalog.createInMemory();
// add a query to the catalog
QueryEncoding query = new QueryEncoding();
query.rawQuery = "query 1 is about baseball";
query.logicalRa = "";
catalog.newQuery(query);
}
/**
* Destroy catalog.
*/
@After
public void Cleanup() {
catalog.close();
}
@Test
public final void testQueryQueries() throws DbException, CatalogException {
Schema schema = Schema.ofFields(Type.LONG_TYPE, "id", Type.STRING_TYPE, "raw");
CatalogQueryScan scan = new CatalogQueryScan("select query_id, raw_query from queries", schema, catalog);
scan.open(null);
assertEquals(false, scan.eos());
TupleBatch tb = scan.nextReady();
assertEquals(false, scan.eos());
assertEquals(1, tb.numTuples());
assertEquals(schema, tb.getSchema());
tb = scan.nextReady();
assertEquals(true, scan.eos());
}
}