/** * For the given trip ID, fetch all the stop times in order of increasing stop_sequence. * This is an efficient iteration over a tree map. */ public Iterable<StopTime> getOrderedStopTimesForTrip (String trip_id) { Map<Fun.Tuple2, StopTime> tripStopTimes = stop_times.subMap( Fun.t2(trip_id, null), Fun.t2(trip_id, Fun.HI) ); return tripStopTimes.values(); }
/** * For the given trip ID, fetch all the stop times in order of increasing stop_sequence. * This is an efficient iteration over a tree map. */ public Iterable<StopTime> getOrderedStopTimesForTrip (String trip_id) { Map<Fun.Tuple2, StopTime> tripStopTimes = stop_times.subMap( Fun.t2(trip_id, null), Fun.t2(trip_id, Fun.HI) ); return tripStopTimes.values(); }
private SegmentStatistics loadSegmentStats(long id) { SegmentStatistics cumulativeStats = new SegmentStatistics(); NavigableMap<Fun.Tuple2<Long, Integer>, SegmentStatistics> subMap = statsMap.subMap(new Fun.Tuple2(id, null), true, new Fun.Tuple2(id, Fun.HI), true); for(Object stats : subMap.values()) { cumulativeStats.addStats((SegmentStatistics)stats); } return cumulativeStats; }
public SummaryStatistics collectSummaryStatistics(Long segmentId, Boolean normalize, Set<Integer> weeks, Set<Integer>hours) { SummaryStatistics summaryStatistics = new SummaryStatistics(normalize, hours); if(weeks == null || weeks.size() == 0) { summaryStatistics.add(cumulativeStats.get(segmentId), segmentId); } else { for(Integer week : weeks) { NavigableMap<Fun.Tuple2<Long, Integer>, SegmentStatistics> subMap = statsMap.subMap(new Fun.Tuple2(segmentId, week), true, new Fun.Tuple2(segmentId, week), true); for(Object stats : subMap.values()) { summaryStatistics.add((SegmentStatistics)stats, segmentId); } } } return summaryStatistics; }
public SummaryStatistics collectSummaryStatistics(Set<Long> segmentIds, Boolean normalize, Set<Integer> weeks, Set<Integer>hours) { SummaryStatistics summaryStatistics = new SummaryStatistics(normalize, hours); for(Long segmentId : segmentIds) { if(weeks == null || weeks.size() == 0) { summaryStatistics.add(cumulativeStats.get(segmentId), segmentId); } else { for(Integer week : weeks) { NavigableMap<Fun.Tuple2<Long, Integer>, SegmentStatistics> subMap = statsMap.subMap(new Fun.Tuple2(segmentId, week), true, new Fun.Tuple2(segmentId, week), true); for(Object stats : subMap.values()) { summaryStatistics.add((SegmentStatistics)stats, segmentId); } } } } return summaryStatistics; }
public SummaryStatistics collectSummaryStatistics(Long segmentId, Boolean normalize, Integer week) { SummaryStatistics summaryStatistics = new SummaryStatistics(normalize, null); NavigableMap<Fun.Tuple2<Long, Integer>, SegmentStatistics> subMap; if(week == null){ summaryStatistics.add(cumulativeStats.get(segmentId), segmentId); } else { subMap = statsMap.subMap(new Fun.Tuple2(segmentId, week), true, new Fun.Tuple2(segmentId, week), true); for(SegmentStatistics stats : subMap.values()) { summaryStatistics.add(stats, segmentId); } } return summaryStatistics; }
final Object[] fromKeyArray = new Object[]{key.getHashValue(), ((TwoValueHolder)key.getRangeKey().getValue()).getValue1()}; final Object[] toKeyArray = new Object[]{key.getHashValue(), ((TwoValueHolder)key.getRangeKey().getValue()).getValue2()}; valueArrays = table.subMap(fromKeyArray, true, toKeyArray, true).values(); break; case EQUAL_TO:
@Override public DataSet getData(HistoDataSource datasource, QueryParams query) { Objects.requireNonNull(datasource); Objects.requireNonNull(query); log.info("getData " + query); DataSet result = new DataSet(); BTreeMap<HistoKey, Map<String, Object>> netMap = datasource.getMap(); List<Attribute> columns = query.getCols() != null ? query.getCols() : findAttributes(datasource.getReferenceNetwork(), query, true); long start = query.getStart() >= 0 ? query.getStart() : 0; long maxSize = query.getCount() >= 0 ? query.getCount() : Long.MAX_VALUE; result.addHeaders( query.getColumnStart() >= 0 && query.getColumnEnd() >= 0 ? columns.subList(query.getColumnStart(), query.getColumnEnd() < columns.size() ? query.getColumnEnd() + 1 : columns.size()) : columns); ConcurrentNavigableMap<HistoKey, Map<String, Object>> filtered = netMap.subMap( new HistoKey(query.getHorizon() != null ? query.getHorizon() : "", query.getTimeFrom(), query.getForecastTime() >= 0 ? query.getForecastTime() : Integer.MIN_VALUE), new HistoKey(query.getHorizon(), query.getTimeTo(), query.getForecastTime() >= 0 ? query.getForecastTime() : Integer.MAX_VALUE)); result.addAll(filtered.keySet().stream().filter(k -> matches(k, filtered.get(k), query)) .skip(start) .map(k -> filterColumns(filtered.get(k), query, columns)) .limit(maxSize) .collect(Collectors.toList())); return result; }
: columns); ConcurrentNavigableMap<HistoKey, Map<String, Object>> filtered = netMap.subMap( new HistoKey(HistoDbHorizon.DACF.toString(), query.getTimeFrom(), query.getForecastTime() >= 0 ? query.getForecastTime() : Integer.MIN_VALUE),