scala.collection.JavaConverters.asScalaSetConverter()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(76)

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

JavaConverters.asScalaSetConverter介绍

暂无

代码示例

代码示例来源:origin: uber/marmaray

public static <T> Set<T> toScalaSet(@NonNull final java.util.Set<T> javaSet) {
  return JavaConverters.asScalaSetConverter(javaSet).asScala().<T>toSet();
}

代码示例来源:origin: com.uber.hoodie/hoodie-utilities

public static Set<String> toScalaSet(HashSet<String> s) {
 return JavaConverters.asScalaSetConverter(s).asScala().toSet();
}

代码示例来源:origin: uber/hudi

public static Set<String> toScalaSet(HashSet<String> s) {
 return JavaConverters.asScalaSetConverter(s).asScala().toSet();
}

代码示例来源:origin: apache/incubator-sentry

@Override
  public Void run(SentryGenericServiceClient client) throws Exception {
    for (String role : roles) {
      final Set<TSentryPrivilege> rolePrivileges = client.listPrivilegesByRoleName(
        requestorName, role, COMPONENT_NAME, instanceName);
      final scala.collection.immutable.Set<TSentryPrivilege> rolePrivilegesScala =
        scala.collection.JavaConverters.asScalaSetConverter(rolePrivileges).asScala().toSet();
      rolePrivilegesMap.put(role, rolePrivilegesScala);
    }
    return null;
  }
});

代码示例来源:origin: apache/samza

JavaConverters.asScalaSetConverter(systemStreamToSsp.keySet()).asScala().toSet(), false)).asJava();

代码示例来源:origin: org.apache.samza/samza-core_2.12

JavaConverters.asScalaSetConverter(systemStreamToSsp.keySet()).asScala().toSet(), false)).asJava();

代码示例来源:origin: org.apache.samza/samza-core_2.11

JavaConverters.asScalaSetConverter(systemStreamToSsp.keySet()).asScala().toSet(), false)).asJava();

代码示例来源:origin: org.apache.samza/samza-core_2.10

JavaConverters.asScalaSetConverter(systemStreamToSsp.keySet()).asScala().toSet(), false)).asJava();

代码示例来源:origin: org.apache.samza/samza-core

JavaConverters.asScalaSetConverter(systemStreamToSsp.keySet()).asScala().toSet(), false)).asJava();

代码示例来源:origin: apache/samza

/**
 * Get the oldest offset for each changelog SSP based on the stream's metadata (obtained from streamMetadataCache).
 */
private void getOldestChangeLogOffsets() {
 Map<SystemStream, SystemStreamMetadata> changeLogMetadata = JavaConverters.mapAsJavaMapConverter(
   streamMetadataCache.getStreamMetadata(
     JavaConverters.asScalaSetConverter(new HashSet<>(changelogSystemStreams.values())).asScala().toSet(),
     false)).asJava();
 LOG.info("Got change log stream metadata: {}", changeLogMetadata);
 changeLogOldestOffsets =
   getChangeLogOldestOffsetsForPartition(taskModel.getChangelogPartition(), changeLogMetadata);
 LOG.info("Assigning oldest change log offsets for taskName {} : {}", taskModel.getTaskName(),
   changeLogOldestOffsets);
}

代码示例来源:origin: com.twitter/util-core_2.11

/**
 * Converts a {@link java.util.Set} to an immutable Scala Set.
 *
 * See scala.collection.JavaConverters.asScalaSet if you do
 * not need the returned Set to be immutable.
 *
 * @return an empty Set if the input is null.
 */
@SuppressWarnings("unchecked")
public static <E> scala.collection.immutable.Set<E> asImmutableSet(
  java.util.Set<E> jSet
) {
 if (jSet == null) {
  return scala.collection.immutable.Set$.MODULE$.<E>empty();
 } else {
  //TODO: After dropping support for 2.11.x, replace with
  //JavaConverters.asScalaSet(jSet).toSet
  return JavaConverters.asScalaSetConverter(jSet).asScala().toSet();
 }
}

代码示例来源:origin: com.twitter/util-core_2.12

/**
 * Converts a {@link java.util.Set} to an immutable Scala Set.
 *
 * See scala.collection.JavaConverters.asScalaSet if you do
 * not need the returned Set to be immutable.
 *
 * @return an empty Set if the input is null.
 */
@SuppressWarnings("unchecked")
public static <E> scala.collection.immutable.Set<E> asImmutableSet(
  java.util.Set<E> jSet
) {
 if (jSet == null) {
  return scala.collection.immutable.Set$.MODULE$.<E>empty();
 } else {
  //TODO: After dropping support for 2.11.x, replace with
  //JavaConverters.asScalaSet(jSet).toSet
  return JavaConverters.asScalaSetConverter(jSet).asScala().toSet();
 }
}

代码示例来源:origin: apache/samza

/**
 * Gets the metadata for all the specified system streams from the provided metadata cache.
 * Handles scala-java conversions.
 *
 * @param streamsToMonitor  the set of system streams for which the metadata is needed.
 * @param metadataCache     the metadata cache which will be used to fetch metadata.
 * @return                  a map from each system stream to its metadata.
 */
