首页 \ 问答 \ Python的Spark自定义Hadoop配置(PySpark)?(Custom Hadoop Configuration for Spark from Python (PySpark)?)

Python的Spark自定义Hadoop配置(PySpark)?(Custom Hadoop Configuration for Spark from Python (PySpark)?)

我有基于Python的脚本,应该在Apache Spark集群上运行。

我有Hadoop MapReduce InputFormat作为RDD的数据源。 这没问题。

问题是我想构建自定义的Hadoop Configuration其中加载了额外的资源文件并设置了属性。 意图是在Python SparkContext使用修改后的Configuration

我可以构建可以构建和加载所需Hadoop Configuration JVM代码。 如何使用PySpark将其附加到Python

有谁知道如何实现这一切?


I have Python-based script which should be run on Apache Spark cluster.

I have Hadoop MapReduce InputFormat as a data source for RDD. Here is no problem.

The problem is I'd like to construct custom Hadoop Configuration with additional resource files loaded and attributes set. Intention is to use modified Configuration inside Python SparkContext.

I can build JVM code which can construct and load needed Hadoop Configuration. How to attach it to Python using PySpark?

Does anybody know how all of this could be achieved?


原文:https://stackoverflow.com/questions/29571644
更新时间:2022-11-09 12:11

最满意答案

关键字static在C中已经严重超载,C ++增加了一些额外的含义。 对于static意味着什么的真实讨论,您需要指定上下文:在命名空间范围内, static影响所谓的链接:声明的名称是指不同来源中的同一实体,还是仅涉及这一个特定来源。 在其他地方,对于数据,它指定实体的生命周期, 而不是实体名称的绑定:只有一个静态成员变量的实例,它独立于包含它的类的任何实例而存在。 如果成员函数是静态的,这意味着它没有指向特定实例的指针,并且可以在没有任何实例的情况下调用。

关于您的具体问题:

  1. 静态成员不是该类的任何实例的一部分,因此它不会影响类的大小(实际上是其实例的大小)。 静态成员在范围和访问控制方面仍然是成员,但它具有静态生存期,并且存在于类的任何实例之外。

  2. 具体对象的sizeof不能为零,因为即使它不包含数据,也不能与内存中的任何其他对象具有相同的地址。 如果定义了这样的对象数组,则第一个元素的地址必须与第二个元素的地址不同( sizeof返回必须添加到第一个元素的地址以获取第二个元素的地址的字节数) 。 对象的物理大小可以是0,至少在某些情况下:例如,基类的物理大小可以为0(假设它是该类型的唯一基础)。

  3. 我不确定你在这里问的是什么。 当你写一些类似ab东西时, b会在a的范围内被查找; 如果b是静态成员,则a仅用于确定范围。 当您编写A::bA::还指定将在其中进行名称查找的范围。

  4. 从技术上讲,静态数据成员的声明不是定义。 原因,或者至少原因,是它必须独立于类的任何实例而在内存中布局。 在早期,这是当时现有的编译器技术所要求的,即使在今天,您通常也不希望在定义类的头文件中使用初始化数据。


The keyword static was already seriously overloaded in C, and C++ adds a couple of additional meanings. For any real discussion of what static means, you need to specify the context: at namespace scope, static affects what is called linkage: whether the name being declared refers to the same entity in different sources, or only in this one particular source. Elsewhere, for data, it specifies the lifetime of the entity, not the binding of the name of the entity: there is exactly one instance of a static member variable, which exists independently of any instances of the class which contains it. If a member function is static, this means that it has no this pointer to a specific instance, and can be called without any instance.

With regards to your specific questions:

  1. A static member is not part of any instance of the class, so it doesn't affect the size of the class (which is in fact the size of its instances). The static member is still a member in terms of scope and access controls, but it has static lifetime, and exists outside of any instance of the class.

  2. The sizeof of a concrete object cannot be zero, since even if it contains no data, it cannot have the same address as any other object in memory; if you define an array of such objects, the address of the first element must be different from that of the second element (and sizeof returns the number of bytes you must add to the address of the first element to get the address of the second). The physical size of an object can be 0, at least in certain cases: a base class can have a physical size of 0, for example (provided it is the only base of that type).

  3. I'm not sure what you're actually asking here. When you write something like a.b, b is looked up in the scope of a; if b is a static member, a is only used to determine the scope. When you write A::b, the A:: also specifies thhe scope in which name lookup will occur.

  4. Techically, the declaration of a static data member is not a definition. The reason, or at least the original reason, is that it must be laid out in memory independently of any instances of the class. In the early days, this was required by the then existing compiler technology, and even today, you generally don't want the initialization data in the header file where you define the class.

