• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Cursor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.jooq.Cursor的典型用法代码示例。如果您正苦于以下问题:Java Cursor类的具体用法?Java Cursor怎么用?Java Cursor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Cursor类属于org.jooq包,在下文中一共展示了Cursor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: Select

import org.jooq.Cursor; //导入依赖的package包/类
private Select(
  Connection connection,
  QueryBuilder<ResultQuery<? extends R>> queryBuilder,
  RecordMapper<? super R, ? extends T> recordMapper
) {
  super(
    subscriber -> {
      try (ResultQuery<? extends R> query = queryBuilder.build(connection)) {
        Cursor<? extends R> cursor = query.fetchLazy();
        setupUnsubscription(subscriber, query, cursor);
        log.debug("Select setProducer for  {}", query);
        subscriber.setProducer(new SelectProducer<>(
          subscriber,
          query,
          cursor,
          recordMapper
        ));
      } catch (Throwable t) {
        handleException(t, subscriber);
      }
    }
  );
}
 
开发者ID:Trunkplatform,项目名称:tiny-rxjava-jdbc,代码行数:24,代码来源:Select.java


示例2: iteratorHosts

import org.jooq.Cursor; //导入依赖的package包/类
protected Iterator<AllocationCandidate> iteratorHosts(List<Long> volumes, QueryOptions options, boolean hosts,
        AllocationCandidateCallback callback) {
    final Cursor<Record2<Long,Long>> cursor = create()
            .select(HOST.ID, STORAGE_POOL.ID)
            .from(HOST)
            .leftOuterJoin(STORAGE_POOL_HOST_MAP)
                .on(STORAGE_POOL_HOST_MAP.HOST_ID.eq(HOST.ID)
                    .and(STORAGE_POOL_HOST_MAP.REMOVED.isNull()))
            .join(STORAGE_POOL)
                .on(STORAGE_POOL.ID.eq(STORAGE_POOL_HOST_MAP.STORAGE_POOL_ID))
            .leftOuterJoin(AGENT)
                .on(AGENT.ID.eq(HOST.AGENT_ID))
            .where(
                AGENT.ID.isNull().or(AGENT.STATE.eq(CommonStatesConstants.ACTIVE))
                .and(HOST.STATE.eq(CommonStatesConstants.ACTIVE))
                .and(STORAGE_POOL.STATE.eq(CommonStatesConstants.ACTIVE))
                .and(getQueryOptionCondition(options)))
            .orderBy(SPREAD.get() ? HOST.COMPUTE_FREE.desc() : HOST.COMPUTE_FREE.asc())
            .fetchLazy();

    return new AllocationCandidateIterator(objectManager, cursor, volumes, hosts, callback);
}
 
开发者ID:cloudnautique,项目名称:cloud-cattle,代码行数:23,代码来源:SimpleAllocatorDaoImpl.java


示例3: iteratorHosts

import org.jooq.Cursor; //导入依赖的package包/类
protected Iterator<AllocationCandidate> iteratorHosts(List<Long> volumes, QueryOptions options, boolean hosts) {
    final Cursor<Record2<Long,Long>> cursor = create()
            .select(HOST.ID, STORAGE_POOL.ID)
            .from(HOST)
            .leftOuterJoin(STORAGE_POOL_HOST_MAP)
                .on(STORAGE_POOL_HOST_MAP.HOST_ID.eq(HOST.ID)
                    .and(STORAGE_POOL_HOST_MAP.REMOVED.isNull()))
            .join(STORAGE_POOL)
                .on(STORAGE_POOL.ID.eq(STORAGE_POOL_HOST_MAP.STORAGE_POOL_ID))
            .leftOuterJoin(AGENT)
                .on(AGENT.ID.eq(HOST.AGENT_ID))
            .where(
                AGENT.ID.isNull().or(AGENT.STATE.eq(CommonStatesConstants.ACTIVE))
                .and(HOST.STATE.eq(CommonStatesConstants.ACTIVE))
                .and(STORAGE_POOL.STATE.eq(CommonStatesConstants.ACTIVE))
                .and(getQueryOptionCondition(options)))
            .orderBy(SPREAD.get() ? HOST.COMPUTE_FREE.asc() : HOST.COMPUTE_FREE.desc())
            .fetchLazy();

    return new AllocationCandidateIterator(objectManager, cursor, volumes, hosts);
}
 
