/** * Constructor. * * @param table table definition * @param data table data * @throws MPXJException */ public FileRow(TableDefinition table, List<String> data) throws MPXJException { super(new HashMap<String, Object>()); ColumnDefinition[] columns = table.getColumns(); for (int index = 0; index < columns.length; index++) { ColumnDefinition column = columns[index]; if (index < data.size()) { m_map.put( column.getName(), getColumnValue(table.getName(), column.getName(), data.get(index), column.getType())); } } }
public FieldSpec buildColumnFieldSpec(ColumnDefinition c) { TypeName type = c.getType(); CodeBlock initializer; if (type instanceof ParameterizedTypeName) { initializer = CodeBlock.builder() .add( "new $T($S, $T.getType(new $T<$T>(){}), $L, $L, $L, $L, $L, $L)", c.getColumnDefType(), c.columnName, Types.ParameterizedTypes, Types.TypeHolder, type, c.nullable, c.primaryKey, c.autoincrement, c.autoId, c.indexed, c.unique) .build(); } else { initializer = CodeBlock.builder() .add( "new $T($S, $T.class, $L, $L, $L, $L, $L, $L)", c.getColumnDefType(), c.columnName, type, c.nullable, c.primaryKey, c.autoincrement, c.autoId, c.indexed, c.unique) .build(); } return FieldSpec.builder(c.getColumnDefType(), c.name) .addModifiers(publicStaticFinal) .initializer(initializer) .build(); }
/** * Gets partition where tuple has to be written. Creates the partition if necessary. * * @param t * @return * @throws IOException */ public synchronized Partition getPartitionForTuple(Tuple t) throws IOException { // if(partitioningSpec==null) return // tableDefinition.getDataDir()+"/"+tableDefinition.getName(); long time = TimeEncoding.INVALID_INSTANT; Object value = null; if (partitioningSpec.timeColumn != null) { time = (Long) t.getColumn(partitioningSpec.timeColumn); } if (partitioningSpec.valueColumn != null) { value = t.getColumn(partitioningSpec.valueColumn); ColumnDefinition cd = tableDefinition.getColumnDefinition(partitioningSpec.valueColumn); if (cd.getType() == DataType.ENUM) { value = tableDefinition.addAndGetEnumValue(partitioningSpec.valueColumn, (String) value); } } return createAndGetPartition(time, value); }