相关问答

更多
  • 当我无故地回答你的问题时,请问,这样可以更容易理解。 当在头文件中声明静态变量时,其范围限制为.h文件或跨所有单位。 没有像“头文件范围”这样的东西。 头文件被包含在源文件中。 翻译单元是源文件, 包括头文件中的文本。 无论你在头文件中写什么,都会被复制到每个包含源文件中。 因此,头文件中声明的静态变量就像每个源文件中的静态变量一样。 由于声明一个变量static这种方式意味着内部链接,每个包含头文件的翻译单元都会获得自己的 单个变量(在翻译单元之外是不可见的)。 这通常不是你想要的。 我想知道一个头文件中 ...
  • C-1x添加_Static_assert关键字。 这似乎是在gcc-4.6中实现的: _Static_assert (0, "assert1"); /* { dg-error "static assertion failed: \"assert1\"" } */ 第一个插槽需要是一个积分的常量表达式。 第二个插槽是一个常量字符串文字,可以长( _Static_assert(0, L"assertion of doom!") )。 我应该注意,这也是在最新版本的俚语中实现的。 C11 standard ad ...
  • static在Objective-C中具有与C中完全相同的含义。它与C ++中的含义不同。 在C ++中, static还用于声明和定义类方法(只能在类本身上调用的方法)和变量,但Objective-C使用不同的语法区分类和实例方法: + (void)classMethod; - (void)instanceMethod; 并且不支持类变量。 static has the exact same meaning in Objective-C that it would have in C. It does ...
  • 关键字static在C中已经严重超载,C ++增加了一些额外的含义。 对于static意味着什么的真实讨论,您需要指定上下文:在命名空间范围内, static影响所谓的链接:声明的名称是指不同来源中的同一实体,还是仅涉及这一个特定来源。 在其他地方,对于数据,它指定实体的生命周期, 而不是实体名称的绑定:只有一个静态成员变量的实例,它独立于包含它的类的任何实例而存在。 如果成员函数是静态的,这意味着它没有指向特定实例的指针,并且可以在没有任何实例的情况下调用。 关于您的具体问题: 静态成员不是该类的任何实例 ...
  • 形式上,“本地”C中没有这样的术语。 术语静态绑定(“早期绑定”)和动态绑定(“后期绑定”)的简化说明:它们最常用于面向对象的设计,以确定是否在编译时调用特定的继承成员函数的决定时间或运行时间。 虚函数的含义是它是一个被继承的函数,而不是被继承的基类中的等价函数。 如果编译器可以在编译时确定对象是“基类”类型还是类型“继承类”,那么您将获得静态绑定,否则将获得动态绑定。 所以你需要某种运行时类型信息(RTTI)。 在上面的上下文中,只有在C程序中使用面向对象的继承/多态时,这些术语才有意义。 C对此类机制没 ...
  • static表示该函数具有内部链接。 这意味着它不会与其他文件(翻译单元)中相同标识符的其他用途链接。 例如,假设在Tree.c我有一个在Tree结构上运行的函数,我有一些名为UpdateNode本地子程序,它在Tree的一部分上运行。 进一步假设在List.c ,我有一个对List结构进行操作的函数,它还有一些名为UpdateNode本地子例程,它只适用于List结构,而不适用于Tree结构。 如果我将这两个子例程都与外部链接一起离开,那么链接器会抱怨多个定义。 通过用static内部连接标记它们,避免了 ...
  • 在尝试将某些内容推送到CPP文件之前,您需要在CPP文件中的某个位置初始化静态成员。 添加如下内容: std::vector Foo::unvalidatedSockets; You need to initialize your static member somewhere in the CPP file before you try to push something onto it. Add something like this: std::vector< ...
  • 尝试在项目属性的链接器输入中设置其他依赖项。 Try setting additional dependencies in the linker input for a project properties.
  • 您可能不希望在main函数中声明您的struct - 将其范围限制为函数的范围,这很少是您想要的。 然后,在C中, static指的是对象生命周期,而不是结构成员。 你想要的是一个static类成员,它是一个C ++(而不是 C)构造。 You might not want to declare your struct inside the main function -- that limits its scope to that of the function, which is seldom what ...
  • 未定义的引用`Tool :: getStringIntoArray(std :: basic_string,std :: allocator>)' 它正在寻找Tool::getStringIntoArray但你定义了getStringIntoArray 。 更改定义中的签名 char* getStringIntoArray(string str) 至 char* Tool::getStringIntoArray(string str) undefined reference to `Tool::getS ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。