use of org.apache.phoenix.util.ColumnInfo in project phoenix by apache.
the class PhoenixConfigurationUtil method getUpsertColumnMetadataList.
public static List<ColumnInfo> getUpsertColumnMetadataList(final Configuration configuration) throws SQLException {
Preconditions.checkNotNull(configuration);
List<ColumnInfo> columnMetadataList = null;
columnMetadataList = ColumnInfoToStringEncoderDecoder.decode(configuration);
if (columnMetadataList != null && !columnMetadataList.isEmpty()) {
return columnMetadataList;
}
final String tableName = getOutputTableName(configuration);
Preconditions.checkNotNull(tableName);
final Connection connection = ConnectionUtil.getOutputConnection(configuration);
List<String> upsertColumnList = PhoenixConfigurationUtil.getUpsertColumnNames(configuration);
if (!upsertColumnList.isEmpty()) {
LOG.info(String.format("UseUpsertColumns=%s, upsertColumnList.size()=%s, upsertColumnList=%s ", !upsertColumnList.isEmpty(), upsertColumnList.size(), Joiner.on(",").join(upsertColumnList)));
}
columnMetadataList = PhoenixRuntime.generateColumnInfo(connection, tableName, upsertColumnList);
// we put the encoded column infos in the Configuration for re usability.
ColumnInfoToStringEncoderDecoder.encode(configuration, columnMetadataList);
connection.close();
return columnMetadataList;
}
use of org.apache.phoenix.util.ColumnInfo in project phoenix by apache.
the class PhoenixIndexDBWritable method write.
@Override
public void write(PreparedStatement statement) throws SQLException {
Preconditions.checkNotNull(values);
Preconditions.checkNotNull(columnMetadata);
for (int i = 0; i < values.size(); i++) {
Object value = values.get(i);
ColumnInfo columnInfo = columnMetadata.get(i);
if (value == null) {
statement.setNull(i + 1, columnInfo.getSqlType());
} else {
statement.setObject(i + 1, value, columnInfo.getSqlType());
}
}
}
Aggregations