/** * Get a {@link com.stratio.crossdata.common.data.Cell} with the column contents of a Row. * * @param type The {@link com.datastax.driver.core.DataType} of the column. * @param r The row that contains the column. * @param columnName The column name. * @return A {@link com.stratio.crossdata.common.data.Cell} with the contents. * @throws java.lang.reflect.InvocationTargetException If the required method cannot be invoked. * @throws IllegalAccessException If the method cannot be accessed. */ protected Cell getCell(DataType type, Row r, String columnName) throws InvocationTargetException, IllegalAccessException { Method m = transformations.get(type.toString()); Object value = m.invoke(r, columnName); return new Cell(value); }
private String insertBlock(Row row, TableMetadata targetTable, boolean ifNotExists) throws ExecutionException { Set<String> keys = row.getCells().keySet(); Map<ColumnName, ColumnMetadata> columnsWithMetadata = targetTable.getColumns(); Map<String, ColumnInsertCassandra> columnsMetadata = new HashMap<>(); try { for (String key : keys) { ColumnName col = new ColumnName(targetTable.getName().getCatalogName().getName(), targetTable.getName().getName(), key); columnsMetadata.put(key, new ColumnInsertCassandra(columnsWithMetadata.get(col).getColumnType(), row.getCell(key).toString(), key)); } } catch (Exception e) { throw new ExecutionException("Trying insert data in a not existing column", e); } InsertIntoStatement insertStatement = new InsertIntoStatement(targetTable, columnsMetadata, ifNotExists); return insertStatement.toString(); }
metaCell=new Cell(row.getList(def.getName(),def.getType().getTypeArguments().get(0) .asJavaClass()) .toString());