开发者ID:ibuildthecloud,项目名称:dstack,代码行数:22,代码来源:SimpleAllocatorDaoImpl.java


示例4: fetchList

import org.jooq.Cursor; //导入依赖的package包/类
private List<String> fetchList (ResultQuery<Record1<String>> query, String columnField) {
  Cursor<Record1<String>> cursor = null;
  List<String> result = new ArrayList<String> (1000);
  try {
    cursor = query.fetchLazy ();
    // Cursor has similar methods as Iterator<R>
    while (cursor.hasNext ()) {
      Record record = cursor.fetchOne ();
      String sValue = (String) record.getValue (columnField);
      result.add (sValue);
    }
  } finally {
    if (cursor != null) {
      cursor.close ();
    }
  }
  return result;
}
 
开发者ID:dfci-cccb,项目名称:mev,代码行数:19,代码来源:TestJooqCursorLUSCLevel2.java


示例5: aggregateDependencies

import org.jooq.Cursor; //导入依赖的package包/类
List<DependencyLink> aggregateDependencies(long endTs, @Nullable Long lookback, Connection conn) {
  endTs = endTs * 1000;
  // Lazy fetching the cursor prevents us from buffering the whole dataset in memory.
  Cursor<Record> cursor = context.get(conn)
      .selectDistinct(hasTraceIdHigh.get() ? LINK_FIELDS : LINK_FIELDS_WITHOUT_TRACE_ID_HIGH)
      // left joining allows us to keep a mapping of all span ids, not just ones that have
      // special annotations. We need all span ids to reconstruct the trace tree. We need
      // the whole trace tree so that we can accurately skip local spans.
      .from(ZIPKIN_SPANS.leftJoin(ZIPKIN_ANNOTATIONS)
          // NOTE: we are intentionally grouping only on the low-bits of trace id. This buys time
          // for applications to upgrade to 128-bit instrumentation.
          .on(ZIPKIN_SPANS.TRACE_ID.eq(ZIPKIN_ANNOTATIONS.TRACE_ID).and(
              ZIPKIN_SPANS.ID.eq(ZIPKIN_ANNOTATIONS.SPAN_ID)))
          .and(ZIPKIN_ANNOTATIONS.A_KEY.in(CLIENT_SEND, CLIENT_ADDR, SERVER_RECV, SERVER_ADDR)))
      .where(lookback == null ?
          ZIPKIN_SPANS.START_TS.lessOrEqual(endTs) :
          ZIPKIN_SPANS.START_TS.between(endTs - lookback * 1000, endTs))
      // Grouping so that later code knows when a span or trace is finished.
      .groupBy(hasTraceIdHigh.get()
          ? LINK_GROUP_FIELDS
          : LINK_GROUP_FIELDS_WITHOUT_TRACE_ID_HIGH).fetchLazy();

  Iterator<Iterator<DependencyLinkSpan>> traces =
      new DependencyLinkSpanIterator.ByTraceId(cursor.iterator(), hasTraceIdHigh.get());

  if (!traces.hasNext()) return Collections.emptyList();

  DependencyLinker linker = new DependencyLinker();

  while (traces.hasNext()) {
    linker.putTrace(traces.next());
  }

  return linker.link();
}
 
开发者ID:liaominghua,项目名称:zipkin,代码行数:36,代码来源:MySQLSpanStore.java


示例6: closeQuietly

import org.jooq.Cursor; //导入依赖的package包/类
/**
 * Close the cursor quietly
 */
public static <R extends Record> void closeQuietly(Cursor<R> cursor) {
  try {
    if (cursor != null && !cursor.isClosed()) {
      cursor.close();
      log.debug("closed {}", cursor);
    }
  } catch (Exception e) {
    log.debug(e.getMessage(), e);
  }
}
 
开发者ID:Trunkplatform,项目名称:tiny-rxjava-jdbc,代码行数:14,代码来源:Util.java


示例7: SelectProducer

import org.jooq.Cursor; //导入依赖的package包/类
public SelectProducer(
  Subscriber<? super T> subscriber,
  ResultQuery<? extends R> query,
  Cursor<? extends R> cursor,
  RecordMapper<? super R, ? extends T> recordMapper
) {
  this.subscriber = subscriber;
  this.query = query;
  this.cursor = cursor;
  this.recordMapper = recordMapper;
}
 
开发者ID:Trunkplatform,项目名称:tiny-rxjava-jdbc,代码行数:12,代码来源:SelectProducer.java


