com.hazelcast.jet.Util.entry()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(7.0k)|赞(0)|评价(0)|浏览(226)

本文整理了Java中com.hazelcast.jet.Util.entry()方法的一些代码示例,展示了Util.entry()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.entry()方法的具体详情如下:
包路径:com.hazelcast.jet.Util
类名称:Util
方法名:entry

Util.entry介绍

[英]Returns a Map.Entry with the given key and value.
[中]返回一张地图。输入给定的键和值。

代码示例

代码示例来源:origin: hazelcast/hazelcast-jet-code-samples

  1. private Entry<Long, Double> tfidfEntry(double logDf, Entry<Long, Double> docidTf) {
  2. Long docId = docidTf.getKey();
  3. double tf = docidTf.getValue();
  4. double idf = logDocCount - logDf;
  5. return entry(docId, tf * idf);
  6. }
  7. }

代码示例来源:origin: hazelcast/hazelcast-jet-code-samples

  1. private static Entry<String, Double> tfidfEntry(double logDocCount, double logDf, Entry<String, Long> docIdTf) {
  2. String docId = docIdTf.getKey();
  3. double tf = docIdTf.getValue();
  4. double idf = logDocCount - logDf;
  5. return entry(docId, tf * idf);
  6. }
  7. }

代码示例来源:origin: hazelcast/hazelcast-jet-code-samples

  1. private static Entry<Long, Double> tfidfEntry(Entry<Entry<Long, String>, Long> tfEntry, Double idf) {
  2. final Long tf = tfEntry.getValue();
  3. return entry(tfEntry.getKey().getKey(), tf * idf);
  4. }
  5. }

代码示例来源:origin: hazelcast/hazelcast-jet-code-samples

  1. private static Entry<String, Double> tfidfEntry(Entry<Entry<String, String>, Long> tfEntry, Double idf) {
  2. final Long tf = tfEntry.getValue();
  3. return entry(tfEntry.getKey().getKey(), tf * idf);
  4. }
  5. }

代码示例来源:origin: hazelcast/hazelcast-jet-code-samples

  1. static Stream<Entry<String, String>> docLines(String name) {
  2. try {
  3. return Files.lines(Paths.get(TfIdfJdkStreams.class.getResource("books/" + name).toURI()))
  4. .map(String::toLowerCase)
  5. .map(line -> entry(name, line));
  6. } catch (IOException | URISyntaxException e) {
  7. throw new RuntimeException(e);
  8. }
  9. }

代码示例来源:origin: hazelcast/hazelcast-jet-code-samples

  1. private static Stream<Entry<Long, String>> tokenize(Entry<Long, String> docLine) {
  2. return Arrays.stream(TfIdfJdkStreams.DELIMITER.split(docLine.getValue()))
  3. .filter(token -> !token.isEmpty())
  4. .map(word -> entry(docLine.getKey(), word));
  5. }
  6. }

代码示例来源:origin: hazelcast/hazelcast-jet-code-samples

  1. @Override
  2. @SuppressWarnings("unchecked")
  3. protected boolean tryProcess1(@Nonnull Object item) {
  4. Entry<Entry<Long, String>, Long> e = (Entry<Entry<Long, String>, Long>) item;
  5. long docId = e.getKey().getKey();
  6. String word = e.getKey().getValue();
  7. long tf = e.getValue();
  8. wordDocTf.computeIfAbsent(word, w -> new ArrayList<>())
  9. .add(entry(docId, (double) tf));
  10. return true;
  11. }

代码示例来源:origin: hazelcast/hazelcast-jet-code-samples

  1. private Stream<Entry<Long, String>> tokenize(Entry<Long, String> docLine) {
  2. return Arrays.stream(DELIMITER.split(docLine.getValue()))
  3. .filter(token -> !token.isEmpty())
  4. .filter(token -> !stopwords.contains(token))
  5. .map(word -> entry(docLine.getKey(), word));
  6. }

代码示例来源:origin: hazelcast/hazelcast-jet-code-samples

  1. private static Stream<Entry<String, String>> tokenize(Entry<String, String> docLine) {
  2. return Arrays.stream(TfIdfJdkStreams.DELIMITER.split(docLine.getValue()))
  3. .filter(token -> !token.isEmpty())
  4. .map(word -> entry(docLine.getKey(), word));
  5. }
  6. }

代码示例来源:origin: hazelcast/hazelcast-jet-code-samples

  1. static Stream<Entry<Long, String>> docLines(Entry<Long, String> idAndName) {
  2. try {
  3. return Files.lines(Paths.get(TfIdfJdkStreams.class.getResource("books/" + idAndName.getValue()).toURI()))
  4. .map(String::toLowerCase)
  5. .map(line -> entry(idAndName.getKey(), line));
  6. } catch (IOException | URISyntaxException e) {
  7. throw new RuntimeException(e);
  8. }
  9. }

