org.mapdb.Fun.Tuple3 Java Examples
The following examples show how to use
org.mapdb.Fun.Tuple3.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StreetDataStore.java From traffic-engine with GNU General Public License v3.0 | 6 votes |
@Override public void save(List<SpatialDataItem> objs) { List<SpatialDataItem> segments = new ArrayList<SpatialDataItem>(); for(SpatialDataItem obj : objs) { Tuple3 segmentId = ((StreetSegment)obj).getSegmentId(); if (segmentIndex.containsKey(segmentId)) continue; segments.add(obj); segmentIndex.put(segmentId, obj.id); } super.save(segments); }
Example #2
Source File: StreetDataStore.java From traffic-engine with GNU General Public License v3.0 | 6 votes |
@Override public void delete(List<SpatialDataItem> objs) { List<SpatialDataItem> segments = new ArrayList<SpatialDataItem>(); for(SpatialDataItem obj : objs) { Tuple3 segmentId = ((StreetSegment)obj).getSegmentId(); if (!segmentIndex.containsKey(segmentId)) continue; segments.add(obj); segmentIndex.remove(segmentId); } super.delete(segments); }
Example #3
Source File: TradeMap.java From Qora with MIT License | 6 votes |
@SuppressWarnings({ "unchecked", "rawtypes" }) public SortableList<Tuple2<BigInteger, BigInteger>, Trade> getTradesSortableList(long have, long want) { String pairKey; if(have > want) { pairKey = have + "/" + want; } else { pairKey = want + "/" + have; } //FILTER ALL KEYS Collection<Tuple2<BigInteger, BigInteger>> keys = ((BTreeMap<Tuple3, Tuple2<BigInteger, BigInteger>>) this.pairKeyMap).subMap( Fun.t3(pairKey, null, null), Fun.t3(pairKey, Fun.HI(), Fun.HI())).values(); //RETURN return new SortableList<Tuple2<BigInteger, BigInteger>, Trade>(this, keys); }
Example #4
Source File: StreetDataStore.java From traffic-engine with GNU General Public License v3.0 | 5 votes |
@Override public void delete(SpatialDataItem obj) { Tuple3 segmentId = ((StreetSegment)obj).getSegmentId(); segmentIndex.remove(segmentId); super.delete(obj); }
Example #5
Source File: SpatialDataStore.java From traffic-engine with GNU General Public License v3.0 | 5 votes |
public void save(SpatialDataItem obj) { map.put(obj.id, obj); for(Tuple3<Integer, Integer, Long> tuple : obj.getTiles(Z_INDEX)) { tileIndex.add(tuple); } db.commit(); }
Example #6
Source File: SpatialDataStore.java From traffic-engine with GNU General Public License v3.0 | 5 votes |
public void save(List<SpatialDataItem> objs) { for(SpatialDataItem obj : objs) { if (map.containsKey(obj.id)) continue; map.put(obj.id, obj); for (Tuple3<Integer, Integer, Long> tuple : obj.getTiles(Z_INDEX)) { tileIndex.add(tuple); } } db.commit(); }
Example #7
Source File: SpatialDataStore.java From traffic-engine with GNU General Public License v3.0 | 5 votes |
public void delete(List<SpatialDataItem> objs) { for (SpatialDataItem obj : objs) { if(!map.containsKey(obj.id)) continue; map.remove(obj.id); for (Tuple3<Integer, Integer, Long> tuple : obj.getTiles(Z_INDEX)) { tileIndex.remove(tuple); } } db.commit(); }
Example #8
Source File: SpatialDataStore.java From traffic-engine with GNU General Public License v3.0 | 5 votes |
public void delete(SpatialDataItem obj) { map.remove(obj.id); for(Tuple3<Integer, Integer, Long> tuple : obj.getTiles(Z_INDEX)) { tileIndex.remove(tuple); } db.commit(); }
Example #9
Source File: OSM.java From osm-lib with BSD 2-Clause "Simplified" License | 5 votes |
/** * Insert the given way into the tile-based spatial index, based on its current node locations in the database. * If the way does not exist, this method does nothing (leaving any reference to the way in the index) because * it can't know anything about the location of a way that's already deleted. If the way object is not supplied * it will be looked up by its ID. */ public void indexWay(long wayId, Way way) { // We could also insert using ((float)lat, (float)lon) as a key // but depending on whether MapDB does tree path compression this might take more space WebMercatorTile tile = tileForWay(wayId, way); if (tile == null) { LOG.debug("Attempted insert way {} into the spatial index, but it is not currently in the database.", wayId); } else { this.index.add(new Tuple3(tile.xtile, tile.ytile, wayId)); } }
Example #10
Source File: OSM.java From osm-lib with BSD 2-Clause "Simplified" License | 5 votes |
public void unIndexWay(long wayId) { Way way = ways.get(wayId); if (way == null) { LOG.debug("Attempted to remove way {} from the spatial index, but it is not currently in the database.", wayId); } else { WebMercatorTile tile = tileForWay(wayId, way); if (tile != null) { this.index.remove(new Tuple3(tile.xtile, tile.ytile, wayId)); } } }
Example #11
Source File: BalanceMap.java From Qora with MIT License | 5 votes |
@SuppressWarnings({ "unchecked"}) @Override protected Map<Tuple2<String, Long>, BigDecimal> getMap(DB database) { //OPEN MAP BTreeMap<Tuple2<String, Long>, BigDecimal> map = database.createTreeMap("balances") .keySerializer(BTreeKeySerializer.TUPLE2) .counterEnable() .makeOrGet(); //HAVE/WANT KEY this.assetKeyMap = database.createTreeMap("balances_key_asset") .comparator(Fun.COMPARATOR) .counterEnable() .makeOrGet(); //BIND ASSET KEY Bind.secondaryKey(map, this.assetKeyMap, new Fun.Function2<Tuple3<Long, BigDecimal, String>, Tuple2<String, Long>, BigDecimal>() { @Override public Tuple3<Long, BigDecimal, String> run(Tuple2<String, Long> key, BigDecimal value) { return new Tuple3<Long, BigDecimal, String>(key.b, value.negate(), key.a); } }); //RETURN return map; }
Example #12
Source File: BalanceMap.java From Qora with MIT License | 5 votes |
@SuppressWarnings({ "unchecked", "rawtypes" }) public SortableList<Tuple2<String, Long>, BigDecimal> getBalancesSortableList(long key) { //FILTER ALL KEYS Collection<Tuple2<String, Long>> keys = ((BTreeMap<Tuple3, Tuple2<String, Long>>) this.assetKeyMap).subMap( Fun.t3(key, null, null), Fun.t3(key, Fun.HI(), Fun.HI())).values(); //RETURN return new SortableList<Tuple2<String, Long>, BigDecimal>(this, keys); }
Example #13
Source File: StreetDataStore.java From traffic-engine with GNU General Public License v3.0 | 4 votes |
public SpatialDataItem getBySegmentId(Tuple3<Long, Long, Long> segmentId) { if(!segmentIndex.containsKey(segmentId)) return null; return map.get(segmentIndex.get(segmentId)); }
Example #14
Source File: StreetDataStore.java From traffic-engine with GNU General Public License v3.0 | 4 votes |
public boolean contains(Tuple3<Long, Long, Long> segmentId) { return segmentIndex.containsKey(segmentId); }
Example #15
Source File: SpatialDataStore.java From traffic-engine with GNU General Public License v3.0 | 4 votes |
public List<Long> getIdsByEnvelope(Envelope env) { int y1 = getTileY(env.getMinY(), Z_INDEX); int x1 = getTileX(env.getMinX(), Z_INDEX); int y2 = getTileY(env.getMaxY(), Z_INDEX); int x2 = getTileX(env.getMaxX(), Z_INDEX); int minY; int maxY; int minX; int maxX; if(x1 < x2) { minX = x1; maxX = x2; } else { minX = x2; maxX = x1; } if(y1 < y2) { minY = y1; maxY = y2; } else { minY = y2; maxY = y1; } minX--; maxX++; minY--; maxY++; List<Long> ids = new ArrayList(); for(int tileX = minX; tileX <= maxX; tileX++) { NavigableSet<Tuple3<Integer, Integer, Long>> xSubset = tileIndex.subSet( new Tuple3(tileX, minY, null), true, // inclusive lower bound, null tests lower than anything new Tuple3(tileX, maxY, Fun.HI), true // inclusive upper bound, HI tests higher than anything ); for (Tuple3<Integer, Integer, Long> item : xSubset) { ids.add(item.c); } } return ids; }
Example #16
Source File: StreetDataStore.java From traffic-engine with GNU General Public License v3.0 | 3 votes |
public void save(SpatialDataItem obj) { Tuple3 segmentId = ((StreetSegment)obj).getSegmentId(); if (segmentIndex.containsKey(segmentId)) return; segmentIndex.put(segmentId, obj.id); super.save(obj); }