示例8: setupUnsubscription

import org.jooq.Cursor; //导入依赖的package包/类
private static <R extends Record, T> void setupUnsubscription(
  Subscriber<? super T> subscriber,
  ResultQuery<? extends R> query,
  Cursor<? extends R> cursor
) {
  subscriber.add(
    Subscriptions.create(
      () -> {
        closeQuietly(cursor);
        closeQuietly(query);
      }
    )
  );
}
 
开发者ID:Trunkplatform,项目名称:tiny-rxjava-jdbc,代码行数:15,代码来源:Select.java


示例9: findAuthorsWithBooksJooqFetchLazyOldFashionGroupBy

import org.jooq.Cursor; //导入依赖的package包/类
@Transactional(readOnly = true)
public Collection<AuthorWithBooks> findAuthorsWithBooksJooqFetchLazyOldFashionGroupBy() {

	try (Cursor<Record> records = dslContext.select()
			.from(AUTHOR.leftOuterJoin(BOOK).on(BOOK.AUTHOR_ID.equal(AUTHOR.ID)))
			.fetchLazy()) {

		Map<Long, AuthorWithBooks> booksMap = new HashMap<>();

		for (Record r : records) {

			Long authorId = r.getValue(TAuthor.AUTHOR.ID);

			AuthorWithBooks authorWithBooks = booksMap.get(authorId);

			if (authorWithBooks == null) {
				authorWithBooks = new AuthorWithBooks();
				authorWithBooks.setAuthor(new Author(authorId, r.getValue(TAuthor.AUTHOR.NAME)));
				authorWithBooks.setBooks(new ArrayList<>());
				booksMap.put(authorId, authorWithBooks);
			}

			Book book = new Book(r.getValue(TBook.BOOK.ID), r.getValue(TBook.BOOK.TITLE), authorId);
			authorWithBooks.getBooks().add(book);
		}

		return booksMap.values();
	}
}
 
开发者ID:nithril,项目名称:sandbox-query-benchmark-jooq-hibernate-jdbc,代码行数:30,代码来源:AuthorQueries.java


示例10: AllocationCandidateIterator

import org.jooq.Cursor; //导入依赖的package包/类
public AllocationCandidateIterator(ObjectManager objectManager, Cursor<Record2<Long,Long>> cursor, List<Long> volumeIds, boolean hosts,
        AllocationCandidateCallback callback) {
    super();
    this.objectManager = objectManager;
    this.volumeIds = volumeIds;
    this.cursor = cursor;
    this.hosts = hosts;
    this.callback = callback;
}
 
开发者ID:cloudnautique,项目名称:cloud-cattle,代码行数:10,代码来源:AllocationCandidateIterator.java


示例11: AllocationCandidateIterator

import org.jooq.Cursor; //导入依赖的package包/类
public AllocationCandidateIterator(ObjectManager objectManager, Cursor<Record2<Long,Long>> cursor, List<Long> volumeIds, boolean hosts) {
    super();
    this.objectManager = objectManager;
    this.volumeIds = volumeIds;
    this.cursor = cursor;
    this.hosts = hosts;
}
 
开发者ID:ibuildthecloud,项目名称:dstack,代码行数:8,代码来源:AllocationCandidateIterator.java


示例12: get

import org.jooq.Cursor; //导入依赖的package包/类
@Override
public Iterable<Tag> get(DaoFilter filter) throws DaoException {
    Collection<Condition> conditions = new ArrayList<Condition>();
    if (filter.getTags() != null) {
        conditions.add(Tables.TAGS.RAW_TAG.in(filter.getTags()));
    }
    if (filter.getConcepts() != null) {
        conditions.add(Tables.TAGS.CONCEPT_ID.in(filter.getConceptIds()));
    }
    Cursor<Record> cursor = fetchLazy(conditions);
    return buildTagIterable(cursor);
}
 
开发者ID:shilad,项目名称:sem-tag,代码行数:13,代码来源:TagSqlDao.java


示例13: buildTagIterable

import org.jooq.Cursor; //导入依赖的package包/类
private Iterable<Tag> buildTagIterable(Cursor<Record> cursor) {
    return new SqlDaoIterable<Tag>(cursor) {
        @Override
        public Tag transform(Record record) throws DaoException {
            return buildTag(record);
        }
    };
}
 
开发者ID:shilad,项目名称:sem-tag,代码行数:9,代码来源:TagSqlDao.java


示例14: get

