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

Java CloseableIterator类代码示例

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

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



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

示例1: createSetFromTuples

import com.mysema.commons.lang.CloseableIterator; //导入依赖的package包/类
public static <T extends Entity> EntitySet<T> createSetFromTuples(entityFromTupleFactory<T> factory, CloseableIterator<Tuple> tuples, Query query, long maxDataSize) {
    EntitySet<T> entitySet = new EntitySetImpl<>(factory.getEntityType());
    int count = 0;
    DataSize size = new DataSize();
    int top = query.getTopOrDefault();
    while (tuples.hasNext()) {
        Tuple tuple = tuples.next();
        entitySet.add(factory.create(tuple, query, size));
        count++;
        if (count >= top) {
            return entitySet;
        }
        if (size.getDataSize() > maxDataSize) {
            LOGGER.debug("Size limit reached: {} > {}.", size.getDataSize(), maxDataSize);
            return entitySet;
        }
    }
    return entitySet;
}
 
开发者ID:FraunhoferIOSB,项目名称:SensorThingsServer,代码行数:20,代码来源:PropertyHelper.java


示例2: iterate

import com.mysema.commons.lang.CloseableIterator; //导入依赖的package包/类
@Override
public CloseableIterator<Q> iterate() {
    final Iterator<? extends Q> iterator = query().iterator();
    return new CloseableIterator<Q>() {
        @Override
        public boolean hasNext() {
            return iterator.hasNext();
        }

        @Override
        public Q next() {
            return iterator.next();
        }

        @Override
        public void remove() {
            iterator.remove();
        }

        @Override
        public void close() {
        }
    };
}
 
开发者ID:querydsl,项目名称:querydsl-contrib,代码行数:25,代码来源:DynamoDBQuery.java


示例3: findUtilizationsWithResolution

import com.mysema.commons.lang.CloseableIterator; //导入依赖的package包/类
@Transactional(readOnly = true, isolation = READ_COMMITTED, propagation = MANDATORY)
@Override
public List<Utilization> findUtilizationsWithResolution(UtilizationKey utilizationKey, DateTime start, DateTime end, Minutes resolution) {
    ArrayList<Utilization> results = new ArrayList<>();
    Optional<Utilization> first = findUtilizationAtInstant(utilizationKey, start);
    try (CloseableIterator<Utilization> rest = findUtilizationsBetween(utilizationKey, start, end)) {
        LinkedList<Utilization> utilizations = Stream.concat(
                StreamUtil.asStream(first),
                StreamUtil.asStream(rest))
                .collect(Collectors.toCollection(LinkedList::new));

        Utilization current = null;
        for (DateTime instant = start; !instant.isAfter(end); instant = instant.plus(resolution)) {
            while (!utilizations.isEmpty() && !utilizations.getFirst().timestamp.isAfter(instant)) {
                current = utilizations.removeFirst();
            }
            if (current != null) {
                current.timestamp = instant;
                results.add(current.copy());
            }
        }
    }
    return results;
}
 
开发者ID:HSLdevcom,项目名称:parkandrideAPI,代码行数:25,代码来源:UtilizationDao.java


示例4: sparqlFind

import com.mysema.commons.lang.CloseableIterator; //导入依赖的package包/类
protected <T extends BaseNode> List<T> sparqlFind(String qry, String idVar, Class<T> c, boolean first) {
    CloseableIterator<Map<String,NODE>> res = _sparql(qry);
    ArrayList<T> result = new ArrayList<T>();
    while (res.hasNext()) {
        for (Map.Entry<String, NODE> n : res.next().entrySet()) {
            if (n.getKey().equals(idVar.replace("?",""))) {
                if (n.getValue().isResource()) {
		result.add(_getById(n.getValue().asResource(), c));
		if (first) 
			return result;
		 else 
			break;
                }
            }
        }
    }
    return result;
}
 
开发者ID:meshnetinc,项目名称:gmantic,代码行数:19,代码来源:Ontology.java


示例5: sparql

import com.mysema.commons.lang.CloseableIterator; //导入依赖的package包/类
private CloseableIterator<Map<String,NODE>> sparql(String q, QueryLanguage queryType, org.openrdf.query.QueryLanguage language) {
    String f = "prefix :    <" + NS + "> \n";
    f += "prefix rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n";
    f += "prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n";
    f += "prefix owl: <http://www.w3.org/2002/07/owl#> \n";
    f += "prefix fts: <http://rdf.useekm.com/fts#> \n";
    f += q;
    if (sparqlVerbose) logger.info(f);
    RDFConnection conn = connection;
    CloseableIterator<Map<String,NODE>> rows = null;
    try {
       rows = smr.openConnection().createQuery(QueryLanguage.SPARQL, f).getTuples();
   } catch (Exception e) {
        logger.error(e.getMessage());
        for (StackTraceElement ste : e.getStackTrace()) logger.info(ste.toString());
   }
    return rows;
}
 
