Package com.alvazan.orm.api.z3api

Examples of com.alvazan.orm.api.z3api.QueryResult


 
  @Test
  public void testInnerJoinParts2() throws InterruptedException {
    NoSqlTypedSession s = mgr.getTypedSession();

    QueryResult result = s.createQueryCursor("select * FROM Account as a WHERE a.isActive = false", 50);
   
    Cursor<IndexColumnInfo> cursor = result.getCursor();
    List<ViewInfo> views = result.getViews();
   
    ViewInfo viewAct = views.get(0);
    String alias1 = viewAct.getAlias();
    Assert.assertEquals("a", alias1);
   
View Full Code Here


 
  @Test
  public void testInnerJoinParts2Backward() throws InterruptedException {
    NoSqlTypedSession s = mgr.getTypedSession();

    QueryResult result = s.createQueryCursor("select * FROM Account as a WHERE a.isActive = false", 50);
   
    Cursor<IndexColumnInfo> cursor = result.getCursor();
    cursor.afterLast();
    List<ViewInfo> views = result.getViews();
   
    ViewInfo viewAct = views.get(0);
    String alias1 = viewAct.getAlias();
    Assert.assertEquals("a", alias1);
   
View Full Code Here

 
  @Test
  public void testInnerJoinBackward() throws InterruptedException {
    NoSqlTypedSession s = mgr.getTypedSession();

    QueryResult result = s.createQueryCursor("select * FROM Activity as e INNER JOIN e.account  as a WHERE e.numTimes < 15 and a.isActive = false", 50);
   
    Cursor<IndexColumnInfo> cursor = result.getCursor();
    cursor.afterLast();
    List<ViewInfo> views = result.getViews();
   
    ViewInfo viewAct = views.get(0);
    ViewInfo viewAcc = views.get(1);
    String alias1 = viewAct.getAlias();
    String alias2 = viewAcc.getAlias();
    Assert.assertEquals("e", alias1);
    Assert.assertEquals("a", alias2);
   
    Assert.assertTrue(cursor.previous());
    compareKeys(cursor, viewAct, viewAcc, "act7", "acc1");
    Assert.assertTrue(cursor.previous());
    compareKeys(cursor, viewAct, viewAcc, "act1", "acc1");
    Assert.assertFalse(cursor.previous());
   
    Cursor<List<TypedRow>> rows = result.getAllViewsCursor();
    rows.afterLast();
   
    rows.previous();
    List<TypedRow> joinedRow = rows.getCurrent();
   
View Full Code Here

   */
  @Test
  public void testInnerJoinBackwardRepeatedly() throws InterruptedException {
    NoSqlTypedSession s = mgr.getTypedSession();

    QueryResult result = s.createQueryCursor("select * FROM Activity as e INNER JOIN e.account  as a WHERE e.numTimes < 15 and a.isActive = false", 50);
    List<ViewInfo> views = result.getViews();
    Cursor<IndexColumnInfo> cursor = result.getCursor();
    cursor.afterLast();
    //iterate all the way through to force everything to load once, then ensure things are still in the correct (reversed) order:
    while(cursor.previous()){cursor.getCurrent();}
    cursor.afterLast();
   
    ViewInfo viewAct = views.get(0);
    ViewInfo viewAcc = views.get(1);
    String alias1 = viewAct.getAlias();
    String alias2 = viewAcc.getAlias();
    Assert.assertEquals("e", alias1);
    Assert.assertEquals("a", alias2);
   
    Assert.assertTrue(cursor.previous());
    compareKeys(cursor, viewAct, viewAcc, "act7", "acc1");
    Assert.assertTrue(cursor.previous());
    compareKeys(cursor, viewAct, viewAcc, "act1", "acc1");
    Assert.assertFalse(cursor.previous());
   
    Cursor<List<TypedRow>> rows = result.getAllViewsCursor();
    rows.afterLast();
   
    rows.previous();
    List<TypedRow> joinedRow = rows.getCurrent();
   
View Full Code Here

  @Test
  public void testJoinViewButNoJoin() throws InterruptedException {
    NoSqlTypedSession s = mgr.getTypedSession();

    QueryResult result = s.createQueryCursor("select * FROM Activity as e WHERE e.numTimes < 15", 50);
    List<ViewInfo> views = result.getViews();
    Assert.assertEquals(1, views.size());
    Cursor<IndexColumnInfo> cursor = result.getCursor();

    ViewInfo viewAct = views.get(0);
    String alias1 = viewAct.getAlias();
    Assert.assertEquals("e", alias1);
   
    Assert.assertTrue(cursor.next());
    compareKeys2(cursor, viewAct, "act1");
    Assert.assertTrue(cursor.next());
    compareKeys2(cursor, viewAct, "act3");
    Assert.assertTrue(cursor.next());
    compareKeys2(cursor, viewAct, "act5");
    Assert.assertTrue(cursor.next());
    compareKeys2(cursor, viewAct, "act7");
    Assert.assertFalse(cursor.next());
   
    Cursor<List<TypedRow>> rows = result.getAllViewsCursor();
   
    rows.next();
    List<TypedRow> joinedRow = rows.getCurrent();
    Assert.assertEquals(1, joinedRow.size());
   
View Full Code Here

  @Test
  public void testOuterJoin() throws InterruptedException {
    NoSqlTypedSession s = mgr.getTypedSession();

    QueryResult result = s.createQueryCursor("select * FROM Activity as e LEFT JOIN e.account as a WHERE e.numTimes < 15 and a.isActive = false", 50);
    List<ViewInfo> views = result.getViews();
    Cursor<IndexColumnInfo> cursor = result.getCursor();

    ViewInfo viewAct = views.get(0);
    ViewInfo viewAcc = views.get(1);
    String alias1 = viewAct.getAlias();
    String alias2 = viewAcc.getAlias();
    Assert.assertEquals("e", alias1);
    Assert.assertEquals("a", alias2);
   
    Assert.assertTrue(cursor.next());
    compareKeys(cursor, viewAct, viewAcc, "act1", "acc1");
    Assert.assertTrue(cursor.next());
    compareKeys(cursor, viewAct, viewAcc, "act7", "acc1");
    Assert.assertFalse(cursor.next());
   
    Cursor<List<TypedRow>> rows = result.getAllViewsCursor();
   
    rows.next();
    List<TypedRow> joinedRow = rows.getCurrent();
   
    TypedRow typedRow = joinedRow.get(0);
View Full Code Here

   */
  @Test
  public void testOuterJoinWithNullClause() throws InterruptedException {
    NoSqlTypedSession s = mgr.getTypedSession();
   
    QueryResult result = s.createQueryCursor("select * FROM Activity as e LEFT JOIN e.account as a WHERE e.numTimes < 15 and (e.account = null or a.isActive = false)", 50);
    List<ViewInfo> views = result.getViews();
    Cursor<IndexColumnInfo> cursor = result.getCursor();

    ViewInfo viewAct = views.get(0);
    ViewInfo viewAcc = views.get(1);
    String alias1 = viewAct.getAlias();
    String alias2 = viewAcc.getAlias();
    Assert.assertEquals("e", alias1);
    Assert.assertEquals("a", alias2);
   
    Assert.assertTrue(cursor.next());
    compareKeys(cursor, viewAct, viewAcc, "act1", "acc1");
    Assert.assertTrue(cursor.next());
    compareKeys(cursor, viewAct, viewAcc, "act5", null);
    Assert.assertTrue(cursor.next());
    compareKeys(cursor, viewAct, viewAcc, "act7", "acc1");
    Assert.assertFalse(cursor.next());
   
    Cursor<List<TypedRow>> rows = result.getAllViewsCursor();
   
    rows.next();
    List<TypedRow> joinedRow = rows.getCurrent();
   
    TypedRow typedRow = joinedRow.get(0);
View Full Code Here

  }

  @Override
  public int executeQuery(String query) {
    int batchSize = 250;
    QueryResult result = createQueryCursor(query, batchSize);
    Cursor<List<TypedRow>> cursor = result.getAllViewsCursor();
    return updateBatch(cursor, result);
  }
View Full Code Here

        valueString = ""+ (((Float)value).floatValue());
    }
    else
      valueString = null;
    int batchSize = 250;
    QueryResult result = createQueryCursor(query+valueString,batchSize);
    Cursor<IndexColumnInfo> cursor = result.getCursor();
    int rowCount = 0;
    while(cursor.next())
      rowCount++;
    return rowCount;
  }
View Full Code Here

public class CmdSelect {

  void processSelect(String cmd, NoSqlEntityManager mgr) {
    NoSqlTypedSession s = mgr.getTypedSession();
    try {
      QueryResult result = s.createQueryCursor(cmd, 100);
      Cursor<List<TypedRow>> cursor = result.getAllViewsCursor();

      processBatch(cursor, result.getViews());
     
    } catch(ParseException e) {
      Throwable childExc = e.getCause();
      throw new InvalidCommand("Scalable-SQL command was invalid.  Reason="+childExc.getMessage()+" AND you may want to add -v option to playcli to get more info", e);
    }
View Full Code Here

TOP

Related Classes of com.alvazan.orm.api.z3api.QueryResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.