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


Java Object2ObjectMap类代码示例

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


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

示例1: writeProperties

import it.unimi.dsi.fastutil.objects.Object2ObjectMap; //导入依赖的package包/类
public void writeProperties(Object2ObjectOpenHashMap<String,DataRef> props) {
    try {
        writer.writeStartObject();
        for (Object2ObjectMap.Entry<String, DataRef> entry : props.object2ObjectEntrySet()) {
            writer.writeFieldName(entry.getKey());
            if(entry.getValue() instanceof CoreRef) {
                CoreRef prop =  (CoreRef)(entry.getValue());
                prop.write(propwriter);
            }
            else
                throw new UnsupportedOperationException("Only CoreRefs are supported for encoding.");
        }

        writer.writeEndObject();
    } catch (IOException e) {
        throw new IOError(e);
    }
}
 
开发者ID:marcusklang,项目名称:docforia,代码行数:19,代码来源:MemoryJsonLevel0Codec.java

示例2: compute

import it.unimi.dsi.fastutil.objects.Object2ObjectMap; //导入依赖的package包/类
public static void compute(OrientGraphFactory factory) {

//		GraphUtils.printGraph(factory);
        GraphAlgoEngine engine = new ParallelGraphEngine(factory);
        LabelPropagation lp = new LabelPropagation();
        engine.execute(lp);

        Object2ObjectMap<String, String> node2community = lp.getResult();
        engine.clean(lp);

//		node2community.entrySet().forEach(e -> {
//			System.out.println(e.getKey()+" -> "+e.getValue());
//		});

        Map<String, Long> frequencies = node2community.values().stream()
                .collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));

        frequencies.entrySet().stream().map(e -> e.getKey() + " " + e.getValue()).forEach(System.out::println);

        engine.shutdown();
    }
 
开发者ID:besil,项目名称:orientsna,代码行数:22,代码来源:OrientSNAMain.java

示例3: writeProperties

import it.unimi.dsi.fastutil.objects.Object2ObjectMap; //导入依赖的package包/类
private void writeProperties(Object2ObjectOpenHashMap<String,DataRef> props, Output writer) {
    BinaryCoreWriter propwriter = new BinaryCoreWriter(writer);
    writer.writeInt(props.size());
    for (Object2ObjectMap.Entry<String, DataRef> entry : props.object2ObjectEntrySet()) {
        writer.writeString(entry.getKey());
        if(entry.getValue() instanceof CoreRef) {
            CoreRef prop =  (CoreRef)(entry.getValue());
            writer.writeByte(prop.id().value);
            prop.write(propwriter);
        }
        else
            throw new UnsupportedOperationException("Only CoreRefs are supported for encoding.");
    }
}
 
开发者ID:marcusklang,项目名称:docforia,代码行数:15,代码来源:MemoryBinaryV1L0Codec.java

示例4: fastIterable

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

示例5: loadValues

