use of org.skife.jdbi.v2.sqlobject.Bind in project hive by apache.
the class DruidStorageHandlerUtils method getDataSegmentList.
/**
* @param connector SQL connector to metadata
* @param metadataStorageTablesConfig Tables configuration
* @param dataSource Name of data source
* @return List of all data segments part of the given data source
*/
static List<DataSegment> getDataSegmentList(final SQLMetadataConnector connector, final MetadataStorageTablesConfig metadataStorageTablesConfig, final String dataSource) {
return connector.retryTransaction((handle, status) -> handle.createQuery(String.format("SELECT payload FROM %s WHERE dataSource = :dataSource", metadataStorageTablesConfig.getSegmentsTable())).setFetchSize(getStreamingFetchSize(connector)).bind("dataSource", dataSource).map(ByteArrayMapper.FIRST).fold(new ArrayList<>(), (Folder3<List<DataSegment>, byte[]>) (accumulator, payload, control, ctx) -> {
try {
final DataSegment segment = DATA_SEGMENT_INTERNER.intern(JSON_MAPPER.readValue(payload, DataSegment.class));
accumulator.add(segment);
return accumulator;
} catch (Exception e) {
throw new SQLException(e.toString());
}
}), 3, DEFAULT_MAX_TRIES);
}
Aggregations