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


Java Fun类代码示例

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


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

示例1: compare

import org.mapdb.Fun; //导入依赖的package包/类
public int compare(Object[] keys, int pos, Object[] tuple) {
    pos*=tsize;
    int len = Math.min(tuple.length, tsize);
    int r;
    //$DELAY$
    for(int i=0;i<len;i++){
        Object tval = tuple[i];
        if(tval==null)
            return -1;
        //$DELAY$
        r = comparators[i].compare(keys[pos++],tval);
        if(r!=0)
            return r;
    }
    return Fun.compareInt(tsize, tuple.length);
}
 
开发者ID:simonstey,项目名称:SecureLinkedData,代码行数:17,代码来源:ObjectKeySerializer.java

示例2: 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);
	}
}
 
开发者ID:opentraffic,项目名称:traffic-engine,代码行数:20,代码来源:VehicleStates.java

示例3: 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();
		}
	}
 
开发者ID:opentraffic,项目名称:traffic-engine,代码行数:20,代码来源:OSMDataStore.java

示例4: getStreetSegmentsBySegmentId

import org.mapdb.Fun; //导入依赖的package包/类
public List<SpatialDataItem> getStreetSegmentsBySegmentId(Fun.Tuple3<Long, Long, Long> segmentId) {
	List<SpatialDataItem> edges = new ArrayList<>();

	StreetSegment sdi = (StreetSegment)osmData.streetSegments.getBySegmentId(segmentId);
	if(sdi == null) {
		Jumper j = osmData.jumperDataStore.getJumper(segmentId.b, segmentId.c);
		if (j != null) {
			for (long id : j.segments) {
				sdi = (StreetSegment) osmData.streetSegments.getById(id);
				if (sdi != null)
					edges.add(sdi);
			}
		}
	}
	else
		edges.add(sdi);

	return edges;
}
 
开发者ID:opentraffic,项目名称:traffic-engine,代码行数:20,代码来源:TrafficEngine.java

示例5: loadOneRow

import org.mapdb.Fun; //导入依赖的package包/类
@Override
public void loadOneRow() throws IOException {
    StopTime st = new StopTime();
    st.sourceFileLine = row + 1; // offset line number by 1 to account for 0-based row index
    st.trip_id        = getStringField("trip_id", true);
    // TODO: arrival_time and departure time are not required, but if one is present the other should be
    // also, if this is the first or last stop, they are both required
    st.arrival_time   = getTimeField("arrival_time", false);
    st.departure_time = getTimeField("departure_time", false);
    st.stop_id        = getStringField("stop_id", true);
    st.stop_sequence  = getIntField("stop_sequence", true, 0, Integer.MAX_VALUE);
    st.stop_headsign  = getStringField("stop_headsign", false);
    st.pickup_type    = getIntField("pickup_type", false, 0, 3); // TODO add ranges as parameters
    st.drop_off_type  = getIntField("drop_off_type", false, 0, 3);
    st.shape_dist_traveled = getDoubleField("shape_dist_traveled", false, 0D, Double.MAX_VALUE); // FIXME using both 0 and NaN for "missing", define DOUBLE_MISSING
    st.timepoint      = getIntField("timepoint", false, 0, 1, INT_MISSING);
    st.feed           = null; // this could circular-serialize the whole feed
    feed.stop_times.put(new Fun.Tuple2(st.trip_id, st.stop_sequence), st);

    /*
      Check referential integrity without storing references. StopTime cannot directly reference Trips or
      Stops because they would be serialized into the MapDB.
     */
    getRefField("trip_id", true, feed.trips);
    getRefField("stop_id", true, feed.stops);
}
 
开发者ID:conveyal,项目名称:gtfs-lib,代码行数:27,代码来源:StopTime.java

示例6: getAverageSpeedForTrips

import org.mapdb.Fun; //导入依赖的package包/类
/**
 * Get average speed for set of trips that begin within the time window in meters per second.
 * @param trips
 * @param from
 * @param to
 * @return avg. speed (meters per second)
 */
public double getAverageSpeedForTrips (Collection<Trip> trips, LocalTime from, LocalTime to) {
    TDoubleList speeds = new TDoubleArrayList();

    for (Trip trip : trips) {
        StopTime firstStopTime = feed.stop_times.ceilingEntry(Fun.t2(trip.trip_id, null)).getValue();
        LocalTime tripBeginTime = LocalTime.ofSecondOfDay(firstStopTime.departure_time % 86399); // convert 24hr+ seconds to 0 - 86399

        // skip trip if begin time is before or after specified time period
        if (tripBeginTime.isAfter(to) || tripBeginTime.isBefore(from)) {
            continue;
        }
        // TODO: swap straight lines for actual geometry?
        double speed = feed.getTripSpeed(trip.trip_id, true);

        if (!Double.isNaN(speed)) {
            speeds.add(speed);
        }
    }

    if (speeds.isEmpty()) return -1;

    return speeds.sum() / speeds.size();
}
 
