private ReadResult translate(Column current) { byte[] name = current.getName(); byte[] value = current.getValue(); Object time = meta.getIdColumnMeta().convertFromStorage2(name); Object val = colMeta.convertFromStorage2(value); // TODO: parameterize timeColumn and valueColumn from options TSRelational tv = new TSRelational("time", "value"); tv.put("time", time); tv.put(colMeta.getColumnName(), val); return new ReadResult(url, tv); }
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); }
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()); } } }