Package com.alvazan.orm.api.z3api

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


    other.clearDatabase(true);
  }

  @Test
  public void testTimeSeriesData() {
    NoSqlTypedSession typedSession = mgr.getTypedSession();
    String colFamily = "timeSeriesAutoPartition";

    long partitionSize = TimeUnit.MILLISECONDS.convert(30, TimeUnit.DAYS);
    DboTableMeta tm = new DboTableMeta();
    tm.setTimeSeries(true);
    tm.setTimeSeriesPartionSize(partitionSize);
    tm.setup(colFamily, "realCf", false, false);
    tm.setColNameType(long.class);

    DboColumnIdMeta idMeta = new DboColumnIdMeta();
    idMeta.setup(tm, "time", BigInteger.class, false);
   
    DboColumnCommonMeta meta = new DboColumnCommonMeta();
    meta.setup(tm, "value", BigDecimal.class, false, false);

    mgr.put(idMeta);
    mgr.put(meta);
    mgr.put(tm);

    mgr.flush();
   
    TypedRow row = typedSession.createTypedRow(colFamily);
    BigInteger rowKey = new BigInteger("0");
    row.setRowKey(rowKey);
    row.addTimeValue(0, new BigDecimal(56));
    row.addTimeValue(10, new BigDecimal(56));
    row.addTimeValue(20, new BigDecimal(56));
    row.addTimeValue(30, new BigDecimal(56));
    row.addTimeValue(40, new BigDecimal(56));
    row.addTimeValue(50, new BigDecimal(56));
    row.addTimeValue(60, new BigDecimal(56));
    row.addTimeValue(70, new BigDecimal(56));
    row.addTimeValue(80, new BigDecimal(56));
    row.addTimeValue(90, new BigDecimal(56));
    row.addTimeValue(100, new BigDecimal(56));

    typedSession.put(colFamily, row);
    typedSession.flush();
   
    Cursor<TimeValColumn> timeVal = typedSession.timeSeriesSlice(colFamily, rowKey, 40, 60, 200);
    for(int i = 0; i < 3; i++) {
      timeVal.next();
      TimeValColumn current = timeVal.getCurrent();
      Assert.assertEquals(i*10+40, current.getTime());
    }
View Full Code Here


 
  //In one case, we added this String.long.String a few times and our in-memory version saw different values as being the same
  //due to the Utf8Comparator being not so correct in that it translated some different long values back to the same string utf 8 value
  @Test
  public void testRawComposite() {
    NoSqlTypedSession s = mgr.getTypedSession();
    String cf = "TimeSeriesData";
    BigInteger id = BigInteger.valueOf(98);
    TypedRow row = s.createTypedRow(cf);
    row.setRowKey(id);

    createColumn(row, "6e756d526f6f6d73", (byte) 1);
    createColumn(row, "6275696c64696e67", (byte) 2);
    createColumn(row, "6e616d65", (byte) 3);
    createColumn(row, "5f686973746f72790000013caaa1b98d5f7374617465", (byte) 4);
    createColumn(row, "5f686973746f72790000013caaa1b98d6275696c64696e67", (byte) 5);
    createColumn(row, "5f686973746f72790000013caaa1b98d6e756d526f6f6d73", (byte) 6);
    createColumn(row, "5f686973746f72790000013caaa1b9ba6275696c64696e67", (byte) 7);
    createColumn(row, "5f686973746f72790000013caaa1b9ba6e756d526f6f6d73", (byte) 8);
    createColumn(row, "6e756d526f6f6d73", (byte) 0);
   
    s.put(cf, row);
    s.flush();
   
    TypedRow result = s.find(cf, id);
    Assert.assertEquals(8, result.getColumnsAsColl().size());
  }
View Full Code Here

  //@Test
  public void testAdvancedJoinClause() {
    //let's add some good data to the table for the join stuff....
    fillInData();
   
    NoSqlTypedSession s = mgr.getTypedSession();
   
    Cursor<KeyValue<TypedRow>> cursor = s.createQueryCursor("select * FROM User as u left join u.age Child as c on u.age = c.age", 500).getPrimaryViewCursor();

    int counter = 0;
    while(cursor.next()) {
      counter++;
    }
View Full Code Here

  }
 
  @Test
  public void testBasicChangeToIndex() {
    log.info("testBasicChangeToIndex");
    NoSqlTypedSession s = mgr.getTypedSession();
   
    String cf = "User";
    String id = "someid";
    TypedRow row = s.createTypedRow(cf);
    createUser(row, id, "dean", "hiller");
    s.put(cf, row);
    s.flush();
   
    //NOW, let's find the row we put
    TypedRow result = s.find(cf, id);
    Assert.assertEquals(id, result.getRowKey());
    Assert.assertEquals(row.getColumn("name").getValue(), result.getColumn("name").getValue());
    Assert.assertEquals(row.getColumn("lastName").getValue(), result.getColumn("lastName").getValue());
  }
View Full Code Here

  public void testZeroVersusNullVersusOther() {
    //Because we can save a name column with no value, can we save a name
    //column with a value of 0? 
    log.info("testTimeSeries");

    NoSqlTypedSession s = mgr.getTypedSession();
   
    //SAVE the value ZERO
    String cf = "TimeSeriesData";
    TypedRow row1 = s.createTypedRow(cf);
    row1.setRowKey(BigInteger.valueOf(25));
    row1.addColumn("temp", new BigDecimal(0));
    row1.addColumn("someName", "dean");
    s.put(cf, row1);

    //SAVE a null value
    TypedRow row2 = s.createTypedRow(cf);
    row2.setRowKey(BigInteger.valueOf(26));
    row2.addColumn("temp", null);
    row2.addColumn("someName", "dean");
    s.put(cf, row2);

    //SAVE with NO column
    TypedRow row3 = s.createTypedRow(cf);
    row3.setRowKey(BigInteger.valueOf(27));
    row3.addColumn("someName", "dean");
    s.put(cf, row3);

    byte[] name = new byte[] {1,2,3,4};
    //SAVE with zero length byte array
    TypedRow row4 = s.createTypedRow(cf);
    row4.setRowKey(BigInteger.valueOf(28));
    row4.addColumn(name, new byte[0], null);
    row4.addColumn("someName", "dean");
    s.put(cf, row4);
   
    //SAVE with zero length byte array
    TypedRow row5 = s.createTypedRow(cf);
    row5.setRowKey(BigInteger.valueOf(29));
    row5.addColumn("other", "");
    row5.addColumn("someName", "dean");
    s.put(cf, row5);

    //SAVE zero for int
    TypedRow row6 = s.createTypedRow(cf);
    row6.setRowKey(BigInteger.valueOf(30));
    row6.addColumn("other", 0);
    row6.addColumn("nullInt", null);
    row6.addColumn("someName", "dean");
    s.put(cf, row6);
   
    s.flush();
   
    //NOW, let's find the row we put
    TypedRow result1 = s.find(cf, row1.getRowKey());
    TypedRow result2 = s.find(cf, row2.getRowKey());
    TypedRow result3 = s.find(cf, row3.getRowKey());
    TypedRow result4 = s.find(cf, row4.getRowKey());
    TypedRow result5 = s.find(cf, row5.getRowKey());
    TypedRow result6 = s.find(cf, row6.getRowKey());
   
    TypedColumn column1 = result1.getColumn("temp");
    Assert.assertNotNull(column1);
    Object val = column1.getValue();
    Assert.assertEquals(new BigDecimal(0), val);
View Full Code Here

    Assert.assertNull(val6b);
  }
 
  @Test
  public void testRemoveColumn() {
    NoSqlTypedSession s = mgr.getTypedSession();
   
    String cf = "TimeSeriesData";
    TypedRow row1 = s.createTypedRow(cf);
    row1.setRowKey(BigInteger.valueOf(25));
    row1.addColumn("temp", new BigDecimal(667));
    row1.addColumn("someName", "dean");
    row1.addColumn("notInSchema", "hithere");
    s.put(cf, row1);
   
    s.flush();
   
    TypedRow result1 = s.find(cf, row1.getRowKey());
    TypedColumn col = result1.getColumn("temp");
    Assert.assertEquals(new BigDecimal(667), col.getValue());
   
    TypedColumn col2 = result1.getColumn("notInSchema");
    String value = col2.getValue(String.class);
    Assert.assertEquals("hithere", value);
   
    result1.removeColumn("temp");
    result1.removeColumn("notInSchema");
   
    s.put(cf, result1);
    s.flush();
   
    TypedRow result2 = s.find(cf, row1.getRowKey());
   
    TypedColumn col4 = result2.getColumn("notInSchema");
    Assert.assertNull(col4);
   
    TypedColumn col3 = result2.getColumn("temp");
View Full Code Here

 
  @Test
  public void testTimeSeries() {
    log.info("testTimeSeries");

    NoSqlTypedSession s = mgr.getTypedSession();
   
    String cf = "TimeSeriesData";
    TypedRow row = s.createTypedRow(cf);
    row.setRowKey(BigInteger.valueOf(25));
    row.addColumn("temp", new BigDecimal(55.6));
    row.addColumn("someName", "dean");
   
    s.put(cf, row);
    s.flush();
   
    //NOW, let's find the row we put
    TypedRow result = s.find(cf, row.getRowKey());
    Assert.assertEquals(row.getRowKey(), result.getRowKey());
    Assert.assertEquals(row.getColumn("temp").getValue(), result.getColumn("temp").getValue());
    Assert.assertEquals(row.getColumn("someName").getValue(), result.getColumn("someName").getValue());
   
    Cursor<KeyValue<TypedRow>> rowsIter = s.createQueryCursor("select s FROM TimeSeriesData as s where s.key = 25", 500).getPrimaryViewCursor();
    rowsIter.next();
    KeyValue<TypedRow> keyValue = rowsIter.getCurrent();
    TypedRow theRow = keyValue.getValue();
    Assert.assertEquals(row.getRowKey(), theRow.getRowKey());
    Assert.assertEquals(row.getColumn("temp").getValue(), theRow.getColumn("temp").getValue());

    //Testing a negative value in the SQL here
    Cursor<KeyValue<TypedRow>> rows2 = s.createQueryCursor("select s FROM TimeSeriesData as s where s.key > -25", 500).getPrimaryViewCursor();
    rows2.next();
    KeyValue<TypedRow> keyValue2 = rows2.getCurrent();
    TypedRow theRow2 = keyValue2.getValue();
    Assert.assertEquals(row.getRowKey(), theRow2.getRowKey());
    Assert.assertEquals(row.getColumn("temp").getValue(), theRow2.getColumn("temp").getValue());
View Full Code Here

    addMetaClassDbo(metaDb, "MyEntity", "theid", "cat", "mouse", "dog");
    addMetaClassDbo(metaDb, "OtherEntity", "id", "dean", "declan", "pet", "house");

    mgr.flush();

    NoSqlTypedSession session = mgr.getTypedSession();
   
    String sql = "select * FROM MyEntity as e WHERE e.cat = \"deano\"";

    TypedRow typedRow = session.createTypedRow("MyEntity");

    typedRow.addColumn("cat", "deano");
    typedRow.setRowKey("dean1");
   
    session.put("MyEntity", typedRow);
   
    session.flush();
   
    Iterable<KeyValue<TypedRow>> rowsIterable = session.createQueryCursor(sql, 50).getPrimaryViewIter();
    int counter = 0;
    for(@SuppressWarnings("unused") KeyValue<TypedRow> k : rowsIterable) {
      counter++;
    }
    Assert.assertEquals(1, counter);
View Full Code Here

    Assert.assertEquals("acc1", theJoinedRow.getRowKey());
  }
 
  @Test
  public void testInnerJoinParts() throws InterruptedException {
    NoSqlTypedSession s = mgr.getTypedSession();

    QueryResult result = s.createQueryCursor("select * FROM Activity as e WHERE e.numTimes < 15", 50);
   
    Cursor<IndexColumnInfo> cursor = result.getCursor();
    List<ViewInfo> views = result.getViews();
   
    ViewInfo viewAct = views.get(0);
View Full Code Here

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

    QueryResult result = s.createQueryCursor("select * FROM Activity as e WHERE e.numTimes < 15", 50);
   
    Cursor<IndexColumnInfo> cursor = result.getCursor();
    cursor.afterLast();
    List<ViewInfo> views = result.getViews();
   
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.