开发者ID:meshnetinc,项目名称:gmantic,代码行数:19,代码来源:Ontology.java


示例6: selectAll

import com.mysema.commons.lang.CloseableIterator; //导入依赖的package包/类
public static ArrayList<NODE> selectAll(String q) {
    ArrayList results = new ArrayList<NODE>();
    CloseableIterator cl = sparql(q);
    while(cl.hasNext()){
        Map m = (Map)cl.next();


        Object[] objectArray = m.values().toArray();
        UID[] n = new UID[objectArray.length];
       for(int i = 0; i< objectArray.length; i++){
           n[i] = (UID) objectArray[i];
       }
        results.add(getById(n[0]));

    }
    return results;
}
 
开发者ID:meshnetinc,项目名称:gmantic,代码行数:18,代码来源:Ontology.java


示例7: testCustomTransform

import com.mysema.commons.lang.CloseableIterator; //导入依赖的package包/类
@Test
@Transactional
public void testCustomTransform() throws Exception {
	JPAQuery query = new JPAQuery(em);
	QStockKeepingUnit path = QStockKeepingUnit.stockKeepingUnit;

	List<SkuDto> results = query.from(path)
			.transform(new ResultTransformer<List<SkuDto>>() {

				@Override
				public List<SkuDto> transform(Projectable arg0) {
					List<SkuDto> result = new ArrayList<SkuDto>();
					CloseableIterator<StockKeepingUnit> iterator = arg0.iterate(QStockKeepingUnit.stockKeepingUnit);
					while (iterator.hasNext()) {
						StockKeepingUnit sku = iterator.next();
						SkuDto dto = new SkuDto(sku.getSkuId(), sku.getName(), sku.getPrice());
						result.add(dto);
					}
					return result;
				}
			});

	Assert.assertEquals(Integer.valueOf(8), Integer.valueOf(results.size()));

}
 
开发者ID:patrickvankann,项目名称:bjug-querydsl,代码行数:26,代码来源:JpaQueryTest.java


示例8: _04Fields

import com.mysema.commons.lang.CloseableIterator; //导入依赖的package包/类
@Benchmark
public void _04Fields(LimitParam limit, final Blackhole blackhole, ConnectionParam connectionParam) throws Exception {
	SQLQuery query = new SQLQuery(connectionParam.connection, templates);

	CloseableIterator<MappedObject4> iterate = query.from(QTestSmallBenchmarkObject.testSmallBenchmarkObject)
			.limit(limit.limit)
			.iterate(MAPPED_OBJECT_4_Q_BEAN);

	while(iterate.hasNext()) {
		blackhole.consume(iterate.next());
	}
}
 
开发者ID:arnaudroger,项目名称:mapping-benchmark,代码行数:13,代码来源:QueryDslSfmBenchmark.java


示例9: _16Fields

import com.mysema.commons.lang.CloseableIterator; //导入依赖的package包/类
@Benchmark
public void _16Fields(LimitParam limit, final Blackhole blackhole, ConnectionParam connectionParam) throws Exception {
	SQLQuery query = new SQLQuery(connectionParam.connection, templates);

	CloseableIterator<MappedObject16> iterate = query.from(QTestBenchmarkObject16.testBenchmarkObject16)
			.limit(limit.limit)
			.iterate(MAPPED_OBJECT_16_Q_BEAN);

	while(iterate.hasNext()) {
		blackhole.consume(iterate.next());
	}
}
 
开发者ID:arnaudroger,项目名称:mapping-benchmark,代码行数:13,代码来源:QueryDslSfmBenchmark.java


示例10: transform

import com.mysema.commons.lang.CloseableIterator; //导入依赖的package包/类
@Override
public R transform(FetchableQuery<?, ?> query) {
	CloseableIterator<T> iter = query.select(groupExpression.getExpression()).iterate();
	GroupCollector<T, R> collector = groupExpression.createGroupCollector();
	try {
		while (iter.hasNext()) {
			T collectable = iter.next();
			collector.add(collectable);
		}
	} finally {
		iter.close();
	}
	return collector.get();
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:15,代码来源:GroupExpressionResultTransformer.java


示例11: findUtilizationsBetween

import com.mysema.commons.lang.CloseableIterator; //导入依赖的package包/类
@Transactional(readOnly = true, isolation = READ_COMMITTED, propagation = MANDATORY)
@Override
public CloseableIterator<Utilization> findUtilizationsBetween(UtilizationKey utilizationKey, DateTime start, DateTime end) {
    UtilizationSearch search = new UtilizationSearch();
    search.facilityIds.add(utilizationKey.facilityId);
    search.usages.add(utilizationKey.usage);
    search.capacityTypes.add(utilizationKey.capacityType);
    search.start = start;
    search.end = end;
    return findUtilizations(search);
}
 
开发者ID:HSLdevcom,项目名称:parkandrideAPI,代码行数:12,代码来源:UtilizationDao.java


示例12: findUtilizations

import com.mysema.commons.lang.CloseableIterator; //导入依赖的package包/类
@Transactional(readOnly = true, isolation = READ_COMMITTED, propagation = MANDATORY)
@Override
public CloseableIterator<Utilization> findUtilizations(UtilizationSearch search) {
    // TODO: add support for JDBC setFetchSize to QueryDSL, without it PostgreSQL will not stream results, but instead reads all results to memory
    final PostgreSQLQuery<Utilization> q = queryFactory.from(qUtilization).select(utilizationMapping);
    q.where(qUtilization.ts.between(search.start, search.end));
    addCriteria(q, search.facilityIds, qUtilization.facilityId);
    addCriteria(q, search.capacityTypes, qUtilization.capacityType);
    addCriteria(q, search.usages, qUtilization.usage);
    q.setStatementOptions(StatementOptions.builder().setFetchSize(100).build());
    return q.orderBy(qUtilization.ts.asc()).iterate();
}
 
开发者ID:HSLdevcom,项目名称:parkandrideAPI,代码行数:13,代码来源:UtilizationDao.java


示例13: getFacilityStats

import com.mysema.commons.lang.CloseableIterator; //导入依赖的package包/类
private Map<MaxUtilizationReportKeyWithDate, Integer> getFacilityStats(ReportContext ctx, ReportParameters parameters, UtilizationSearch search) {
    try (CloseableIterator<Utilization> utilizations = utilizationRepository.findUtilizations(search)) {
        return stream(spliteratorUnknownSize(addFilters(utilizations, ctx, parameters), Spliterator.ORDERED), false)
                .filter(u -> hasBuiltCapacity(u, ctx.facilities))
                .collect(toMap(
                        u -> new MaxUtilizationReportKeyWithDate(u, ctx.facilities.get(u.facilityId)),
                        u -> u.spacesAvailable,
                        Math::min,
                        LinkedHashMap::new
                ));
    }
}
 
开发者ID:HSLdevcom,项目名称:parkandrideAPI,代码行数:13,代码来源:MaxUtilizationReportService.java


示例14: predict

import com.mysema.commons.lang.CloseableIterator; //导入依赖的package包/类
@Override
public List<Prediction> predict(PredictorState state, UtilizationHistory history, int maxCapacity) {
    List<Prediction> predictions = new ArrayList<>();
    try (CloseableIterator<Utilization>  utilizations = history.getUpdatesSince(state.latestUtilization)) {
        stream(spliteratorUnknownSize(utilizations, NONNULL | IMMUTABLE), false)
            .reduce((older, newer) -> newer)
            .ifPresent(lastUpdate -> {
                state.latestUtilization = lastUpdate.timestamp;
                predictions.add(new Prediction(lastUpdate.timestamp, lastUpdate.spacesAvailable));
                predictions.add(new Prediction(lastUpdate.timestamp.plusDays(1), lastUpdate.spacesAvailable));
            });
    }
    return predictions;
}
 
开发者ID:HSLdevcom,项目名称:parkandrideAPI,代码行数:15,代码来源:SameAsLatestPredictor.java


示例15: getUpdatesSince

import com.mysema.commons.lang.CloseableIterator; //导入依赖的package包/类
@Override
public CloseableIterator<Utilization> getUpdatesSince(DateTime startExclusive) {
    return new IteratorAdapter<Utilization>(
            utilizationList.stream()
            .filter(utilization -> !utilization.timestamp.isBefore(startExclusive))
            .iterator()
    );
}
 
开发者ID:HSLdevcom,项目名称:parkandrideAPI,代码行数:9,代码来源:UtilizationHistoryList.java


示例16: findUtilizationsBetween_limits_to_start_and_end_time_inclusive_ordered_by_time

import com.mysema.commons.lang.CloseableIterator; //导入依赖的package包/类
@Test
public void findUtilizationsBetween_limits_to_start_and_end_time_inclusive_ordered_by_time() {
    Utilization u1 = newUtilization(facilityId, new DateTime(2000, 1, 1, 12, 0, 0, 1), 100, 100);
    Utilization u2 = newUtilization(facilityId, new DateTime(2000, 1, 1, 12, 0, 0, 2), 200, 200);
    Utilization u3 = newUtilization(facilityId, new DateTime(2000, 1, 1, 12, 0, 0, 3), 300, 300);
    Utilization u4 = newUtilization(facilityId, new DateTime(2000, 1, 1, 12, 0, 0, 4), 400, 400);
    Utilization u5 = newUtilization(facilityId, new DateTime(2000, 1, 1, 12, 0, 0, 5), 500, 500);
    UtilizationKey key = u1.getUtilizationKey();
    utilizationDao.insertUtilizations(asList(u1, u2, u3, u4, u5));

    try (CloseableIterator<Utilization> results = utilizationDao.findUtilizationsBetween(key, u2.timestamp, u4.timestamp)) {

        assertThat(results).containsExactly(u2, u3, u4);
    }
}
 
开发者ID:HSLdevcom,项目名称:parkandrideAPI,代码行数:16,代码来源:UtilizationDaoTest.java


示例17: findUtilizationsBetween_is_facility_specific

import com.mysema.commons.lang.CloseableIterator; //导入依赖的package包/类
@Test
public void findUtilizationsBetween_is_facility_specific() {
    DateTime time = new DateTime(2000, 1, 1, 12, 0);
    Utilization u1 = newUtilization(dummies.createFacility(), time, 100, 100);
    Utilization u2 = newUtilization(dummies.createFacility(), time, 200, 200);
    utilizationDao.insertUtilizations(asList(u1, u2));

    try (CloseableIterator<Utilization> results = utilizationDao.findUtilizationsBetween(u1.getUtilizationKey(), time, time)) {

        assertThat(results).containsExactly(u1);
    }
}
 
开发者ID:HSLdevcom,项目名称:parkandrideAPI,代码行数:13,代码来源:UtilizationDaoTest.java


示例18: findUtilizationsBetween_is_capacity_type_specific

import com.mysema.commons.lang.CloseableIterator; //导入依赖的package包/类
@Test
public void findUtilizationsBetween_is_capacity_type_specific() {
    DateTime time = new DateTime(2000, 1, 1, 12, 0);
    Utilization u1 = newUtilization(facilityId, time, 100, 100);
    u1.capacityType = CAR;
    Utilization u2 = newUtilization(facilityId, time, 200, 200);
    u2.capacityType = MOTORCYCLE;
    utilizationDao.insertUtilizations(asList(u1, u2));

    try (CloseableIterator<Utilization> results = utilizationDao.findUtilizationsBetween(u1.getUtilizationKey(), time, time)) {

        assertThat(results).containsExactly(u1);
    }
}
 
开发者ID:HSLdevcom,项目名称:parkandrideAPI,代码行数:15,代码来源:UtilizationDaoTest.java


示例19: findUtilizationsBetween_is_usage_specific

import com.mysema.commons.lang.CloseableIterator; //导入依赖的package包/类
@Test
public void findUtilizationsBetween_is_usage_specific() {
    DateTime time = new DateTime(2000, 1, 1, 12, 0);
    Utilization u1 = newUtilization(facilityId, time, 100, 100);
    u1.usage = COMMERCIAL;
    Utilization u2 = newUtilization(facilityId, time, 200, 200);
    u2.usage = HSL_TRAVEL_CARD;
    utilizationDao.insertUtilizations(asList(u1, u2));

    try (CloseableIterator<Utilization> results = utilizationDao.findUtilizationsBetween(u1.getUtilizationKey(), time, time)) {

        assertThat(results).containsExactly(u1);
    }
}
 
开发者ID:HSLdevcom,项目名称:parkandrideAPI,代码行数:15,代码来源:UtilizationDaoTest.java


示例20: update

import com.mysema.commons.lang.CloseableIterator; //导入依赖的package包/类
@Test
public void update() {
    tn.description = "howdy";
    tn.save();
    CloseableIterator<Map<String,NODE>> c = Ontology.sparql("select ?d where { ?tn a %TestNode . ?tn %description ?d }");
    assertTrue(c.hasNext());
    assertEquals(c.next().get("d").asLiteral().getValue(), "howdy");
}
 
开发者ID:meshnetinc,项目名称:gmantic,代码行数:9,代码来源:GmanticTest.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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