开发者ID:conveyal,项目名称:gtfs-lib,代码行数:31,代码来源:PatternStats.java

示例7: getTripSpeed

import org.mapdb.Fun; //导入依赖的package包/类
/** Get trip speed in meters per second. */
public double getTripSpeed (String trip_id, boolean straightLine) {

    StopTime firstStopTime = this.stop_times.ceilingEntry(Fun.t2(trip_id, null)).getValue();
    StopTime lastStopTime = this.stop_times.floorEntry(Fun.t2(trip_id, Fun.HI)).getValue();

    // ensure that stopTime returned matches trip id (i.e., that the trip has stoptimes)
    if (!firstStopTime.trip_id.equals(trip_id) || !lastStopTime.trip_id.equals(trip_id)) {
        return Double.NaN;
    }

    double distance = getTripDistance(trip_id, straightLine);

    // trip time (in seconds)
    int time = lastStopTime.arrival_time - firstStopTime.departure_time;

    return distance / time; // meters per second
}
 
开发者ID:conveyal,项目名称:gtfs-lib,代码行数:19,代码来源:GTFSFeed.java

示例8: testOSM

import org.mapdb.Fun; //导入依赖的package包/类
public void testOSM(){
	OSM osm = new OSM("./src/test/resources/tmp");
	osm.readFromFile("./src/test/resources/bangor_maine.osm.pbf");
	assertEquals( osm.nodes.size(), 35747 );
	assertEquals( osm.ways.size(), 2976 );
	assertEquals( osm.relations.size(), 34 );

	// make sure the indices work
	for (Map.Entry<Long, Relation> e : osm.relations.entrySet()) {
		Relation relation = e.getValue();
		long id = e.getKey();
		// Tested: Bangor contains relations with way, node, and relation members
		for (Relation.Member member : relation.members) {
			if (member.type == OSMEntity.Type.NODE)
				assertTrue(osm.relationsByNode.contains(Fun.t2(member.id, id)));
			else if (member.type == OSMEntity.Type.WAY)
				assertTrue(osm.relationsByWay.contains(Fun.t2(member.id, id)));
			else if (member.type == OSMEntity.Type.RELATION)
				assertTrue(osm.relationsByRelation.contains(Fun.t2(member.id, id)));
		}
	}
}
 
开发者ID:conveyal,项目名称:osm-lib,代码行数:23,代码来源:OSMTest.java

示例9: compile

import org.mapdb.Fun; //导入依赖的package包/类
static void compile(String file, String database){
	DB db = DBMaker.newFileDB(new File(database)).compressionEnable().closeOnJvmShutdown().make();
	NavigableSet<Tuple2<String, Tuple2<String,Double>>> multiset = db.getTreeSet("SW");
	multiset.clear();
	try {
		BufferedReader swFile = new BufferedReader(new InputStreamReader(new BZip2InputStream(new FileInputStream(new File(file)), false), "UTF-8"));
		int entry = 0;
		for(String line=swFile.readLine();line != null;line = swFile.readLine()){
			String key = line.trim();
			String[] values = swFile.readLine().trim().split(" ");
			for(int i = 1;i < values.length;i += 2){
				multiset.add(Fun.t2(key, Fun.t2(values[i-1], Double.parseDouble(values[i]))));
			}
			if(entry++ > 100){
				db.commit();
				entry = 0;
			}
		}
		swFile.close();
	} catch (IOException e) {
		e.printStackTrace();
	}
	db.commit();
	db.close();
}
 
开发者ID:tticoin,项目名称:JointER,代码行数:26,代码来源:NICTNounSynonymsDB.java

示例10: createIndexes

import org.mapdb.Fun; //导入依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes"})
protected void createIndexes(DB database)
{
	//HEIGHT INDEX
	Tuple2Comparator<Integer, byte[]> comparator = new Fun.Tuple2Comparator<Integer, byte[]>(Fun.COMPARATOR, UnsignedBytes.lexicographicalComparator());
	NavigableSet<Tuple2<Integer, byte[]>> heightIndex = database.createTreeSet("blocks_index_height")
			.comparator(comparator)
			.makeOrGet();
	
	NavigableSet<Tuple2<Integer, byte[]>> descendingHeightIndex = database.createTreeSet("blocks_index_height_descending")
			.comparator(new ReverseComparator(comparator))
			.makeOrGet();
	
	createIndex(HEIGHT_INDEX, heightIndex, descendingHeightIndex, new Fun.Function2<Integer, byte[], Block>() {
	   	@Override
	    public Integer run(byte[] key, Block value) {
	   		return value.getHeight();
	    }
	});
}
 