import org.jooq.Cursor; //导入依赖的package包/类
@Override
public Iterable<Concept> get(DaoFilter filter) throws DaoException {
    Collection<Condition> conditions = new ArrayList<Condition>();
    if (filter.getConceptIds() != null) {
        conditions.add(Tables.CONCEPTS.CONCEPT_ID.in(filter.getConceptIds()));
    }
    Cursor<Record> cursor = fetchLazy(conditions);
    return buildConceptIterable(cursor);
}
 
开发者ID:shilad,项目名称:sem-tag,代码行数:10,代码来源:ConceptSqlDao.java


示例15: buildConceptIterable

import org.jooq.Cursor; //导入依赖的package包/类
private Iterable<Concept> buildConceptIterable(Cursor<Record> cursor) {
    return new SqlDaoIterable<Concept>(cursor) {
        @Override
        public Concept transform(Record record) throws DaoException {
            return buildConcept(record);
        }
    };
}
 
开发者ID:shilad,项目名称:sem-tag,代码行数:9,代码来源:ConceptSqlDao.java


示例16: get

import org.jooq.Cursor; //导入依赖的package包/类
@Override
public Iterable<User> get(DaoFilter filter) throws DaoException {
    Collection<Condition> conditions = new ArrayList<Condition>();
    if (filter.getUserIds() != null) {
        conditions.add(Tables.USERS.USER_ID.in(filter.getUserIds()));
    }
    Cursor<Record> cursor = fetchLazy(conditions);
    return buildUserIterable(cursor);
}
 
开发者ID:shilad,项目名称:sem-tag,代码行数:10,代码来源:UserSqLDao.java


示例17: buildUserIterable

import org.jooq.Cursor; //导入依赖的package包/类
private Iterable<User> buildUserIterable(Cursor<Record> cursor) {
    return new SqlDaoIterable<User>(cursor) {
        @Override
        public User transform(Record record) throws DaoException {
            return buildUser(record);
        }
    };
}
 
开发者ID:shilad,项目名称:sem-tag,代码行数:9,代码来源:UserSqLDao.java


示例18: get

import org.jooq.Cursor; //导入依赖的package包/类
@Override
public Iterable<Item> get(DaoFilter filter) throws DaoException {
    Collection<Condition> conditions = new ArrayList<Condition>();
    if (filter.getUserIds() != null) {
        conditions.add(Tables.ITEMS.ITEM_ID.in(filter.getUserIds()));
    }
    Cursor<Record> cursor = fetchLazy(conditions);
    return buildItemIterable(cursor);
}
 
开发者ID:shilad,项目名称:sem-tag,代码行数:10,代码来源:ItemSqlDao.java


示例19: buildItemIterable

import org.jooq.Cursor; //导入依赖的package包/类
private Iterable<Item> buildItemIterable(Cursor<Record> cursor) {
    return new SqlDaoIterable<Item>(cursor) {
        @Override
        public Item transform(Record record) throws DaoException {
            return buildItem(record);
        }
    };
}
 
开发者ID:shilad,项目名称:sem-tag,代码行数:9,代码来源:ItemSqlDao.java


示例20: testSimpleSelectAll

import org.jooq.Cursor; //导入依赖的package包/类
@Test
@Ignore @SuppressWarnings("unused")
public void testSimpleSelectAll () {
  Table<Record> table = tableByName (tsvFileName);

  long startTime = System.nanoTime ();
  int count = 0;
  ResultQuery<Record> query = context.selectFrom (table);
  // log.debug ("PresetValuesFlatTable sql:"+query.getSQL ());
  Cursor<Record> cursor = null;
  try {
    cursor = query.fetchLazy ();
    // Cursor has similar methods as Iterator<R>
    while (cursor.hasNext ()) {
      Record record = cursor.fetchOne ();
      for (Field<?> columnField : record.fields ()) {
        String value = (String) record.getValue (columnField);
        count++;
      }
    }
  } finally {
    if (cursor != null) {
      cursor.close ();
    }
  }

  long endTime = System.nanoTime ();
  long duration = endTime - startTime;
  log.debug ("flat-count:" + count + ", duration: " + duration);
}
 
开发者ID:dfci-cccb,项目名称:mev,代码行数:31,代码来源:TestJooqCursorLUSCLevel2.java



注:本文中的org.jooq.Cursor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DatabaseUtil类代码示例发布时间:2022-05-23
下一篇:
Java Disableable类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap