当前位置: 首页>>代码示例>>Java>>正文


Java CloseableIterator类代码示例

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


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


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