/** * {@inheritDoc} */ @Override public Set<Object> getComponentsForQuery(Query q) { try { return SqlGenerator.findTableNames(q, getSchema(), true); } catch (ObjectStoreException e) { throw new RuntimeException(e); } }
/** * {@inheritDoc} */ @Override public Set<Object> getComponentsForQuery(Query q) { try { return SqlGenerator.findTableNames(q, getSchema(), true); } catch (ObjectStoreException e) { throw new RuntimeException(e); } }
/** * Sets up the instance variables * * @throws BuildException if something is wrong */ public void setUp() { if (alias == null && objectStore == null) { throw new BuildException("exactly one of alias and objectStore must be set"); } if (objectStore == null) { try { objectStore = ObjectStoreFactory.getObjectStore(alias); } catch (Exception e) { throw new BuildException("Exception while creating ObjectStore", e); } } if (objectStore instanceof ObjectStoreInterMineImpl) { ObjectStoreInterMineImpl osii = ((ObjectStoreInterMineImpl) objectStore); database = osii.getDatabase(); schema = osii.getSchema(); } else { // change comment on setAlias() when this changes throw new BuildException("the alias (" + alias + ") does not refer to an " + "ObjectStoreInterMineImpl"); } }
/** * Sets up the instance variables * * @throws BuildException if something is wrong */ public void setUp() { if (alias == null && objectStore == null) { throw new BuildException("exactly one of alias and objectStore must be set"); } if (objectStore == null) { try { objectStore = ObjectStoreFactory.getObjectStore(alias); } catch (Exception e) { throw new BuildException("Exception while creating ObjectStore", e); } } if (objectStore instanceof ObjectStoreInterMineImpl) { ObjectStoreInterMineImpl osii = ((ObjectStoreInterMineImpl) objectStore); database = osii.getDatabase(); schema = osii.getSchema(); } else { // change comment on setAlias() when this changes throw new BuildException("the alias (" + alias + ") does not refer to an " + "ObjectStoreInterMineImpl"); } }
protected DatabaseSchema getSchema() throws Exception { DatabaseSchema schema = ((ObjectStoreInterMineImpl) ObjectStoreFactory.getObjectStore("os.notxmlunittest")).getSchema(); return schema; } public String getRegisterOffset1() {
protected DatabaseSchema getSchema() throws Exception { return ((ObjectStoreInterMineImpl) ObjectStoreFactory.getObjectStore("os.flatmodeunittest")).getSchema(); }
new HashMap<String, QuerySelectable>(), bqr, null); String sqlString = SqlGenerator.generate(q, 0, Integer.MAX_VALUE, ((ObjectStoreInterMineImpl) productionOs).getSchema(), ((ObjectStoreInterMineImpl) productionOs).getDatabase(), (Map<Object, String>) null);
protected DatabaseSchema getSchema() throws Exception { return ((ObjectStoreInterMineImpl) ObjectStoreFactory.getObjectStore("os.unittest")).getSchema(); }
protected DatabaseSchema getSchema() throws Exception { return ((ObjectStoreInterMineImpl) ObjectStoreFactory.getObjectStore("os.truncunittest")).getSchema(); }
schema = ((ObjectStoreInterMineImpl) os).getSchema(); limitedContext = ((ObjectStoreInterMineImpl) os).limitedContext; description = "Writer(" + ((ObjectStoreInterMineImpl) os).description + ")";
new HashMap<String, QuerySelectable>(), bqr, null); String sqlString = SqlGenerator.generate(q, 0, Integer.MAX_VALUE, ((ObjectStoreInterMineImpl) productionOs).getSchema(), ((ObjectStoreInterMineImpl) productionOs).getDatabase(), (Map<Object, String>) null);
schema = ((ObjectStoreInterMineImpl) os).getSchema(); limitedContext = ((ObjectStoreInterMineImpl) os).limitedContext; description = "Writer(" + ((ObjectStoreInterMineImpl) os).description + ")";
getSchema().isMissingNotXml()); if ((subQ.getFrom().size() > 1) && (subQ.getConstraint() == null)) { LOG.error("Software bug - we are being asked to precompute a cross "
if (osimi.getSchema().getMissingTables().contains("intermineobject")) { System.out.println("Skipping deletion of all objects in objectstore because intermineobject table is missing"); return;
Query qopeQuery = qope.getQuery(idsToFetch, os.getSchema().isMissingNotXml()); long startTime = System.currentTimeMillis(); List<ResultsRow<Object>> res = os.executeWithConnection(c, qopeQuery, 0,
String generatedSql = SqlGenerator.generate( q, osi.getSchema(), osi.getDatabase(), null,
@Test public void testLargeOffset() throws Exception { Query q = new Query(); QueryClass qc = new QueryClass(Address.class); q.addFrom(qc); q.addToSelect(qc); Query q2 = QueryCloner.cloneQuery(q); SingletonResults r = os.executeSingleton(q, 2, true, true, true); InterMineObject o = (InterMineObject) r.get(5); SqlGenerator.registerOffset(q2, 6, ((ObjectStoreInterMineImpl) os).getSchema(), ((ObjectStoreInterMineImpl) os).db, o.getId(), new HashMap()); SingletonResults r2 = os.executeSingleton(q2, 2, true, true, true); Query q3 = QueryCloner.cloneQuery(q); SqlGenerator.registerOffset(q3, 5, ((ObjectStoreInterMineImpl) os).getSchema(), ((ObjectStoreInterMineImpl) os).db, o.getId(), new HashMap()); SingletonResults r3 = new SingletonResults(q3, os, ObjectStore.SEQUENCE_IGNORE); r3.setBatchSize(2); Assert.assertTrue(r == r2); Assert.assertTrue(r != r3); Assert.assertTrue(r2 != r3); Assert.assertEquals(r, r2); Assert.assertTrue(!r.equals(r3)); }
@Test public void testPrecomputeWithNegatives() throws Exception { Types t1 = new Types(); t1.setLongObjType(new Long(-765187651234L)); t1.setIntObjType(new Integer(278652)); t1.setName("Fred"); storeDataWriter.store(t1); Query q = new Query(); QueryClass qc = new QueryClass(Types.class); QueryField into = new QueryField(qc, "intObjType"); QueryField longo = new QueryField(qc, "longObjType"); q.addFrom(qc); q.addToSelect(into); q.addToSelect(longo); q.addToSelect(qc); q.setDistinct(false); ((ObjectStoreInterMineImpl) os).precompute(q, "test"); Results r = os.execute(q, 1, true, true, true); SqlGenerator.registerOffset(q, 1, ((ObjectStoreInterMineImpl) os).getSchema(), ((ObjectStoreInterMineImpl) os).db, new Integer(278651), new HashMap()); ResultsRow row = (ResultsRow) r.get(1); InterMineObject o = (InterMineObject) row.get(2); Assert.assertEquals("Expected " + t1.toString() + " but got " + o.toString(), t1.getId(), o.getId()); try { r.get(2); Assert.fail("Expected size to be 2"); } catch (Exception e) { } Assert.assertEquals(2, r.size()); storeDataWriter.delete(t1); }
@Test public void testLargeOffset2() throws Exception { Employee nullEmployee = new Employee(); nullEmployee.setAge(26); nullEmployee.setName(null); try { storeDataWriter.store(nullEmployee); Query q = new Query(); QueryClass qc = new QueryClass(Employee.class); q.addFrom(qc); q.addToSelect(qc); q.addToOrderBy(new QueryField(qc, "name")); Query q2 = QueryCloner.cloneQuery(q); SingletonResults r = os.executeSingleton(q, 2, true, true, true); Employee o = (Employee) r.get(2); SqlGenerator.registerOffset(q2, 3, ((ObjectStoreInterMineImpl) os).getSchema(), ((ObjectStoreInterMineImpl) os).db, o.getName(), new HashMap()); SingletonResults r2 = os.executeSingleton(q2, 2, true, true, true); Query q3 = QueryCloner.cloneQuery(q); SqlGenerator.registerOffset(q3, 2, ((ObjectStoreInterMineImpl) os).getSchema(), ((ObjectStoreInterMineImpl) os).db, o.getName(), new HashMap()); SingletonResults r3 = new SingletonResults(q3, os, ObjectStore.SEQUENCE_IGNORE); r3.setBatchSize(2); Assert.assertTrue(r == r2); Assert.assertTrue(r != r3); Assert.assertTrue(r2 != r3); Assert.assertEquals(r, r2); Assert.assertTrue(!r.equals(r3)); } finally { storeDataWriter.delete(nullEmployee); } }
SqlGenerator.registerOffset(q, 1, ((ObjectStoreInterMineImpl) os).getSchema(), ((ObjectStoreInterMineImpl) os).db, new Integer(100000), new HashMap());