开发者ID:razakal,项目名称:Qora,代码行数:21,代码来源:BlockMap.java

示例11: openMap

import org.mapdb.Fun; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private Map<BigInteger, Order> openMap(DB database)
{
	//OPEN MAP
	BTreeMap<BigInteger, Order> map = database.createTreeMap("orders")
			.valueSerializer(new OrderSerializer())
			.makeOrGet();
	
	//HAVE/WANT KEY
	this.haveWantKeyMap = database.createTreeMap("orders_key_have_want")
			.comparator(Fun.COMPARATOR)
			.makeOrGet();
	
	//BIND HAVE/WANT KEY
	Bind.secondaryKey(map, this.haveWantKeyMap, new Fun.Function2<Tuple4<Long, Long, BigDecimal, BigInteger>, BigInteger, Order>() {
		@Override
		public Tuple4<Long, Long, BigDecimal, BigInteger> run(BigInteger key, Order value) {
			return new Tuple4<Long, Long, BigDecimal, BigInteger>(value.getHave(), value.getWant(), value.getPrice(), key);
		}	
	});
	
	//RETURN
	return map;
}
 
开发者ID:razakal,项目名称:Qora,代码行数:25,代码来源:OrderMap.java

示例12: createIndexes

import org.mapdb.Fun; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
protected void createIndexes(DB database)
{
	//AMOUNT INDEX
	NavigableSet<Tuple2<BigDecimal, String>> namesIndex = database.createTreeSet("namesales_index_amount")
			.comparator(Fun.COMPARATOR)
			.makeOrGet();
	
	NavigableSet<Tuple2<BigDecimal, String>> descendingNamesIndex = database.createTreeSet("namesales_index_amount_descending")
			.comparator(new ReverseComparator(Fun.COMPARATOR))
			.makeOrGet();
	
	createIndex(AMOUNT_INDEX, namesIndex, descendingNamesIndex, new Fun.Function2<BigDecimal, String, BigDecimal>() {
	   	@Override
	    public BigDecimal run(String key, BigDecimal value) {
	   		return value;
	    }
	});
}
 
开发者ID:razakal,项目名称:Qora,代码行数:20,代码来源:NameExchangeMap.java

示例13: createIndexes

import org.mapdb.Fun; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
protected void createIndexes(DB database)
{
	//TIMESTAMP INDEX
	Tuple2Comparator<Long, byte[]> comparator = new Fun.Tuple2Comparator<Long, byte[]>(Fun.COMPARATOR, UnsignedBytes.lexicographicalComparator());
	NavigableSet<Tuple2<Integer, byte[]>> heightIndex = database.createTreeSet("transactions_index_timestamp")
			.comparator(comparator)
			.makeOrGet();
			
	NavigableSet<Tuple2<Integer, byte[]>> descendingHeightIndex = database.createTreeSet("transactions_index_timestamp_descending")
			.comparator(new ReverseComparator(comparator))
			.makeOrGet();
			
	createIndex(TIMESTAMP_INDEX, heightIndex, descendingHeightIndex, new Fun.Function2<Long, byte[], Transaction>() {
	   	@Override
	    public Long run(byte[] key, Transaction value) {
	   		return value.getTimestamp();
	    }
	});
}
 
开发者ID:razakal,项目名称:Qora,代码行数:21,代码来源:TransactionMap.java

示例14: get

import org.mapdb.Fun; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
public List<NameSale> get(Account account)
{
	List<NameSale> nameSales = new ArrayList<NameSale>();
	
	try
	{
		Map<Tuple2<String, String>, BigDecimal> accountNames = ((BTreeMap) this.map).subMap(
				Fun.t2(account.getAddress(), null),
				Fun.t2(account.getAddress(), Fun.HI()));
		
		for(Entry<Tuple2<String, String>, BigDecimal> entry: accountNames.entrySet())
		{
			NameSale nameSale = new NameSale(entry.getKey().b, entry.getValue());
			nameSales.add(nameSale);
		}
	}
	catch(Exception e)
	{
		//ERROR
		e.printStackTrace();
	}
	
	return nameSales;
}
 
开发者ID:razakal,项目名称:Qora,代码行数:26,代码来源:NameSaleMap.java

示例15: getTradesSortableList

import org.mapdb.Fun; //导入依赖的package包/类
@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);
}
 
开发者ID:razakal,项目名称:Qora,代码行数:22,代码来源:TradeMap.java


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