本文整理汇总了Java中scala.collection.JavaConversions.asJavaIterable方法的典型用法代码示例。如果您正苦于以下问题:Java JavaConversions.asJavaIterable方法的具体用法?Java JavaConversions.asJavaIterable怎么用?Java JavaConversions.asJavaIterable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scala.collection.JavaConversions
的用法示例。
在下文中一共展示了JavaConversions.asJavaIterable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: select
import scala.collection.JavaConversions; //导入方法依赖的package包/类
@Override
public Routee select(Object message, IndexedSeq<Routee> routees) {
//find which product ID is relevant here
String productId = null;
if(message instanceof PurchaseOrder){
productId = ((PurchaseOrder) message).getProductId();
}else if(message instanceof SalesOrder){
productId = ((SalesOrder) message).getProductId();
}
ActorRef actorHandlingProduct = kids.get(productId);
//no go find the routee for the relevant actor
for(Routee r : JavaConversions.asJavaIterable(routees)){
ActorRef a = ((ActorRefRoutee) r).ref(); //cast ok, since the are by definition in this program all routees to ActorRefs
if(a.equals(actorHandlingProduct)){
return r;
}
}
return akka.routing.NoRoutee$.MODULE$; //none found, return NoRoutee
}
示例2: refresh
import scala.collection.JavaConversions; //导入方法依赖的package包/类
public static void refresh() {
if (null == CONTEXT)
throw new IllegalStateException("The Spark context has not been created.");
if (CONTEXT.isStopped())
recreateStopped();
final Set<String> keepNames = new HashSet<>();
for (final RDD<?> rdd : JavaConversions.asJavaIterable(CONTEXT.persistentRdds().values())) {
if (null != rdd.name()) {
keepNames.add(rdd.name());
NAME_TO_RDD.put(rdd.name(), rdd);
}
}
// remove all stale names in the NAME_TO_RDD map
NAME_TO_RDD.keySet().stream().filter(key -> !keepNames.contains(key)).collect(Collectors.toList()).forEach(NAME_TO_RDD::remove);
}
示例3: source
import scala.collection.JavaConversions; //导入方法依赖的package包/类
public static StreamSource source(SourceConf sc){
StreamSource s = new StreamSource();
s.setAlias(sc.alias());
s.setSqlQuery(sc.query());
if (sc.slide().isDefined())
s.setRawSlideValue(sc.slide().get());
if (sc.samplingRate().isDefined())
s.setSamplingRate(((Double)sc.samplingRate().get()).floatValue());
if (sc.disconnectBufferSize().isDefined())
s.setDisconnectedBufferSize(((Integer)sc.disconnectBufferSize().get()));
if (sc.storageSize().isDefined())
s.setRawHistorySize(sc.storageSize().get());
AddressBean[] add=new AddressBean[sc.wrappers().size()];
int i=0;
for (WrapperConf w:JavaConversions.asJavaIterable(sc.wrappers())){
add[i]=address(w);
i++;
}
s.setAddressing(add);
return s;
}
示例4: address
import scala.collection.JavaConversions; //导入方法依赖的package包/类
public static AddressBean address(WrapperConf w){
KeyValueImp [] p=new KeyValueImp[w.params().size()];
Iterable<String> keys=JavaConversions.asJavaIterable(w.params().keys());
int i=0;
for (String k:keys){
p[i]=new KeyValueImp(k,w.params().apply(k));
i++;
}
AddressBean a = new AddressBean(w.wrapper(),p);
if(w.partialKey().isDefined()){
a.setPartialOrderKey(w.partialKey().get());
}
DataField [] out=new DataField[(w.output().size())];
for (int j=0;j<out.length;j++){
out[j]=dataField(w.output().apply(j));
}
a.setVsconfig(out);
return a;
}
示例5: render
import scala.collection.JavaConversions; //导入方法依赖的package包/类
public void render(Snapshot snapshot) {
int x = 20;
int y = height - 20;
batch.begin();
for (LeaderBoard.Stats stats : JavaConversions.asJavaIterable(snapshot.leaderBoard().sortedByHighest().take(4))) {
ClientId player = stats.player();
if (stats.hits() == 0)
continue;
Texture tex = bodyTextures[0];
batch.draw(tex, x, y - tex.getWidth() * 5 / 6);
String text = snapshot.nicknameFor(player) + " " + stats.hits() + "/" + stats.deaths();
textRenderer.drawString(batch, text, x + tex.getWidth() + 20, y);
y -= 40;
}
batch.end();
}
示例6: persistenceId
import scala.collection.JavaConversions; //导入方法依赖的package包/类
@Override
public String persistenceId() {
for (String role : JavaConversions.asJavaIterable((Cluster.get(getContext().system()).selfRoles()))) {
if (role.startsWith("backend-")) {
return role + "-master";
}
}
return "master";
}
示例7: refresh
import scala.collection.JavaConversions; //导入方法依赖的package包/类
public static void refresh() {
if (null == CONTEXT)
throw new IllegalStateException("The Spark context has not been created.");
final Set<String> keepNames = new HashSet<>();
for (final RDD<?> rdd : JavaConversions.asJavaIterable(CONTEXT.persistentRdds().values())) {
if (null != rdd.name()) {
keepNames.add(rdd.name());
NAME_TO_RDD.put(rdd.name(), rdd);
}
}
// remove all stale names in the NAME_TO_RDD map
NAME_TO_RDD.keySet().stream().filter(key -> !keepNames.contains(key)).collect(Collectors.toList()).forEach(NAME_TO_RDD::remove);
}
示例8: hasPersistedRDD
import scala.collection.JavaConversions; //导入方法依赖的package包/类
private static boolean hasPersistedRDD(final String name) {
for (final RDD<?> rdd : JavaConversions.asJavaIterable(Spark.getContext().persistentRdds().values())) {
if (null != rdd.name() && rdd.name().equals(name))
return true;
}
return false;
}
示例9: getPersistedRDDSize
import scala.collection.JavaConversions; //导入方法依赖的package包/类
private static int getPersistedRDDSize() {
int counter = 0;
for (final RDD<?> rdd : JavaConversions.asJavaIterable(Spark.getContext().persistentRdds().values())) {
if (null != rdd.name())
counter++;
}
return counter;
}
示例10: getBrokers
import scala.collection.JavaConversions; //导入方法依赖的package包/类
/**
* There is always only one string in zkHost
* @param zkHost
* @return
*/
public static Set<String> getBrokers(Set<String> zkHost)
{
ZkClient zkclient = new ZkClient(zkHost.iterator().next(), 30000, 30000, ZKStringSerializer$.MODULE$);
Set<String> brokerHosts = new HashSet<String>();
for (Broker b : JavaConversions.asJavaIterable(ZkUtils.getAllBrokersInCluster(zkclient))) {
brokerHosts.add(b.connectionString());
}
zkclient.close();
return brokerHosts;
}
示例11: gatherTraits
import scala.collection.JavaConversions; //导入方法依赖的package包/类
private void gatherTraits(SchemaLike sch) {
final Iterable<Thype> thypes =
JavaConversions.asJavaIterable(sch.thypes().values());
for(Thype t: thypes) {
if(t instanceof TraitThypeLike) {
traits.add((TraitThypeLike)t);
}
}
if(sch.parent().isDefined()) {
gatherTraits(sch.parent().get());
}
}
示例12: persistenceId
import scala.collection.JavaConversions; //导入方法依赖的package包/类
@Override
public String persistenceId() {
for (String role : JavaConversions.asJavaIterable((Cluster.get(getContext().system()).selfRoles()))) {
if (role.startsWith("backend-")) {
return role + "-master";
}
}
return "master";
}
示例13: drawPlayers
import scala.collection.JavaConversions; //导入方法依赖的package包/类
private void drawPlayers(Vector2 scroll, Snapshot snapshot) {
for (PlayerEntity player : JavaConversions.asJavaIterable(snapshot.playerEntities())) {
Vector2 pos = player.position().cpy();
pos.sub(scroll);
pos.x -= width / 2;
pos.y -= height / 2;
pos.x /= H_SCALE;
pos.y /= V_SCALE;
pos.x = Math.min(WIDTH / 2, Math.max(pos.x, -WIDTH / 2));
pos.y = Math.min(HEIGHT / 2, Math.max(pos.y, -HEIGHT / 2));
pos.x += width - SHIFT - WIDTH + WIDTH / 2;
pos.y += height - SHIFT - HEIGHT + HEIGHT / 2;
Texture head = headTextures[0];
Vector2 dir = player.aim();
batch.draw(head,
pos.x - head.getWidth() / 2,
pos.y - head.getHeight() / 2, // Position
0, 0, // Origin
head.getWidth(), head.getHeight(), // Dst WH
1, 1, // Scale
0, // Rotation
0, 0, // Src XY
head.getWidth(), head.getHeight(), // Src WH
dir.x > 0, false);
}
}
示例14: buildUpdates
import scala.collection.JavaConversions; //导入方法依赖的package包/类
@Override
public Iterable<U> buildUpdates(JavaPairRDD<K, M> newData) {
return JavaConversions.asJavaIterable(scalaManager.buildUpdates(newData.rdd()));
}
示例15: generate
import scala.collection.JavaConversions; //导入方法依赖的package包/类
public void generate() throws IOException {
Path tmpRoot = ScalaGenUtils
.rmrf(outputRoot.resolveSibling(outputRoot.getFileName().toString() + "~tmp"), outputRoot.getParent());
for (CNamespace namespace : ctx.namespaces().values()) {
new NamespaceGen(namespace).writeUnder(tmpRoot);
}
for (CSchemaFile schemaFile : ctx.schemaFiles().values()) {
for (CTypeDef typeDef : JavaConversions.asJavaIterable(schemaFile.typeDefs())) {
switch (typeDef.kind()) {
case ENTITY:
//new VarTypeGen((CVarTypeDef) typeDef).writeUnder(tmpRoot);
break;
case RECORD:
new RecordGen((CRecordTypeDef) typeDef).writeUnder(tmpRoot);
break;
case MAP:
break;
case LIST:
new ListGen((CListTypeDef) typeDef).writeUnder(tmpRoot);
break;
case ENUM:
break;
case STRING:
case INTEGER:
case LONG:
case DOUBLE:
case BOOLEAN:
new PrimitiveGen((CPrimitiveTypeDef) typeDef).writeUnder(tmpRoot);
break;
default:
throw new UnsupportedOperationException(typeDef.kind().toString());
}
}
}
ScalaGenUtils.move(tmpRoot, outputRoot, outputRoot.getParent()); // move new root to final location
}