本文整理汇总了Java中org.mapdb.Fun.Tuple2方法的典型用法代码示例。如果您正苦于以下问题:Java Fun.Tuple2方法的具体用法?Java Fun.Tuple2怎么用?Java Fun.Tuple2使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mapdb.Fun
的用法示例。
在下文中一共展示了Fun.Tuple2方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: placeVehicleInTile
import org.mapdb.Fun; //导入方法依赖的package包/类
public void placeVehicleInTile(Fun.Tuple2<Integer, Integer> tile, Long vehicleId) {
synchronized (vehicleCache) {
if(!tileVehicleMap.containsKey(tile)) {
tileVehicleMap.put(tile, new ConcurrentHashMap<>());
}
if(!tileCount.containsKey(tile)){
tileCount.put(tile, new AtomicInteger());
}
if(tileVehicleMap.get(tile).containsKey(vehicleId)) {
tileCount.get(tile).decrementAndGet();
tileVehicleMap.get(tile).remove(vehicleId);
}
tileCount.get(tile).incrementAndGet();
tileVehicleMap.get(tile).put(vehicleId, true);
}
}
示例2: loadPbfFile
import org.mapdb.Fun; //导入方法依赖的package包/类
public void loadPbfFile(Fun.Tuple2<Integer, Integer> tile, Envelope env, File pbfFile) {
log.log(Level.INFO, "loading osm from: " + pbfFile.getAbsolutePath());
// load pbf osm source and merge into traffic engine
OSM osm = new OSM(null);
osm.readFromFile(pbfFile.getAbsolutePath().toString());
try {
// add OSM an truncate geometries
OSMArea osmArea = addOsm(tile, env, osm, false);
}
catch (Exception e) {
e.printStackTrace();
log.log(Level.SEVERE, "Unable to load osm: " + pbfFile.getAbsolutePath());
}
finally {
osm.close();
}
}
示例3: getVehicleTilePoints
import org.mapdb.Fun; //导入方法依赖的package包/类
public List<GPSPoint> getVehicleTilePoints(Fun.Tuple2<Integer, Integer> tile) {
List<GPSPoint> points = new ArrayList<>();
if(tileVehicleMap.containsKey(tile)) {
for (Long vehicleId : tileVehicleMap.get(tile).keySet()) {
points.add(vehicleCache.get(vehicleId).lastPoint);
}
}
return points;
}
示例4: sortByValue
import org.mapdb.Fun; //导入方法依赖的package包/类
public static Map<Fun.Tuple2<Integer, Integer>, AtomicInteger> sortByValue(Map<Fun.Tuple2<Integer, Integer>, AtomicInteger> map)
{
Map<Fun.Tuple2<Integer, Integer>, AtomicInteger> result = new LinkedHashMap<>();
Stream<Map.Entry<Fun.Tuple2<Integer, Integer>, AtomicInteger>> st = map.entrySet().stream();
Comparator<Map.Entry<Fun.Tuple2<Integer, Integer>, AtomicInteger>> comparator = Comparator.comparing(e -> e.getValue().get());
st.sorted(comparator.reversed())
.forEach(e -> result.put(e.getKey(), e.getValue()));
return result;
}
示例5: checkOsm
import org.mapdb.Fun; //导入方法依赖的package包/类
public OSMArea checkOsm(double lat, double lon) {
Fun.Tuple2<Integer, Integer> tile = getOsmId(lat, lon);
if(!osmAreas.containsKey(tile)){
synchronized (this){
loadingOSM = true;
loadOSMTile(tile);
loadingOSM = false;
}
}
return osmAreas.get(tile);
}
示例6: getOrderedStopTimesForTrip
import org.mapdb.Fun; //导入方法依赖的package包/类
/**
* 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();
}
示例7: testInternalExecute
import org.mapdb.Fun; //导入方法依赖的package包/类
@Test
public void testInternalExecute() throws Exception {
Fun.Tuple2<String, File> checkout = checkoutProject();
assertTrue(new File(checkout.b, "_site").exists());
assertTrue(new File(checkout.b, ".style").exists());
BuildInfo buildInfo = db.get(checkout.a, BuildInfo.class);
assertEquals(1, buildInfo.getPartialStatuses().size());
assertEquals("ok", buildInfo.getPartialStatuses().get("jekyll").getStatus());
}
示例8: checkoutProject
import org.mapdb.Fun; //导入方法依赖的package包/类
protected Fun.Tuple2<String, File> checkoutProject() {
PushEvent pushEvent = new PushEvent();
pushEvent.setRepository(new Repository());
pushEvent.getRepository().setUrl("ssh://github.com/tunguski/kosher.git");
pushEvent.getRepository().setGit_http_url("http://github.com/tunguski/kosher.git");
pushEvent.getRepository().setGit_ssh_url("[email protected]:tunguski/kosher.git");
pushEvent.setRef("refs/heads/master");
pushEvent.setAfter("78af4d73667e3ef4bbb06e82270e0015a1f251ea");
String idBuild = buildService.pushEvent(pushEvent);
File repository = gitRepositoryService.repository(pushEvent);
return new Fun.Tuple2(idBuild, repository);
}
示例9: testInternalExecute
import org.mapdb.Fun; //导入方法依赖的package包/类
@Test
public void testInternalExecute() throws Exception {
Fun.Tuple2<String, File> checkout = checkoutProject();
assertTrue(new File(checkout.b, "target/cobertura").exists());
BuildInfo buildInfo = db.get(checkout.a, BuildInfo.class);
assertEquals(1, buildInfo.getPartialStatuses().size());
assertEquals("ok", buildInfo.getPartialStatuses().get("cobertura").getStatus());
}
示例10: testInternalExecute
import org.mapdb.Fun; //导入方法依赖的package包/类
@Test
public void testInternalExecute() throws Exception {
Fun.Tuple2<String, File> checkout = checkoutProject();
// fixme:
// assertTrue(new File(checkout.b, "target/javancss-result.xml").exists());
//
// BuildInfo buildInfo = db.get(checkout.a, BuildInfo.class);
//
// assertEquals(1, buildInfo.getPartialStatuses().size());
// assertEquals("ok", buildInfo.getPartialStatuses().get("javancss").getStatus());
}
示例11: copyDataToFile
import org.mapdb.Fun; //导入方法依赖的package包/类
private BTreeMap<String, Long> copyDataToFile(
BTreeMap<Fun.Tuple2<String, Long>,Long > dbMap, DB fileDb ) {
Iterator<Fun.Tuple2<String, Long>> sortIterator = Pump.sort(dbMap.keySet().iterator(), true, 100000, Collections.reverseOrder(BTreeMap.COMPARABLE_COMPARATOR), // reverse
// order
// comparator
fileDb.getDefaultSerializer());
BTreeMap<String, Long> make = fileDb.createTreeMap("map").pumpSource(sortIterator)
// .pumpPresort(100000) // for presorting data we could also use this method
.keySerializer(BTreeKeySerializer.STRING).makeOrGet();
return make;
}
示例12: testHugeDataForTreeMap
import org.mapdb.Fun; //导入方法依赖的package包/类
@Test
public void testHugeDataForTreeMap() throws UnsupportedEncodingException{
setStartT();
DB fileDb =DBMaker.newTempFileDB().asyncWriteFlushDelay(100).closeOnJvmShutdown().transactionDisable().make();
// BTreeMap<Long, String> dbMap = fileDb.createTreeMap("test").keySerializer(BTreeKeySerializer.ZERO_OR_POSITIVE_LONG).valueSerializer(Serializer.STRING).make();
HTreeMap<Long, String> dbMap = fileDb.createHashMap("test").keySerializer(Serializer.LONG).valueSerializer(Serializer.STRING).make();
// HTreeMap<Long, String> dbMap = fileDb.createHashMap("test").keySerializer(Serializer.LONG).valueSerializer(Serializer.STRING).make();
NavigableSet<Fun.Tuple2<String, Long>> inverseMapping = new TreeSet<Fun.Tuple2<String, Long>>();
Bind.mapInverse(dbMap, inverseMapping);
Store store = Store.forDB(fileDb);
boolean memoryIsOut=false;
int tempIndex=1;
for(int index=0;index<5e4;index++){
for(String[] dataItem:initData()){
dbMap.put(Long.valueOf(tempIndex),ConvertToKey(dataItem));
tempIndex++;
}
}
// System.out.println("Key for 'value' size is: "+inverseMapping.subSet(Fun.t2("name5id5city5", (Long)null), Fun.t2("name5id5city5", (Long)Fun.HI)));
System.out.println(store.getCurrSize()/1024);
ellipseT();
// computeResult(dbMap);
ellipseT();
// Assert.assertEquals(10l, distinctCount.longValue());
Assert.assertEquals(20l, rowCount.longValue());
Assert.assertEquals(uniqueCount.longValue(), distinctCount.longValue()-duplicateCount.longValue());
// Assert.assertEquals(0l, uniqueCount.longValue());
// Assert.assertEquals(10l, duplicateCount.longValue());
fileDb.close();
}
示例13: getVehicleTileCount
import org.mapdb.Fun; //导入方法依赖的package包/类
public Integer getVehicleTileCount(Fun.Tuple2<Integer, Integer> tile) {
if(tileCount.containsKey(tile))
return tileCount.get(tile).get();
else
return 0;
}
示例14: loadOSMTile
import org.mapdb.Fun; //导入方法依赖的package包/类
public void loadOSMTile(Fun.Tuple2<Integer, Integer> tile) {
if(osmAreas.containsKey(tile))
return;
File zDir = new File(osmPath, "" + Z_INDEX);
File xDir = new File(zDir, "" + tile.a);
File pbfFile = new File(xDir, tile.b + ".osm.pbf");
Envelope env = SpatialDataStore.tile2Envelope(tile.a, tile.b, Z_INDEX);
if(!pbfFile.exists()) {
xDir.mkdirs();
Double south = env.getMinY() < env.getMaxY() ? env.getMinY() : env.getMaxY();
Double west = env.getMinX() < env.getMaxX() ? env.getMinX() : env.getMaxX();
Double north = env.getMinY() > env.getMaxY() ? env.getMinY() : env.getMaxY();
Double east = env.getMinX() > env.getMaxX() ? env.getMinX() : env.getMaxX();
String vexUrl = osmServer + "";
if (!vexUrl.endsWith("/"))
vexUrl += "/";
vexUrl += String.format("%.6f,%.6f,%.6f,%.6f.pbf", south, west, north, east);
HttpURLConnection conn;
log.log(Level.INFO, "loading osm from: " + vexUrl);
try {
conn = (HttpURLConnection) new URL(vexUrl).openConnection();
conn.connect();
if (conn.getResponseCode() != HttpURLConnection.HTTP_OK) {
System.err.println("Received response code " +
conn.getResponseCode() + " from vex server");
return;
}
// download the file
InputStream is = conn.getInputStream();
OutputStream os = new FileOutputStream(pbfFile);
ByteStreams.copy(is, os);
is.close();
os.close();
loadPbfFile(tile, env, pbfFile);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else
loadPbfFile(tile, env, pbfFile);
}
示例15: testInternalExecute
import org.mapdb.Fun; //导入方法依赖的package包/类
@Test
public void testInternalExecute() throws Exception {
Fun.Tuple2<String, File> checkout = checkoutProject();
// fixme: check generated report
}