示例#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());
      }
    }
  }