在 PySpark 中,我知道 python 工作线程用于在工作节点上执行(至少一些)计算(如https://cwiki.apache.org/confluence/display/SPARK/PySpark+Internals中所述)。
在我的测试设置中,我试图让 Spark 使用 4 个工作线程(在独立机器上),但似乎只创建了 1 个 python 工作线程:
import socket
import threading
spark = SparkSession\
.builder\
.master('local[4]')\
.appName("PythonPi")\
.getOrCreate()
partitions = 4
# Print the ident of the local thread:
print(str(threading.get_ident()))
# Print the idents of the threads inside the python workers:
thread_ids = spark.sparkContext.parallelize(range(1, partitions + 1), partitions)\
.map(lambda x: ' threadid: ' + str(threading.get_ident())).collect()
print(thread_ids)
spark.stop()
Run Code Online (Sandbox Code Playgroud)
输出:
140226126948096
[' threadid: 139948131018496', ' threadid: 139948131018496', ' threadid: 139948131018496', ' threadid: 139948131018496'] …Run Code Online (Sandbox Code Playgroud) 我是Objective C的新手,在使用新的ARC编译器编译代码时,我不知道如何使用out参数创建和调用方法.
这是我在非ARC目标C中试图完成的事情(无论如何这可能是错误的).
//
// Dummy.m
// OutParamTest
#import "Dummy.h"
@implementation Dummy
- (void) foo {
NSString* a = nil;
[self barOutString:&a];
NSLog(@"%@", a);
}
- (void) barOutString:(NSString * __autoreleasing *)myString {
NSString* foo = [[NSString alloc] initWithString:@"hello"];
*myString = foo;
}
@end
Run Code Online (Sandbox Code Playgroud)
(编辑以匹配建议).
我在这里阅读了这些文档:http: //clang.llvm.org/docs/AutomaticReferenceCounting.html
在这里:http: //developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjectiveC/Chapters/ocProperties.html
...但我发现很难得到任何编译的东西,更不用说任何正确的东西了.是否有人能够以适合ARC目标C的方式重写上面代码的jist?