예제 #1
0
  private void parseOutKeyList(Row row, TypedRow entity) {
    String columnName = getColumnName() + "Id";
    byte[] namePrefix = StandardConverters.convertToBytes(columnName);
    Collection<Column> columns = row.columnByPrefix(namePrefix);
    if (columns.size() > 0) {
      for (Column col : columns) {
        byte[] rowkeyFullName = col.getName();
        int rkLen = rowkeyFullName.length - namePrefix.length;
        byte[] rk = new byte[rkLen];
        for (int i = namePrefix.length; i < rowkeyFullName.length; i++) {
          rk[i - namePrefix.length] = rowkeyFullName[i];
        }
        // this is the rowkey which is being added
        String rowKeyToDisplay = getColumnName() + ".Id";
        byte[] rowkeyPrefixToDisplay = StandardConverters.convertToBytes(rowKeyToDisplay);
        entity.addColumn(
            this, rowkeyFullName, rowkeyPrefixToDisplay, rk, col.getValue(), col.getTimestamp());

        // Now extract other columns
        Object objVal = this.convertFromStorage2(rk);
        String columnsInEmbeddedRowName = getColumnName() + this.convertTypeToString(objVal);
        byte[] embedColumn = StandardConverters.convertToBytes(columnsInEmbeddedRowName);
        Collection<Column> columnsInRow = row.columnByPrefix(embedColumn);
        for (Column colInRow : columnsInRow) {
          byte[] fullName = colInRow.getName();
          int pkLen = fullName.length - embedColumn.length;
          byte[] fk = new byte[pkLen];
          for (int i = embedColumn.length; i < fullName.length; i++) {
            fk[i - embedColumn.length] = fullName[i];
          }

          String embedColumnToDisplay = getColumnName() + "." + this.convertTypeToString(objVal);
          byte[] embedColumPrefixToDisplay =
              StandardConverters.convertToBytes(embedColumnToDisplay);
          entity.addColumn(
              this,
              fullName,
              embedColumPrefixToDisplay,
              fk,
              colInRow.getValue(),
              col.getTimestamp());
        }
      }
    } else {
      // It means it doesn't have a NoSqlId, so only extract other columns
      byte[] colName = StandardConverters.convertToBytes(getColumnName());
      Collection<Column> columnsWORowKey = row.columnByPrefix(colName);
      for (Column col : columnsWORowKey) {
        byte[] fullName = col.getName();
        int embedColumnLen = fullName.length - colName.length;
        byte[] embedColumn = new byte[embedColumnLen];
        for (int i = colName.length; i < fullName.length; i++) {
          embedColumn[i - colName.length] = fullName[i];
        }
        entity.addColumn(this, fullName, colName, embedColumn, col.getValue(), col.getTimestamp());
      }
    }
  }
예제 #2
0
  @Override
  public void remove(DboTableMeta colFamily, byte[] rowKey, Collection<byte[]> columnNames) {
    session.remove(colFamily, rowKey, columnNames);
    RowHolder<Row> currentRow = fromCache(colFamily, rowKey);
    if (currentRow == null) {
      return;
    }
    Row value = currentRow.getValue();
    if (value == null) {
      return;
    }

    value.removeColumns(columnNames);
  }
예제 #3
0
  @Override
  public void put(DboTableMeta colFamily, byte[] rowKey, List<Column> columns) {
    session.put(colFamily, rowKey, columns);
    RowHolder<Row> currentRow = fromCache(colFamily, rowKey);
    if (currentRow == null) {
      currentRow = new RowHolder<Row>(rowKey);
    }

    Row value = currentRow.getValue();
    if (value == null) value = rowProvider.get();

    value.setKey(rowKey);
    value.addColumns(columns);
    cacheRow(colFamily, rowKey, value);
  }
예제 #4
0
  @Override
  public void translateFromColumn(Row row, OWNER entity, NoSqlSession session) {
    String indexColFamily = getMetaDbo().getIndexTableName();
    String rowKey = formRowKey(row.getKey());

    byte[] key = StandardConverters.convertToBytes(rowKey);
    ScanInfo info = new ScanInfo(ownerMeta.getMetaDbo(), getMetaDbo(), indexColFamily, key);
    int batchSize = 200;
    AbstractCursor<IndexColumn> indexCursor = session.scanIndex(info, null, null, batchSize);

    CursorProxy<PROXY> cursor =
        new CursorProxy<PROXY>(entity, session, indexCursor, classMeta, batchSize);
    ReflectionUtil.putFieldValue(entity, field, cursor);
  }