代码示例来源:origin: hazelcast/hazelcast-jet-code-samples

  1. private Entry<String, List<Entry<Long, Double>>> toInvertedIndexEntry(
  2. Entry<String, List<Entry<Long, Double>>> wordDocTf
  3. ) {
  4. String word = wordDocTf.getKey();
  5. List<Entry<Long, Double>> docidTfs = wordDocTf.getValue();
  6. return entry(word, docScores(docidTfs));
  7. }

代码示例来源:origin: hazelcast/hazelcast-jet-code-samples

  1. private static Entry<String, Collection<Entry<String, Double>>> toInvertedIndexEntry(
  2. double logDocCount,
  3. String word,
  4. Collection<Entry<String, Long>> docIdTfs
  5. ) {
  6. return entry(word, docScores(logDocCount, docIdTfs));
  7. }

代码示例来源:origin: hazelcast/hazelcast-jet

  1. /**
  2. * Convenience for {@link #kafka(Properties, DistributedFunction, String...)}
  3. * wrapping the output in {@code Map.Entry}.
  4. */
  5. @Nonnull
  6. public static <K, V> StreamSource<Entry<K, V>> kafka(
  7. @Nonnull Properties properties,
  8. @Nonnull String ... topics
  9. ) {
  10. return KafkaSources.<K, V, Entry<K, V>>kafka(properties, r -> entry(r.key(), r.value()), topics);
  11. }

代码示例来源:origin: com.hazelcast.jet/hazelcast-jet-kafka

  1. /**
  2. * Convenience for {@link #kafka(Properties, DistributedFunction, String...)}
  3. * wrapping the output in {@code Map.Entry}.
  4. */
  5. @Nonnull
  6. public static <K, V> StreamSource<Entry<K, V>> kafka(
  7. @Nonnull Properties properties,
  8. @Nonnull String ... topics
  9. ) {
  10. return KafkaSources.<K, V, Entry<K, V>>kafka(properties, r -> entry(r.key(), r.value()), topics);
  11. }

代码示例来源:origin: hazelcast/hazelcast-jet-demos

  1. /**
  2. * The actual classification of the images by using the pre-trained model.
  3. */
  4. private static Entry<String, Double> classifyWithModel(ImageClassifierVggCifar10 classifier, BufferedImage image) {
  5. Planar<GrayF32> planar = new Planar<>(GrayF32.class, image.getWidth(), image.getHeight(), 3);
  6. ConvertBufferedImage.convertFromPlanar(image, planar, true, GrayF32.class);
  7. classifier.classify(planar);
  8. return classifier.getAllResults().stream()
  9. .map(score -> entry(classifier.getCategories().get(score.category), score.score))
  10. .max(Comparator.comparing(Entry::getValue)).get();
  11. }

代码示例来源:origin: hazelcast/hazelcast-jet

  1. /**
  2. * Returns a projection that converts the {@link EventJournalCacheEvent} to a
  3. * {@link java.util.Map.Entry} using the event's new value as a value.
  4. *
  5. * @see Sources#cacheJournal
  6. * @see Sources#remoteCacheJournal
  7. */
  8. public static <K, V> DistributedFunction<EventJournalCacheEvent<K, V>, Entry<K, V>> cacheEventToEntry() {
  9. return e -> entry(e.getKey(), e.getNewValue());
  10. }

代码示例来源:origin: hazelcast/hazelcast-jet

  1. /**
  2. * Returns a projection that converts the {@link EventJournalMapEvent} to a
  3. * {@link java.util.Map.Entry} using the event's new value as a value.
  4. *
  5. * @see Sources#mapJournal
  6. * @see Sources#remoteMapJournal
  7. */
  8. public static <K, V> DistributedFunction<EventJournalMapEvent<K, V>, Entry<K, V>> mapEventToEntry() {
  9. return e -> entry(e.getKey(), e.getNewValue());
  10. }

代码示例来源:origin: hazelcast/hazelcast-jet

  1. @Override
  2. public Entry read(ObjectDataInput in) throws IOException {
  3. return entry(in.readObject(), in.readObject());
  4. }

代码示例来源:origin: hazelcast/hazelcast-jet-code-samples

  1. private static Pipeline buildPipeline(String connectionUrl) {
  2. Pipeline p = Pipeline.create();
  3. p.drawFrom(Sources.jdbc(connectionUrl,
  4. "SELECT * FROM " + TABLE_NAME,
  5. resultSet -> new User(resultSet.getInt(1), resultSet.getString(2))))
  6. .map(user -> Util.entry(user.getId(), user))
  7. .drainTo(Sinks.map(MAP_NAME));
  8. return p;
  9. }

代码示例来源:origin: hazelcast/hazelcast-jet-code-samples

  1. private static Pipeline buildPipeline() {
  2. Pipeline p = Pipeline.create();
  3. p.drawFrom(AvroSources.filesBuilder(AvroSink.DIRECTORY_NAME, ReflectDatumReader<User>::new)
  4. //Both Jet members share the same local file system
  5. .sharedFileSystem(true)
  6. .build())
  7. .map(user -> Util.entry(user.getUsername(), user))
  8. .drainTo(Sinks.map(AvroSink.MAP_NAME));
  9. return p;
  10. }

相关文章