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());
      }
    }
  }
  @Override
  public int compare(ByteArray o1, ByteArray o2) {
    if (o1.getKey() == null && o2.getKey() != null) return -1;
    else if (o2.getKey() == null && o1.getKey() != null) return 1;
    else if (o2.getKey() == null && o1.getKey() == null) return 0;

    String left = StandardConverters.convertFromBytes(String.class, o1.getKey());
    String right = StandardConverters.convertFromBytes(String.class, o2.getKey());
    return left.compareTo(right);
  }
  private void loadPartitions(DboTableMeta meta2) {
    DboTableMeta tableMeta = mgr.find(DboTableMeta.class, "partitions");
    NoSqlSession session = mgr.getSession();
    byte[] rowKey = StandardConverters.convertToBytes(meta2.getColumnFamily());
    Cursor<Column> results =
        session.columnSlice(tableMeta, rowKey, null, null, 1000, BigInteger.class);

    while (results.next()) {
      Column col = results.getCurrent();
      BigInteger time = StandardConverters.convertFromBytes(BigInteger.class, col.getName());
      existingPartitions.add(time.longValue());
    }

    Collections.sort(existingPartitions);
  }
Beispiel #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);
  }