本文整理了Java中org.skife.jdbi.v2.Query.iterator
方法的一些代码示例,展示了Query.iterator
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.iterator
方法的具体详情如下:
包路径:org.skife.jdbi.v2.Query
类名称:Query
方法名:iterator
[英]Obtain a forward-only result set iterator. Note that you must explicitely close the iterator to close the underlying resources.
[中]获取一个只向前的结果集迭代器。请注意,必须明确关闭迭代器才能关闭底层资源。
代码示例来源:origin: apache/incubator-druid
).iterator();
jg.writeStartArray();
while (resultIterator.hasNext()) {
代码示例来源:origin: apache/incubator-druid
try (final ResultIterator<byte[]> dbSegments = sql.map(ByteArrayMapper.FIRST).iterator()) {
return VersionedIntervalTimeline.forSegments(
Iterators.transform(
代码示例来源:origin: killbill/killbill
.bind("accountRecordId", context.getAccountRecordId())
.bind("tenantRecordId", context.getTenantRecordId())
.iterator();
try {
while (iterator.hasNext()) {
代码示例来源:origin: apache/incubator-druid
private List<SegmentIdWithShardSpec> getPendingSegmentsForIntervalWithHandle(
final Handle handle,
final String dataSource,
final Interval interval
) throws IOException
{
final List<SegmentIdWithShardSpec> identifiers = new ArrayList<>();
final ResultIterator<byte[]> dbSegments =
handle.createQuery(
StringUtils.format(
"SELECT payload FROM %1$s WHERE dataSource = :dataSource AND start <= :end and %2$send%2$s >= :start",
dbTables.getPendingSegmentsTable(), connector.getQuoteString()
)
)
.bind("dataSource", dataSource)
.bind("start", interval.getStart().toString())
.bind("end", interval.getEnd().toString())
.map(ByteArrayMapper.FIRST)
.iterator();
while (dbSegments.hasNext()) {
final byte[] payload = dbSegments.next();
final SegmentIdWithShardSpec identifier = jsonMapper.readValue(payload, SegmentIdWithShardSpec.class);
if (interval.overlaps(identifier.getInterval())) {
identifiers.add(identifier);
}
}
dbSegments.close();
return identifiers;
}
代码示例来源:origin: apache/hive
private static VersionedIntervalTimeline<String, DataSegment> getTimelineForIntervalWithHandle(final Handle handle,
final String dataSource,
final Interval interval,
final MetadataStorageTablesConfig dbTables) throws IOException {
Query<Map<String, Object>>
sql =
handle.createQuery(String.format(
"SELECT payload FROM %s WHERE used = true AND dataSource = ? AND start <= ? AND \"end\" >= ?",
dbTables.getSegmentsTable()))
.bind(0, dataSource)
.bind(1, interval.getEnd().toString())
.bind(2, interval.getStart().toString());
final VersionedIntervalTimeline<String, DataSegment> timeline = new VersionedIntervalTimeline<>(Ordering.natural());
try (ResultIterator<byte[]> dbSegments = sql.map(ByteArrayMapper.FIRST).iterator()) {
while (dbSegments.hasNext()) {
final byte[] payload = dbSegments.next();
DataSegment segment = JSON_MAPPER.readValue(payload, DataSegment.class);
timeline.add(segment.getInterval(), segment.getVersion(), segment.getShardSpec().createChunk(segment));
}
}
return timeline;
}
代码示例来源:origin: apache/incubator-druid
.bind("dataSource", dataSource)
.map(ByteArrayMapper.FIRST)
.iterator(),
payload -> {
try {
代码示例来源:origin: rakam-io/rakam
@Override
public Set<String> getProjects() {
try (Handle handle = dbi.open()) {
return ImmutableSet.copyOf(
handle.createQuery("select name from project")
.map(StringMapper.FIRST).iterator());
}
}
代码示例来源:origin: rakam-io/rakam
@Override
public Set<String> getProjects() {
try (Handle handle = dbi.open()) {
return ImmutableSet.copyOf(
handle.createQuery("select name from project")
.map(StringMapper.FIRST).iterator());
}
}
代码示例来源:origin: rakam-io/rakam
p.apiKeys.add(ProjectApiKeys.create(r.getString(6), r.getString(7), r.getString(8)));
return null;
}).iterator();
代码示例来源:origin: rakam-io/rakam
.bind("collection", checkProject(collection))
.bind("schema", checkProject(project))
.map(LongMapper.FIRST).iterator().next();
代码示例来源:origin: org.jdbi/jdbi
@Test
public void testNonPathologicalJustNext() throws Exception {
h.createStatement("insert into something (id, name) values (1, 'eric')").execute();
// Yes, you *should* use first(). But sometimes, an iterator is passed 17 levels deep and then
// used in this way (Hello Jackson!).
final Map<String, Object> result = h.createQuery("select * from something order by id")
.cleanupHandle()
.iterator()
.next();
assertEquals(1, result.get("id"));
assertEquals("eric", result.get("name"));
}
代码示例来源:origin: org.kill-bill.commons/killbill-jdbi
@Test
public void testNonPathologicalJustNext() throws Exception {
h.createStatement("insert into something (id, name) values (1, 'eric')").execute();
// Yes, you *should* use first(). But sometimes, an iterator is passed 17 levels deep and then
// used in this way (Hello Jackson!).
final Map<String, Object> result = h.createQuery("select * from something order by id")
.cleanupHandle()
.iterator()
.next();
assertEquals(1, result.get("id"));
assertEquals("eric", result.get("name"));
}
代码示例来源:origin: org.jdbi/jdbi
@Test
public void testEmptyWorksToo() throws Exception {
ResultIterator<Map<String, Object>> it = h.createQuery("select * from something order by id")
.cleanupHandle()
.iterator();
assertFalse(it.hasNext());
}
代码示例来源:origin: org.kill-bill.commons/killbill-jdbi
@Test
public void testEmptyWorksToo() throws Exception {
ResultIterator<Map<String, Object>> it = h.createQuery("select * from something order by id")
.cleanupHandle()
.iterator();
assertFalse(it.hasNext());
}
代码示例来源:origin: org.jdbi/jdbi
@Test
public void testEmptyExplosion() throws Exception {
ResultIterator<Map<String, Object>> it = h.createQuery("select * from something order by id")
.cleanupHandle()
.iterator();
try {
it.next();
fail("Expected IllegalStateException did not show up!");
}
catch (IllegalStateException iae) {
// TestCase does not deal with the annotations...
}
}
代码示例来源:origin: org.kill-bill.commons/killbill-jdbi
@Test
public void testBasicCleanupIterator()
throws Exception
{
final Handle handle = dbi.open();
final Query<Integer> q = handle.createQuery("SELECT COUNT(1) FROM something")
.cleanupHandle()
.map(IntegerMapper.FIRST);
final ResultIterator<Integer> it = q.iterator();
assertEquals(COUNT, Iterators.getOnlyElement(it).intValue());
assertFalse(it.hasNext());
assertTrue(handle.getConnection().isClosed());
}
代码示例来源:origin: org.jdbi/jdbi
@Test
public void testJustNext() throws Exception {
h.createStatement("insert into something (id, name) values (1, 'eric')").execute();
h.createStatement("insert into something (id, name) values (2, 'brian')").execute();
h.createStatement("insert into something (id, name) values (3, 'john')").execute();
ResultIterator<Map<String, Object>> it = h.createQuery("select * from something order by id")
.cleanupHandle()
.iterator();
it.next();
it.next();
it.next();
}
代码示例来源:origin: org.kill-bill.commons/killbill-jdbi
@Test
public void testJustNext() throws Exception {
h.createStatement("insert into something (id, name) values (1, 'eric')").execute();
h.createStatement("insert into something (id, name) values (2, 'brian')").execute();
h.createStatement("insert into something (id, name) values (3, 'john')").execute();
ResultIterator<Map<String, Object>> it = h.createQuery("select * from something order by id")
.cleanupHandle()
.iterator();
it.next();
it.next();
it.next();
}
代码示例来源:origin: org.jdbi/jdbi
@Test
public void testFetchSize() throws Exception
{
h.createScript("default-data").execute();
Query<Something> q = h.createQuery("select id, name from something order by id").map(Something.class);
q.setFetchSize(1);
ResultIterator<Something> r = q.iterator();
assertTrue(r.hasNext());
r.next();
assertTrue(r.hasNext());
r.next();
assertFalse(r.hasNext());
}
代码示例来源:origin: org.kill-bill.commons/killbill-jdbi
@Test
public void testFetchSize() throws Exception
{
h.createScript("default-data").execute();
Query<Something> q = h.createQuery("select id, name from something order by id").map(Something.class);
q.setFetchSize(1);
ResultIterator<Something> r = q.iterator();
assertTrue(r.hasNext());
r.next();
assertTrue(r.hasNext());
r.next();
assertFalse(r.hasNext());
}
内容来源于网络,如有侵权,请联系作者删除!