Package com.alvazan.orm.api.z3api

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


  public void reindex(String cmd, NoSqlEntityManager mgr) {
    String oldCommand = cmd.substring(8);
    String command = oldCommand.trim();
    ColFamilyData data = parseData(mgr, command);
   
    NoSqlTypedSession s = mgr.getTypedSession();
    String cf = data.getColFamily();
    String field = data.getColumn();
    String by = data.getPartitionBy();
    String id = data.getPartitionId();
    Cursor<IndexPoint> indexView = s.indexView(cf, field, by, id);
    Cursor<IndexPoint> indexView2 = s.indexView(cf, field, by, id);
   
    DboTableMeta meta = data.getTableMeta();
    DboColumnMeta colMeta = data.getColumnMeta();
    System.out.println("indexed value type="+colMeta.getStorageType());
    System.out.println("row key type="+meta.getIdColumnMeta().getStorageType());
View Full Code Here


  public void processIndex(String cmd, NoSqlEntityManager mgr) {
    String oldCommand = cmd.substring(10);
    String command = oldCommand.trim();
   
    ColFamilyData data = parseData(mgr, command);
    NoSqlTypedSession s = mgr.getTypedSession();
   
    String cf = data.getColFamily();
    String field = data.getColumn();
    String by = data.getPartitionBy();
    String id = data.getPartitionId();

    Cursor<IndexPoint> indexView = s.indexView(cf, field, by, id);

    DboTableMeta meta = data.getTableMeta();
    DboColumnMeta colMeta = data.getColumnMeta();
    System.out.println("indexed value type="+colMeta.getStorageType());
    System.out.println("row key type="+meta.getIdColumnMeta().getStorageType());
View Full Code Here

  /**
     *
     * Process the SQL query which is inserted as an command line arguments
     */
  private static void processSQL(String[] args){
    NoSqlTypedSession ntsession = mgr.getTypedSession();
        QueryResult result = ntsession.createQueryCursor(args[0], 50);
        Cursor<List<TypedRow>> cursor = result.getAllViewsCursor();
        processBatch(cursor);
  }
View Full Code Here

   
    byte[] temp = new byte[2];
    temp[0] = 23;
    temp[1] = 24;
   
    NoSqlTypedSession s = mgr.getTypedSession();
    TypedRow row2 = s.createTypedRow("Owner");
    row2.setRowKey("myoneid");
    row2.addColumn("name", "dean");
    row2.addColumn("unknown", temp);
    row2.addColumn("decimal", new BigDecimal(52.32));
    row2.addColumn("integer", BigInteger.valueOf(54));
    row2.addColumn("boolean", true);
   
    s.put("Owner", row2);
    s.flush();
   
    NoSqlEntityManager mgr2 = factory.createEntityManager();
    NoSqlTypedSession s2 = mgr2.getTypedSession();
   
    TypedRow result = s2.find("Owner", row2.getRowKey());
    byte[] unknowResult = row2.getColumn("unknown").getValueRaw();
    Assert.assertEquals(temp[1], unknowResult[1]);
    BigDecimal dec1 = row2.getColumn("decimal").getValueAsBigDecimal();
    BigDecimal dec2 = result.getColumn("decimal").getValueAsBigDecimal();
    Assert.assertEquals(dec1, dec2);
View Full Code Here

 
  @Test
  public void testRawStuff() {
    setupModel();
   
    NoSqlTypedSession s = mgr.getTypedSession();

    TypedRow row2 = s.createTypedRow("Owner");
    row2.setRowKey("myoneid");
    row2.addColumn("name", "dean");
   
    s.put("Owner", row2);

    TypedRow row = s.createTypedRow("MyRaceCar");
    row.setRowKey("myoneid");
    row.addColumn("carOwner", row2.getRowKey());
   
    s.put("MyRaceCar", row);
   
    s.flush();
   
    NoSqlEntityManager mgr2 = factory.createEntityManager();
    NoSqlTypedSession s2 = mgr2.getTypedSession();
   
    s2.remove("Owner", row2);
    s2.flush();
   
    TypedRow result = s2.find("MyRaceCar", row.getRowKey());
    Assert.assertNotNull(result);
    TypedRow result2 = s2.find("Owner", row2.getRowKey());
    Assert.assertNull(result2);
   
/*    if (result.getColumn("carOwner") != null) {
      Object fk = result.getColumn("carOwner").getValue();
      Object rowId = row2.getRowKey();
      //Assert.assertEquals(rowId, fk);
    }
    else {*/
      // it is saved as a composite column now so no need to test as above, test as composite 
      Object rowId = row2.getRowKey();
      for(TypedColumn c : result.getColumnsAsColl()) {
        DboColumnMeta colMeta = c.getColumnMeta();
        if(colMeta != null) {
          String fullName = c.getName();
          String fkcomposite = fullName.substring(fullName.indexOf(".")+1);
          Assert.assertEquals(rowId.toString(), fkcomposite);
        }
      }
    //}

    QueryResult qResult = s2.createQueryCursor("select * from MyRaceCar", 50);
    Cursor<KeyValue<TypedRow>> primView = qResult.getPrimaryViewCursor();
    Assert.assertTrue(primView.next());
    KeyValue<TypedRow> current = primView.getCurrent();
    TypedRow resultRow = current.getValue();
    Assert.assertEquals(row.getRowKey(), resultRow.getRowKey());
   
    Cursor<List<TypedRow>> cursor = qResult.getAllViewsCursor();
    Assert.assertTrue(cursor.next());
    List<TypedRow> theRow = cursor.getCurrent();
    Assert.assertEquals(1, theRow.size());
    TypedRow myRow = theRow.get(0);
    Assert.assertEquals(row.getRowKey(), myRow.getRowKey());
   
    QueryResult rResult = s2.createQueryCursor("select * from Owner", 50);
    Assert.assertFalse(rResult.getCursor().next());
  }
View Full Code Here

    DboDatabaseMeta metaDb = mgr.find(DboDatabaseMeta.class,DboDatabaseMeta.META_DB_ROWKEY);
    for (int i = 1; i <= 20; i++) {
      addMetaClassDboTest(metaDb, "Test" + i, "id"+i, "cat1", "mouse", "dog");
    }
    mgr.flush();
    NoSqlTypedSession session = mgr.getTypedSession();
    for (int j = 1; j < 20; j++) {
      for (int l = 1; l <= 100; l++) {
      TypedRow typedRow = session.createTypedRow("Test" + j);
      for(int k=1;k<100;k++){
      typedRow.addColumn("col"+k, "deano"+k);
      }
      typedRow.setRowKey("Row" + l+"/"+"Test" + j);
      session.put("Test" + j, typedRow);
      }
      session.flush();
    }
  }
View Full Code Here

  @Test
  public void testViewIndex() {
    if (FactorySingleton.getServerType() == DbTypeEnum.HBASE)
      return; // This testcase is not supported for Hbase

    NoSqlTypedSession s = mgr.getTypedSession();
   
    //Here we can pull from a single index to view the index itself.
    //Supply the column family(Activity) the column that is indexed(numTimes)
    //IF a table is partitioned one way, you can add a partitionId
    //IF a table is partitioned multiple ways, you MUST supply partitionBy and you can supply a partitionId or null for null partition
    Cursor<IndexPoint> cursor = s.indexView("Activity", "numTimes", null, null);
   
    List<IndexPoint> points = new ArrayList<IndexPoint>();
    while(cursor.next()) {
      IndexPoint pt = cursor.getCurrent();
      points.add(pt);
View Full Code Here

    mgr.put(sub);
   
    mgr.flush();
   
    String sql = "select a from Email as a";
    NoSqlTypedSession s = mgr.getTypedSession();
    QueryResult result = s.createQueryCursor(sql, 10); // only need last
    Cursor<KeyValue<TypedRow>> cursor = result.getPrimaryViewCursor();
    cursor.afterLast();
    Assert.assertTrue(cursor.previous());
    Assert.assertEquals("email3", cursor.getCurrent().getKey());
  }
View Full Code Here

    mgr.put(sub);
   
    mgr.flush();
   
    String sql = "select a from Email as a";
    NoSqlTypedSession s = mgr.getTypedSession();
    QueryResult result = s.createQueryCursor(sql, 10); // only need last
    Cursor<KeyValue<TypedRow>> cursor = result.getPrimaryViewCursor();
    cursor.beforeFirst();
    List<TypedRow> list = new ArrayList<TypedRow>();
    TypedRow myRow = null;
    while(cursor.next()) {
View Full Code Here

    Assert.assertEquals("anemail1", myRow.getColumn("name").getValue());
  }
 
  @Test
  public void testInnerJoin() 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();

    ViewInfo viewAct = views.get(0);
    ViewInfo viewAcc = views.get(1);
View Full Code Here

TOP

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

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.