import it.unimi.dsi.fastutil.objects.Object2ObjectMap; //导入依赖的package包/类
private static void loadValues(Object2ObjectMap<Object, Object> map, File file,
        PrimitiveObjectInspector keyOI, PrimitiveObjectInspector valueOI) throws IOException,
        SerDeException {
    if (!file.exists()) {
        return;
    }
    if (!file.getName().endsWith(".crc")) {
        if (file.isDirectory()) {
            for (File f : file.listFiles()) {
                loadValues(map, f, keyOI, valueOI);
            }
        } else {
            LazySimpleSerDe serde = HiveUtils.getKeyValueLineSerde(keyOI, valueOI);
            StructObjectInspector lineOI = (StructObjectInspector) serde.getObjectInspector();
            StructField keyRef = lineOI.getStructFieldRef("key");
            StructField valueRef = lineOI.getStructFieldRef("value");
            PrimitiveObjectInspector keyRefOI = (PrimitiveObjectInspector) keyRef.getFieldObjectInspector();
            PrimitiveObjectInspector valueRefOI = (PrimitiveObjectInspector) valueRef.getFieldObjectInspector();

            BufferedReader reader = null;
            try {
                reader = HadoopUtils.getBufferedReader(file);
                String line;
                while ((line = reader.readLine()) != null) {
                    Text lineText = new Text(line);
                    Object lineObj = serde.deserialize(lineText);
                    List<Object> fields = lineOI.getStructFieldsDataAsList(lineObj);
                    Object f0 = fields.get(0);
                    Object f1 = fields.get(1);
                    Object k = keyRefOI.getPrimitiveJavaObject(f0);
                    Object v = valueRefOI.getPrimitiveWritableObject(valueRefOI.copyObject(f1));
                    map.put(k, v);
                }
            } finally {
                IOUtils.closeQuietly(reader);
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:40,代码来源:DistributedCacheLookupUDF.java

示例6: simpleTest

import it.unimi.dsi.fastutil.objects.Object2ObjectMap; //导入依赖的package包/类
@Test
	public void simpleTest() {
		OrientGraphNoTx graph = getGraph();
		
		Vertex a = graph.addVertex(null), b = graph.addVertex(null), c = graph.addVertex(null);
		Vertex d = graph.addVertex(null), e = graph.addVertex(null), f = graph.addVertex(null);
		
		a.addEdge("CC", b);
		b.addEdge("CC", c);
		c.addEdge("CC", a);
		
		d.addEdge("CC", e);
		e.addEdge("CC", f);
		f.addEdge("CC", d);
		
		ConnectedComponents cc = new ConnectedComponents();
		GraphAlgoEngine engine = new ParallelGraphEngine(getFactory());
		engine.execute(cc);
		Object2ObjectMap<String, String> node2components = cc.getResult();
		
		String labela = node2components.get(a.getId().toString());
		String labelb = node2components.get(b.getId().toString());
		String labelc = node2components.get(c.getId().toString());
		
		String labeld = node2components.get(d.getId().toString());
		String labele = node2components.get(e.getId().toString());
		String labelf = node2components.get(f.getId().toString());
		
//		GraphUtils.printGraph(getFactory());
		
		Assert.assertEquals(labela, labelb);
		Assert.assertEquals(labelb, labelc);
		
		Assert.assertEquals(labeld, labele);
		Assert.assertEquals(labele, labelf);

	}
 
开发者ID:besil,项目名称:orientsna,代码行数:38,代码来源:ConnectedComponentsTest.java

示例7: testDisconnectedComponents

import it.unimi.dsi.fastutil.objects.Object2ObjectMap; //导入依赖的package包/类
@Test
public void testDisconnectedComponents() {
	Vertex a = getGraph().addVertex(null), b = getGraph().addVertex(null), c = getGraph().addVertex(null);
	Vertex d = getGraph().addVertex(null), e = getGraph().addVertex(null), f = getGraph().addVertex(null);
	
	a.addEdge("KNOWS", b);
	b.addEdge("KNOWS", c);
	c.addEdge("KNOWS", a);
	
	d.addEdge("KNOWS", e);
	e.addEdge("KNOWS", f);
	f.addEdge("KNOWS", d);
	getGraph().commit();
	
	LabelPropagation lp = new LabelPropagation();
	GraphAlgoEngine engine = new ParallelGraphEngine(getFactory());
	engine.execute(lp);
	
	Object2ObjectMap<String, String> vertex2community = lp.getResult();
	List<String> communities = vertex2community.values().stream().distinct().collect(Collectors.toList());
	Assert.assertEquals(2, communities.size());

	getGraph().getVertices().forEach(v -> Assert.assertTrue(v.getProperty(LabelPropagation.LP_COMMUNITY_KEY) != null));
	getGraph().getVertices().forEach(v -> Assert.assertTrue(v.getProperty(LabelPropagation.LP_COMPUTED_COMMUNITY_KEY) != null));
	
	engine.clean(lp);
	
	getGraph().getVertices().forEach(v -> Assert.assertFalse(v.getProperty(LabelPropagation.LP_COMMUNITY_KEY) != null));
	getGraph().getVertices().forEach(v -> Assert.assertFalse(v.getProperty(LabelPropagation.LP_COMPUTED_COMMUNITY_KEY) != null));
}
 
开发者ID:besil,项目名称:orientsna,代码行数:31,代码来源:LabelPropagationTest.java

示例8: logClusterSizes

import it.unimi.dsi.fastutil.objects.Object2ObjectMap; //导入依赖的package包/类
/**
 * Log cluster sizes in verbose mode.
 * 
 * @param msg Log message
 * @param dimensionality Dimensionality
 * @param clustersMap Cluster map
 */
private void logClusterSizes(String m, int dimensionality, Object2ObjectOpenCustomHashMap<long[], List<ArrayModifiableDBIDs>> clustersMap) {
  if(LOG.isVerbose()) {
    final StringBuilder msg = new StringBuilder(1000).append(m).append('\n');
    for(ObjectIterator<Object2ObjectMap.Entry<long[], List<ArrayModifiableDBIDs>>> iter = clustersMap.object2ObjectEntrySet().fastIterator(); iter.hasNext();) {
      Object2ObjectMap.Entry<long[], List<ArrayModifiableDBIDs>> entry = iter.next();
      msg.append(BitsUtil.toStringLow(entry.getKey(), dimensionality)).append(" sizes:");
      for(ArrayModifiableDBIDs c : entry.getValue()) {
        msg.append(' ').append(c.size());
      }
      msg.append('\n');
    }
    LOG.verbose(msg.toString());
  }
}
 
开发者ID:elki-project,项目名称:elki,代码行数:22,代码来源:DiSH.java

示例9: sortClusters

import it.unimi.dsi.fastutil.objects.Object2ObjectMap; //导入依赖的package包/类
/**
 * Returns a sorted list of the clusters w.r.t. the subspace dimensionality in
 * descending order.
 *
 * @param relation the database storing the objects
 * @param clustersMap the mapping of bits sets to clusters
 * @return a sorted list of the clusters
 */
private List<Cluster<SubspaceModel>> sortClusters(Relation<V> relation, Object2ObjectMap<long[], List<ArrayModifiableDBIDs>> clustersMap) {
  final int db_dim = RelationUtil.dimensionality(relation);
  // int num = 1;
  List<Cluster<SubspaceModel>> clusters = new ArrayList<>();
  for(long[] pv : clustersMap.keySet()) {
    List<ArrayModifiableDBIDs> parallelClusters = clustersMap.get(pv);
    for(int i = 0; i < parallelClusters.size(); i++) {
      ArrayModifiableDBIDs c = parallelClusters.get(i);
      Cluster<SubspaceModel> cluster = new Cluster<>(c);
      cluster.setModel(new SubspaceModel(new Subspace(pv), Centroid.make(relation, c).getArrayRef()));
      String subspace = BitsUtil.toStringLow(cluster.getModel().getSubspace().getDimensions(), db_dim);
      if(parallelClusters.size() > 1) {
        cluster.setName("Cluster_" + subspace + "_" + i);
      }
      else {
        cluster.setName("Cluster_" + subspace);
      }
      clusters.add(cluster);
    }
  }
  // sort the clusters w.r.t. lambda
  Comparator<Cluster<SubspaceModel>> comparator = new Comparator<Cluster<SubspaceModel>>() {
    @Override
    public int compare(Cluster<SubspaceModel> c1, Cluster<SubspaceModel> c2) {
      return c2.getModel().getSubspace().dimensionality() - c1.getModel().getSubspace().dimensionality();
    }
  };
  Collections.sort(clusters, comparator);
  return clusters;
}
 
开发者ID:elki-project,项目名称:elki,代码行数:39,代码来源:DiSH.java

示例10: findParent

import it.unimi.dsi.fastutil.objects.Object2ObjectMap; //导入依赖的package包/类
/**
 * Returns the parent of the specified cluster
 *
 * @param relation the relation storing the objects
 * @param child the child to search the parent for
 * @param clustersMap the map containing the clusters
 * @return the parent of the specified cluster
 */
private Pair<long[], ArrayModifiableDBIDs> findParent(Relation<V> relation, Pair<long[], ArrayModifiableDBIDs> child, Object2ObjectMap<long[], List<ArrayModifiableDBIDs>> clustersMap) {
  Centroid child_centroid = ProjectedCentroid.make(child.first, relation, child.second);

  Pair<long[], ArrayModifiableDBIDs> result = null;
  int resultCardinality = -1;

  long[] childPV = child.first;
  int childCardinality = BitsUtil.cardinality(childPV);
  for(long[] parentPV : clustersMap.keySet()) {
    int parentCardinality = BitsUtil.cardinality(parentPV);
    if(parentCardinality >= childCardinality) {
      continue;
    }
    if(resultCardinality != -1 && parentCardinality <= resultCardinality) {
      continue;
    }

    long[] pv = BitsUtil.andCMin(childPV, parentPV);
    if(BitsUtil.equal(pv, parentPV)) {
      List<ArrayModifiableDBIDs> parentList = clustersMap.get(parentPV);
      for(ArrayModifiableDBIDs parent : parentList) {
        NumberVector parent_centroid = ProjectedCentroid.make(parentPV, relation, parent);
        double d = weightedDistance(child_centroid, parent_centroid, parentPV);
        if(d <= 2 * epsilon) {
          result = new Pair<>(parentPV, parent);
          resultCardinality = parentCardinality;
          break;
        }
      }
    }
  }

  return result;
}
 
开发者ID:elki-project,项目名称:elki,代码行数:43,代码来源:DiSH.java

示例11: RegExpMatcher

import it.unimi.dsi.fastutil.objects.Object2ObjectMap; //导入依赖的package包/类
private RegExpMatcher(IRegExp<S> state,
        Object2ObjectMap<IRegExp<S>,Object2ObjectMap<S,IRegExp<S>>> stateTransitions,
        ObjectSet<IRegExp<S>> nonFinal) {
    this.state = state;
    this.stateTransitions = stateTransitions;
    this.nonFinal = nonFinal;
    this.alphabet = state.getBuilder().getAlphabet();
}
 
开发者ID:metaborg,项目名称:nabl,代码行数:9,代码来源:RegExpMatcher.java

示例12: getMap

import it.unimi.dsi.fastutil.objects.Object2ObjectMap; //导入依赖的package包/类
@Nonnull
Object2ObjectMap<String, Entry> getMap() {
    return _map;
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:5,代码来源:FMStringFeatureMapModel.java

示例13: getResult

import it.unimi.dsi.fastutil.objects.Object2ObjectMap; //导入依赖的package包/类
@Override
public Object2ObjectMap<String, String> getResult() {
	return result;
}
 
开发者ID:besil,项目名称:orientsna,代码行数:5,代码来源:ConnectedComponents.java

示例14: getWordMap

import it.unimi.dsi.fastutil.objects.Object2ObjectMap; //导入依赖的package包/类
/**
 * Gets the dictionary mapping the words to their vectors
 * 
 * @return the dictionary.
 */
public Object2ObjectMap<String, AbstractDoubleList> getWordMap() {
	return wordMap;
}
 
开发者ID:felipebravom,项目名称:AffectiveTweets,代码行数:9,代码来源:EmbeddingHandler.java

示例15: SimpleEnumMap

import it.unimi.dsi.fastutil.objects.Object2ObjectMap; //导入依赖的package包/类
/**
 * Creates a new hash map copying a given type-specific one.
 *
 * @param m a type-specific map to be copied into the new hash map.
 * @param f the load factor.
 */
public SimpleEnumMap(final Object2ObjectMap<K, V> m, final float f)
{
    super(m, f, (Strategy) SimpleEnumHashingStrategy.INSTANCE);
}
 
开发者ID:Diorite,项目名称:Diorite-old,代码行数:11,代码来源:SimpleEnumMap.java


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