Package com.alvazan.orm.api.z8spi.meta

Examples of com.alvazan.orm.api.z8spi.meta.TypedRow


        //one batch may not have any of the keys of the other batch.  This is very normal
      } else if(row.getException() != null || row.getValue() == null) {
        removeIndexPt(s, data, pt);
        changedCounter++;
      } else {
        TypedRow val = row.getValue();
        if (processColumn(s, data, val, pt)) {
          changedCounter++;
        }
      }
View Full Code Here


  public void remove(String colFamily, TypedRow row) {
    DboTableMeta metaDbo = cachedMeta.getMeta(colFamily);
    if(metaDbo == null)
      throw new IllegalArgumentException("DboTableMeta for colFamily="+colFamily+" was not found");
   
    TypedRow proxy = row;
    Object rowKey = row.getRowKey();
    DboColumnIdMeta idMeta = metaDbo.getIdColumnMeta();
    byte[] byteKey = idMeta.convertToStorage2(rowKey);
    byte[] virtualKey = idMeta.formVirtRowKey(byteKey);
    if(!metaDbo.hasIndexedField()) {
View Full Code Here

  public TypedRow createTypedRow(String colFamily) {
    DboTableMeta metaClass = cachedMeta.getMeta(colFamily);
    if(metaClass == null)
      throw new IllegalArgumentException("DboTableMeta for colFamily="+colFamily+" was not found");
   
    TypedRow r = new TypedRow(null, metaClass);
    return r;
  }
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);
   
    BigInteger big1 = row2.getColumn("integer").getValueAsBigInteger();
    BigInteger big2 = result.getColumn("integer").getValueAsBigInteger();
    Assert.assertEquals(big1, big2);
   
    Boolean b1 = row2.getColumn("boolean").getValueAsBoolean();
    Boolean b2 = result.getColumn("boolean").getValueAsBoolean();
    Assert.assertEquals(b1, b2);
   
  }
View Full Code Here

  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

    }
    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 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

    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

    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);
   
    TypedColumn column2 = result2.getColumn("temp");
    Assert.assertNotNull(column2);   
    Object val2 = column2.getValue();
    Assert.assertNull(val2);
   
    TypedColumn column3 = result3.getColumn("temp");
    Assert.assertNull(column3);

    TypedColumn column4 = result4.getColumn(name);
    Assert.assertNotNull(column4);   
    byte[] valueRaw = column4.getValueRaw();
    Assert.assertNull(valueRaw);
   
    TypedColumn column5 = result5.getColumn("other");
    Assert.assertNotNull(column5);
    String value = (String) column5.getValue(String.class);
    Assert.assertEquals(null, value);
   
    TypedColumn column6 = result6.getColumn("other");
    Assert.assertNotNull(column6);
    int value6 = (Integer) column6.getValue(Integer.class);
    Assert.assertEquals(0, value6);
   
    TypedColumn column6b = result6.getColumn("nullInt");
    Integer val6b = column6b.getValue(Integer.class);
    Assert.assertNull(val6b);
  }
View Full Code Here

  @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");
    Assert.assertNull(col3);
  }
View Full Code Here

TOP

Related Classes of com.alvazan.orm.api.z8spi.meta.TypedRow

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.