private static Map<SystemStream, SystemStreamMetadata> getMetadata(Set<SystemStream> streamsToMonitor,
  StreamMetadataCache metadataCache) {
 return JavaConverters
   .mapAsJavaMapConverter(
     metadataCache.getStreamMetadata(
       JavaConverters.asScalaSetConverter(streamsToMonitor).asScala().toSet(),
       true
     )
   ).asJava();
}

代码示例来源:origin: org.apache.samza/samza-core_2.11

/**
 * Gets the metadata for all the specified system streams from the provided metadata cache.
 * Handles scala-java conversions.
 *
 * @param streamsToMonitor  the set of system streams for which the metadata is needed.
 * @param metadataCache     the metadata cache which will be used to fetch metadata.
 * @return                  a map from each system stream to its metadata.
 */
private static Map<SystemStream, SystemStreamMetadata> getMetadata(Set<SystemStream> streamsToMonitor,
  StreamMetadataCache metadataCache) {
 return JavaConverters
   .mapAsJavaMapConverter(
     metadataCache.getStreamMetadata(
       JavaConverters.asScalaSetConverter(streamsToMonitor).asScala().toSet(),
       true
     )
   ).asJava();
}

代码示例来源:origin: org.apache.samza/samza-core_2.12

/**
 * Gets the metadata for all the specified system streams from the provided metadata cache.
 * Handles scala-java conversions.
 *
 * @param streamsToMonitor  the set of system streams for which the metadata is needed.
 * @param metadataCache     the metadata cache which will be used to fetch metadata.
 * @return                  a map from each system stream to its metadata.
 */
private static Map<SystemStream, SystemStreamMetadata> getMetadata(Set<SystemStream> streamsToMonitor,
  StreamMetadataCache metadataCache) {
 return JavaConverters
   .mapAsJavaMapConverter(
     metadataCache.getStreamMetadata(
       JavaConverters.asScalaSetConverter(streamsToMonitor).asScala().toSet(),
       true
     )
   ).asJava();
}

代码示例来源:origin: org.apache.samza/samza-core_2.10

/**
 * Gets the metadata for all the specified system streams from the provided metadata cache.
 * Handles scala-java conversions.
 *
 * @param streamsToMonitor  the set of system streams for which the metadata is needed.
 * @param metadataCache     the metadata cache which will be used to fetch metadata.
 * @return                  a map from each system stream to its metadata.
 */
private static Map<SystemStream, SystemStreamMetadata> getMetadata(Set<SystemStream> streamsToMonitor,
  StreamMetadataCache metadataCache) {
 return JavaConverters
   .mapAsJavaMapConverter(
     metadataCache.getStreamMetadata(
       JavaConverters.asScalaSetConverter(streamsToMonitor).asScala().toSet(),
       true
     )
   ).asJava();
}

代码示例来源:origin: org.apache.samza/samza-core

/**
 * Gets the metadata for all the specified system streams from the provided metadata cache.
 * Handles scala-java conversions.
 *
 * @param streamsToMonitor  the set of system streams for which the metadata is needed.
 * @param metadataCache     the metadata cache which will be used to fetch metadata.
 * @return                  a map from each system stream to its metadata.
 */
private static Map<SystemStream, SystemStreamMetadata> getMetadata(Set<SystemStream> streamsToMonitor,
  StreamMetadataCache metadataCache) {
 return JavaConverters
   .mapAsJavaMapConverter(
     metadataCache.getStreamMetadata(
       JavaConverters.asScalaSetConverter(streamsToMonitor).asScala().toSet(),
       true
     )
   ).asJava();
}

代码示例来源:origin: apache/samza

asScalaSetConverter(new HashSet<SystemStream>(changelogSystemStreams.values())).asScala().toSet(), false))
.thenReturn(
  new scala.collection.immutable.Map.Map1(new SystemStream(SYSTEM_NAME, STREAM_NAME), systemStreamMetadata));

代码示例来源:origin: apache/samza

TaskInstance createTaskInstance(AsyncStreamTask task, TaskName taskName, SystemStreamPartition ssp, OffsetManager manager, SystemConsumers consumers) {
 TaskModel taskModel = mock(TaskModel.class);
 when(taskModel.getTaskName()).thenReturn(taskName);
 TaskInstanceMetrics taskInstanceMetrics = new TaskInstanceMetrics("task", new MetricsRegistryMap());
 scala.collection.immutable.Set<SystemStreamPartition> sspSet = JavaConverters.asScalaSetConverter(Collections.singleton(ssp)).asScala().toSet();
 return new TaskInstance(task,
   taskModel,
   taskInstanceMetrics,
   null,
   consumers,
   mock(TaskInstanceCollector.class),
   manager,
   null,
   null,
   null,
   sspSet,
   new TaskInstanceExceptionHandler(taskInstanceMetrics, new scala.collection.immutable.HashSet<String>()),
   null,
   null,
   null,
   new scala.collection.immutable.HashSet<>(),
   null,
   mock(JobContext.class),
   mock(ContainerContext.class),
   Option.apply(null),
   Option.apply(null),
   Option.apply(null));
}

相关文章