本文整理了Java中org.skife.jdbi.v2.Query.list
方法的一些代码示例,展示了Query.list
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.list
方法的具体详情如下:
包路径:org.skife.jdbi.v2.Query
类名称:Query
方法名:list
[英]Executes the select
Will eagerly load all results
[中]执行选择
将急切地加载所有结果
代码示例来源:origin: apache/incubator-druid
@Override
public boolean tableExists(final Handle handle, final String tableName)
{
return !handle.createQuery("SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = :tableName")
.bind("tableName", tableName)
.map(StringMapper.FIRST)
.list()
.isEmpty();
}
代码示例来源:origin: apache/incubator-druid
@Override
public boolean tableExists(final Handle handle, final String tableName)
{
return !handle.createQuery(
"SELECT tablename FROM pg_catalog.pg_tables WHERE schemaname = 'public' AND tablename ILIKE :tableName"
)
.bind("tableName", tableName)
.map(StringMapper.FIRST)
.list()
.isEmpty();
}
代码示例来源:origin: apache/incubator-druid
@Override
public List<Pair<String, String>> withHandle(Handle handle)
{
return handle
.createQuery(
buildLookupQuery(table, filter, keyColumn, valueColumn)
).map(
new ResultSetMapper<Pair<String, String>>()
{
@Override
public Pair<String, String> map(
final int index,
final ResultSet r,
final StatementContext ctx
) throws SQLException
{
return new Pair<>(r.getString(keyColumn), r.getString(valueColumn));
}
}
).list();
}
}
代码示例来源:origin: apache/incubator-druid
@Override
public List<String> inTransaction(Handle handle, TransactionStatus status)
{
return handle.createQuery(reverseFetchQuery)
.bind("val", value)
.map(StringMapper.FIRST)
.list();
}
});
代码示例来源:origin: apache/incubator-druid
@Override
public List<String> inTransaction(Handle handle, TransactionStatus status)
{
return handle.createQuery(fetchQuery)
.bind("val", key)
.map(StringMapper.FIRST)
.list();
}
}
代码示例来源:origin: apache/incubator-druid
@Override
public List<TaskInfo<EntryType, StatusType>> getActiveTaskInfo(@Nullable String dataSource)
{
return getConnector().retryWithHandle(
handle -> {
final Query<Map<String, Object>> query = createActiveTaskInfoQuery(
handle,
dataSource
);
return query.map(taskInfoMapper).list();
}
);
}
代码示例来源:origin: apache/incubator-druid
@Override
public List<TaskInfo<EntryType, StatusType>> getCompletedTaskInfo(
DateTime timestamp,
@Nullable Integer maxNumStatuses,
@Nullable String dataSource
)
{
return getConnector().retryWithHandle(
handle -> {
final Query<Map<String, Object>> query = createCompletedTaskInfoQuery(
handle,
timestamp,
maxNumStatuses,
dataSource
);
return query.map(taskInfoMapper).list();
}
);
}
代码示例来源:origin: apache/incubator-druid
public byte[] lookupWithHandle(
final Handle handle,
final String tableName,
final String keyColumn,
final String valueColumn,
final String key
)
{
final String selectStatement = StringUtils.format(
"SELECT %s FROM %s WHERE %s = :key", valueColumn,
tableName, keyColumn
);
List<byte[]> matched = handle.createQuery(selectStatement)
.bind("key", key)
.map(ByteArrayMapper.FIRST)
.list();
if (matched.isEmpty()) {
return null;
}
if (matched.size() > 1) {
throw new ISE("Error! More than one matching entry[%d] found for [%s]?!", matched.size(), key);
}
return matched.get(0);
}
代码示例来源:origin: apache/incubator-druid
@Override
public Iterable<Map.Entry<String, String>> fetchAll()
{
return inReadOnlyTransaction((handle, status) -> {
return handle.createQuery(fetchAllQuery)
.setFetchSize(streamingFetchSize)
.map(new KeyValueResultSetMapper(keyColumn, valueColumn))
.list();
});
}
代码示例来源:origin: apache/incubator-druid
@Override
public List<String> withHandle(Handle handle)
{
return handle.createQuery("SELECT id FROM " + table + " WHERE used = true ORDER BY id")
.map(StringMapper.FIRST)
.list();
}
}
代码示例来源:origin: apache/incubator-druid
private boolean segmentExists(final Handle handle, final DataSegment segment)
{
return !handle
.createQuery(StringUtils.format("SELECT id FROM %s WHERE id = :identifier", dbTables.getSegmentsTable()))
.bind("identifier", segment.getId().toString())
.map(StringMapper.FIRST)
.list()
.isEmpty();
}
代码示例来源:origin: apache/incubator-druid
@Override
public boolean tableExists(Handle handle, String tableName)
{
String databaseCharset = handle
.createQuery("SELECT @@character_set_database")
.map(StringMapper.FIRST)
.first();
if (!databaseCharset.startsWith("utf8")) {
throw new ISE(
"Druid requires its MySQL database to be created with an UTF8 charset, found `%1$s`. "
+ "The recommended charset is `utf8mb4`.",
databaseCharset
);
} else if (!"utf8mb4".equals(databaseCharset)) {
log.warn("The current database charset `%1$s` does not match the recommended charset `utf8mb4`", databaseCharset);
}
return !handle.createQuery("SHOW tables LIKE :tableName")
.bind("tableName", tableName)
.list()
.isEmpty();
}
代码示例来源:origin: apache/incubator-druid
@Override
public List<AuditEntry> withHandle(Handle handle)
{
Query<Map<String, Object>> query = handle.createQuery(theQueryString);
if (key != null) {
query.bind("audit_key", key);
}
return query.bind("type", type)
.setMaxRows(theLimit)
.map(
new ResultSetMapper<AuditEntry>()
{
@Override
public AuditEntry map(int index, ResultSet r, StatementContext ctx)
throws SQLException
{
try {
return jsonMapper.readValue(r.getBytes("payload"), AuditEntry.class);
}
catch (IOException e) {
throw new SQLException(e);
}
}
}
)
.list();
}
}
代码示例来源:origin: apache/incubator-druid
StringUtils.format("SELECT DISTINCT dataSource,commit_metadata_payload FROM %1$s", dbTables.get().getDataSourceTable())
.map(new ResultSetMapper<Pair<String, DerivativeDataSourceMetadata>>()
.list()
);
代码示例来源:origin: apache/incubator-druid
.bind("start_date", theInterval.getStart().toString())
.bind("end_date", theInterval.getEnd().toString())
.map(
new ResultSetMapper<AuditEntry>()
.list();
代码示例来源:origin: apache/hive
private List<DataSegment> getUsedSegmentsList(DerbyConnectorTestUtility connector,
final MetadataStorageTablesConfig metadataStorageTablesConfig) {
return connector.getDBI()
.withHandle(handle -> handle.createQuery(String.format(
"SELECT payload FROM %s WHERE used=true ORDER BY created_date ASC",
metadataStorageTablesConfig.getSegmentsTable()))
.map((i, resultSet, statementContext) -> {
try {
return DruidStorageHandlerUtils.JSON_MAPPER.readValue(resultSet.getBytes("payload"), DataSegment.class);
} catch (IOException e) {
throw Throwables.propagate(e);
}
}).list());
}
代码示例来源:origin: apache/incubator-druid
.bind("start", interval.getStart().toString())
.bind("end", interval.getEnd().toString())
.map(new ResultSetMapper<Pair<DataSegment, String>>()
.list()
);
代码示例来源:origin: apache/incubator-druid
.bind("start_date", theInterval.getStart().toString())
.bind("end_date", theInterval.getEnd().toString())
.map(
new ResultSetMapper<AuditEntry>()
.list();
代码示例来源:origin: apache/incubator-druid
boundQuery = boundQuery.bind(var.lhs, var.rhs);
final List<byte[]> existingBytes = boundQuery.map(ByteArrayMapper.FIRST).list();
代码示例来源:origin: rakam-io/rakam
public Map<String, Object> getAll(Handle handle, @Named("user_id") UIPermissionParameterProvider.Project project) {
return handle.createQuery("SELECT name, value FROM ui_user_defaults WHERE user_id = :user AND project_id = :project")
.bind("project", project.project)
.bind("user", project.userId)
.map((ResultSetMapper<Map.Entry<String, Object>>) (index, r, ctx) ->
new AbstractMap.SimpleImmutableEntry<>(r.getString(1), JsonHelper.read(r.getString(2), Object.class)))
.list().stream().collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue()));
}
内容来源于网络,如有侵权,请联系作者删除!