Package com.alvazan.orm.api.z8spi.action

Examples of com.alvazan.orm.api.z8spi.action.Column


  private Object translateFromToComposite(Row row, NoSqlSession session) {
    // THIS IS NOT DONE YET
    byte[] bytes = StandardConverters.convertToBytes(columnName);
    Collection<Column> columns = row.columnByPrefix(bytes);
    if (columns != null && !columns.isEmpty()) {
      Column column = columns.iterator().next();
      byte[] fullName = column.getName();
      // strip off the prefix to get the foreign key
      int pkLen = fullName.length - bytes.length;
      byte[] fk = new byte[pkLen];
      for (int i = bytes.length; i < fullName.length; i++) {
        fk[i - bytes.length] = fullName[i];
View Full Code Here


        System.arraycopy(bytes, 0, bytesandId, 0, bytes.length);
        System.arraycopy(rowid, 0, bytesandId, bytes.length, rowid.length);
        Collection<Column> columns = row.columnByPrefix(bytesandId);
        if (columns != null && !columns.isEmpty()) {
            // Id is present
            Column column = columns.iterator().next();
            byte[] fullName = column.getName();
            // strip off the prefix to get the foreign key
            int pkLen = fullName.length - bytesandrowid;
            byte[] pk = new byte[pkLen];
            for (int i = bytesandrowid; i < fullName.length; i++) {
                pk[i - bytesandrowid] = fullName[i];
View Full Code Here

      return;
    for (PROXY proxy : toBeAdded) {
      byte[] name = formTheName(proxy);
      if (name != null) {
        // rowkey is not null. i.e., NoSqlId is present
        Column idColumn = new Column();
        idColumn.setName(name);
        idColumn.setValue(null);
        row.getColumns().add(idColumn);
        byte[] idValue = translateOne(proxy);
        Field[] fieldsinClass = proxy.getClass().getDeclaredFields();
        for (Field singleField : fieldsinClass) {
          singleField.setAccessible(true);
View Full Code Here

    }
  }

  private void addColumn(PROXY proxy, Field singleField, byte[] idValue, RowToPersist row) {
    Object value = ReflectionUtil.fetchFieldValue(proxy, singleField);
    Column c = new Column();
    byte[] columnName = formTheColumnName(proxy, idValue, singleField);
    c.setName(columnName);
        if (value != null) {
            byte[] columnValue = null;
            NoSqlConverter customConv = singleField.getAnnotation(NoSqlConverter.class);
            if (customConv != null) {
                columnValue = getBytesValue(value, customConv);
            } else {
                columnValue = StandardConverters.convertToBytes(value);
            }
            c.setValue(columnValue);
        }
    row.getColumns().add(c);
  }
View Full Code Here

    return entities;
  }

  private void addColumnWithoutId(PROXY proxy, Field singleField, RowToPersist row) {
    Object value = ReflectionUtil.fetchFieldValue(proxy, singleField);
    Column c = new Column();
    //byte[] columnName = formTheColumnName(proxy, idValue, singleField);

    byte[] prefix = StandardConverters.convertToBytes(columnName);
    byte[] singleFieldName = StandardConverters.convertToBytes(singleField.getName());
    byte[] columnName = new byte[ prefix.length + singleFieldName.length];
    for (int i = 0; i < columnName.length; i++) {
      if (i < prefix.length)
        columnName[i] = prefix[i];
      else
        columnName[i] = singleFieldName[i - prefix.length];
    }
    c.setName(columnName);
    if (value != null) {
            byte[] columnValue = null;
            NoSqlConverter customConv = singleField.getAnnotation(NoSqlConverter.class);
            if (customConv != null) {
                columnValue = getBytesValue(value, customConv);
            } else {
                columnValue = StandardConverters.convertToBytes(value);
            }
            c.setValue(columnValue);
    }
    row.getColumns().add(c);
  }
View Full Code Here

   
    //now process all the existing columns (we can add same entity as many times as we like and it does not
    //get duplicated)
    for(Object fk : toBeAdded) {
      byte[] name = formTheNameImpl(fk);
      Column c = new Column();
      c.setName(name);
      row.getColumns().add(c);
    }
  }
View Full Code Here

    if(isComposite) {
      IndexColumn c = convertToIndexCol(col);
      return new Holder<T>((T) c);
    } else {
      Object obj = col.getName();
      Column c = new Column();
      byte[] name = (byte[])obj;
      c.setName(name);
      c.setValue(col.getByteArrayValue());
      c.setTimestamp(col.getTimestamp());
      return new Holder<T>((T) c);
    }
  }
View Full Code Here

      com.netflix.astyanax.model.Row<byte[], byte[]> row, Row r) {
    for(com.netflix.astyanax.model.Column<byte[]> col : row.getColumns()) {
      byte[] name = col.getName();
      byte[] val = col.getByteArrayValue();
      long timestamp = col.getTimestamp();
      Column c = new Column();
      c.setName(name);
      if(val.length != 0)
        c.setValue(val);
      c.setTimestamp(timestamp);
     
      r.put(name, c);
    }
  }
View Full Code Here

    MetaClassSingle<T> metaClassSingle = retrieveMeta(row);
    return metaClassSingle.translateFromRow(row, session);
  }

  private MetaClassSingle<T> retrieveMeta(Row row) {
    Column column = row.getColumn(discColAsBytes);
   
    String type = StandardConverters.convertFromBytes(String.class, column.getValue());
    MetaClassSingle<T> metaClassSingle = this.dbTypeToMeta.get(type);
    return metaClassSingle;
  }
View Full Code Here

    String type = classToType.get(clazz);
    MetaClassSingle<T> metaClassSingle = dbTypeToMeta.get(type);
    RowToPersist translateToRow = metaClassSingle.translateToRow(entity);
   
    byte[] value = StandardConverters.convertToBytes(type);
    Column typeCol = new Column();
    typeCol.setName(discColAsBytes);
    typeCol.setValue(value);
    translateToRow.getColumns().add(typeCol);
    return translateToRow;
  }
View Full Code Here

TOP

Related Classes of com.alvazan.orm.api.z8spi.action.Column

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.