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


Java Int2LongMap类代码示例

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


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

示例1: phase3

import it.unimi.dsi.fastutil.ints.Int2LongMap; //导入依赖的package包/类
public void phase3(int id) {
    Map<Integer, Int2LongMap> h = JCL_FacadeImpl.GetHashMap(String.valueOf(id));
    Int2LongMap result = new Int2LongOpenHashMap();
    for (Int2LongMap m : h.values()) {
        for (int i : m.keySet()) {
            if (result.containsKey(i)) {
                long j = m.get(i) + result.get(i);
                result.put(i, j);
            } else {
                result.put(i, m.get(i));
            }
        }
        m.clear();
    }
    long freqT = 0;
    for (Long v : result.values())
        freqT += v;
    System.err.println("ID: " + id + " size: " + result.size() + " freqT: " + freqT);

    h.clear();
    h.put(id, result);
    // result.clear();
    // result = null;
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:25,代码来源:Sorting.java

示例2: findParent

import it.unimi.dsi.fastutil.ints.Int2LongMap; //导入依赖的package包/类
/**
 * Find the parent entity for each.
 *
 * @param parents Parent counter map
 * @param parent Parent storage (output)
 * @param cnt Count storage (output)
 */
private void findParent(Int2LongOpenHashMap[] parents, int[] parent, long[] cnt) {
  parent[0] = 0;
  cnt[0] = Long.MAX_VALUE;
  for(int i = 1; i < parents.length; i++) {
    int best = i;
    long total = 0, bcount = -1;
    for(Int2LongMap.Entry p : parents[i].int2LongEntrySet()) {
      final long c = p.getLongValue();
      total += c;
      if(c > bcount || (c == bcount && c < best)) {
        bcount = c;
        best = p.getIntKey();
      }
    }
    cnt[i] = total;
    parent[i] = best;
  }
}
 
开发者ID:kno10,项目名称:reversegeocode,代码行数:26,代码来源:BuildLayeredIndexSliced.java

示例3: fastIterable

import it.unimi.dsi.fastutil.ints.Int2LongMap; //导入依赖的package包/类
@Nonnull
public static ObjectIterable<Int2LongMap.Entry> fastIterable(@Nonnull final Int2LongMap map) {
    final ObjectSet<Int2LongMap.Entry> entries = map.int2LongEntrySet();
    return entries instanceof Int2LongMap.FastEntrySet ? new ObjectIterable<Int2LongMap.Entry>() {
        public ObjectIterator<Int2LongMap.Entry> iterator() {
            return ((Int2LongMap.FastEntrySet) entries).fastIterator();
        }
    }
            : entries;
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:11,代码来源:Fastutil.java

示例4: buildInputDataPartitionSchema

import it.unimi.dsi.fastutil.ints.Int2LongMap; //导入依赖的package包/类
private String buildInputDataPartitionSchema(List<JCL_result> r, int numOfJCLThreads){
	
	IntSet sorted = new IntAVLTreeSet();
	long totalF=0;
	Int2LongMap map = new Int2LongOpenHashMap();
	
	for(JCL_result oneR:r){
		
		try{
			@SuppressWarnings("unchecked")
			List<String> l = (List<String>) oneR.getCorrectResult();
			
			for(String s : l){
				String[] args = s.split(":");
				int key = Integer.parseInt(args[0]); long freq = Long.parseLong(args[1]);
				sorted.add(key);
		
				if(map.containsKey(key)){
					freq+=map.get(key);	
					totalF+=map.get(key);
				} else totalF+=freq;
				
				map.put(key, freq);
			}
			
		}catch(Exception e){}
	}
	
	long load=0; int b; String result = "";
	for(int ac:sorted){
		load += map.get(ac);
		if(load > (totalF/(numOfJCLThreads))){					
			b=ac;
			result += b + ":";				
			load=0;
		}	
	}		
	
	return result;
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:41,代码来源:Main.java

示例5: getGroupStats

import it.unimi.dsi.fastutil.ints.Int2LongMap; //导入依赖的package包/类
@Override
public Iterator<GroupStats> getGroupStats(final EZImhotepSession session, final Map<Integer, GroupKey> groupKeys, final List<StatReference> statRefs, final long timeoutTS) throws ImhotepOutOfMemoryException {
    if(groupKeys.isEmpty()) {   // we don't have any parent groups probably because all docs were filtered out
        return Collections.<GroupStats>emptyList().iterator();
    }
    final StatReference countStatRef = session.pushStat(countStat);
    final long[] counts = getCounts(countStatRef);

    final Int2ObjectMap<Int2LongMap> groupToPositionToStats = getPercentileStats(session, groupKeys, countStatRef, counts);

    final List<GroupStats> result = Lists.newArrayList();

    final int statCount = statRefs.size();
    final int groupCount = session.getNumGroups();

    // get values for the normal stats
    final TIntObjectHashMap<double[]> statsResults = (statCount > 0) ? getGroupStatsValues(session, statRefs, groupCount) : null;

    // combine normal stats with distinct counts
    for (int groupNum = 1; groupNum < groupCount; groupNum++) {
        final Int2LongMap groupPercentileData = groupToPositionToStats.get(groupNum);
        double[] statsVals = statsResults != null ? statsResults.get(groupNum) : null;

        double[] values = new double[statCount + fields.size()];
        for(int i = 0, statsValsIndex = 0; i < values.length; i++) {
            if(groupPercentileData != null && groupPercentileData.containsKey(i)) {    // percentile value
                values[i] = groupPercentileData.get(i);
            } else if(statsVals != null && statsValsIndex < statsVals.length) {
                values[i] = statsVals[statsValsIndex++];    // normal stat value available
            } else {
                values[i] = 0;  // normal stat not in stats array
            }
        }

        GroupKey groupKey = groupKeys.get(groupNum);
        result.add(new GroupStats(groupKey, values));
    }

    return result.iterator();
}
 
开发者ID:indeedeng,项目名称:iql,代码行数:41,代码来源:PercentileGrouping.java

示例6: forwardModel

import it.unimi.dsi.fastutil.ints.Int2LongMap; //导入依赖的package包/类
@Override
protected void forwardModel() throws HiveException {
    this._model = null;
    this._fieldList = null;
    this._sumVfX = null;

    final int factors = _factors;
    final IntWritable idx = new IntWritable();
    final FloatWritable Wi = new FloatWritable(0.f);
    final FloatWritable[] Vi = HiveUtils.newFloatArray(factors, 0.f);
    final List<FloatWritable> ViObj = Arrays.asList(Vi);

    final Object[] forwardObjs = new Object[4];
    String modelId = HadoopUtils.getUniqueTaskIdString();
    forwardObjs[0] = new Text(modelId);
    forwardObjs[1] = idx;
    forwardObjs[2] = Wi;
    forwardObjs[3] = null; // Vi

    // W0
    idx.set(0);
    Wi.set(_ffmModel.getW0());
    forward(forwardObjs);

    final Entry entryW = new Entry(_ffmModel._buf, 1);
    final Entry entryV = new Entry(_ffmModel._buf, _ffmModel._factor);
    final float[] Vf = new float[factors];

    for (Int2LongMap.Entry e : Fastutil.fastIterable(_ffmModel._map)) {
        // set i
        final int i = e.getIntKey();
        idx.set(i);

        final long offset = e.getLongValue();
        if (Entry.isEntryW(i)) {// set Wi
            entryW.setOffset(offset);
            float w = entryV.getW();
            if (w == 0.f) {
                continue; // skip w_i=0
            }
            Wi.set(w);
            forwardObjs[2] = Wi;
            forwardObjs[3] = null;
        } else {// set Vif
            entryV.setOffset(offset);
            entryV.getV(Vf);
            for (int f = 0; f < factors; f++) {
                Vi[f].set(Vf[f]);
            }
            forwardObjs[2] = null;
            forwardObjs[3] = ViObj;
        }

        forward(forwardObjs);
    }
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:57,代码来源:FieldAwareFactorizationMachineUDTF.java

示例7: phase1

import it.unimi.dsi.fastutil.ints.Int2LongMap; //导入依赖的package包/类
public List<String> phase1(int id, String name, int numJCLThreads) {
    Int2LongMap values = new Int2LongOpenHashMap(1000000);
    long totalF = 0;
    System.err.println("file: " + name);
    try {
        File f = new File("../" + name + "/" + name + ".bin");
        InputStream in = new BufferedInputStream(new FileInputStream(f));
        FastBufferedInputStream fb = new FastBufferedInputStream(in);
        byte[] i = new byte[4];
        while (fb.read(i) == 4) {
            int k = java.nio.ByteBuffer.wrap(i).getInt();
            if (!values.containsKey(k))
                values.put(k, 1);
            else {
                long aux = values.get(k);
                aux++;
                values.put(k, aux);
            }
            totalF++;
        }
        fb.close();
        in.close();
        
        // primeira modificacao
        //for (long v : values.values())
        //    totalF += v;
        
        IntSet sorted = new IntAVLTreeSet(values.keySet());
        long acumula = 0;
        int b = 0;
        List<String> result = new LinkedList<>();
        long blinha = 0; 
        int last = 0;
        for (int ac : sorted) {
            blinha = values.get(ac);
            acumula += blinha;
            if (acumula > (totalF / (numJCLThreads))) {
                b = ac;
                result.add(b + ":" + acumula);
                acumula = 0;
            }
            last = ac;
        }
        
        // segunda modificacao
        if(acumula != 0) result.add(last + ":" + acumula);
        
        JCL_facade jcl = JCL_FacadeImpl.getInstanceLambari();
        jcl.instantiateGlobalVar(id, values);
        sorted.clear();
        sorted = null;
        return result;

    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:59,代码来源:Sorting.java

示例8: phase2

import it.unimi.dsi.fastutil.ints.Int2LongMap; //导入依赖的package包/类
public void phase2(int id, int numJCLThreads, String schema) {
    JCL_facade jcl = JCL_FacadeImpl.getInstanceLambari();
    Int2LongMap sorted = (Int2LongMap) jcl.getValue(id).getCorrectResult();
    jcl.deleteGlobalVar(id);
    String[] chunks = schema.split(":");
    int i = 0;
    Int2LongMap[] finais = new Int2LongMap[numJCLThreads];
    for (int r = 0; r < numJCLThreads; r++)
        finais[r] = new Int2LongOpenHashMap();
    for (int ii : sorted.keySet()) {
        i = 0;
        if (ii >= Integer.parseInt(chunks[chunks.length - 1]))
            finais[numJCLThreads - 1].put(ii, sorted.get(ii));
        else {
            if (ii < Integer.parseInt(chunks[0]))
                finais[0].put(ii, sorted.get(ii));
            else {
                tag: {
                    for (int k = 1; k < chunks.length; k++) {
                        if (Integer.parseInt(chunks[i]) <= ii && ii < Integer.parseInt(chunks[k])) {
                            finais[i + 1].put(ii, sorted.get(ii));
                            break tag;
                        }
                        i++;
                    }
                }
            }
        }
    }

    for (int r = 0; r < numJCLThreads; r++) {
        if(!finais[r].isEmpty()) {
            JCL_map<Integer, Int2LongMap> h = new JCLHashMap<>(String.valueOf(r));
            h.put(id, finais[r]);
            long fT = 0;
            for (long kk : finais[r].values())
                fT += kk;
            System.err.println(finais[r].size() + ":" + fT + " phase 2 putting in jcl - thread id " + r);
            finais[r].clear();
            finais[r] = null;
        }
    }
    sorted.clear();
    sorted = null;
    chunks = null;
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:47,代码来源:Sorting.java

示例9: int2LongMap

import it.unimi.dsi.fastutil.ints.Int2LongMap; //导入依赖的package包/类
public static Int2LongMap int2LongMap() {
		return new Int2LongOpenHashMap();
//		return new Int2LongAVLTreeMap();
	}
 
开发者ID:besil,项目名称:AuroraGraphManager,代码行数:5,代码来源:MapFactory.java


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