org.apache.crunch.CrunchRuntimeException:java.io.NotSerializableException
我有一个org.apache.crunch.CrunchRuntimeException:java.io.NotSerializableException,java,hadoop,mapreduce,apache-crunch,Java,Hadoop,Mapreduce,Apache Crunch,我有一个PTable,它是在运行转换作业的程序的中间阶段生成的。 示例PTable条目: ["0067b4c054d14fe2-ACC8D37", [{ "unique_id": "0067b4c054d14fe2-ACC8D37", "user_id": "ACC8D37", "campaign_id": "3URL6GC2", "seller_id": "0067b4c" }, { "unique_id": "0067b4c054d14fe2-AC
PTable
,它是在运行转换作业的程序的中间阶段生成的。
示例PTable条目:
["0067b4c054d14fe2-ACC8D37",
[{
"unique_id": "0067b4c054d14fe2-ACC8D37",
"user_id": "ACC8D37",
"campaign_id": "3URL6GC2",
"seller_id": "0067b4c"
}, {
"unique_id": "0067b4c054d14fe2-ACC8D37",
"user_id": "ACC8D37",
"seller_id": "0067b4c"
}]]
我需要获取一个PCollection
,其中Entity2为null
变压器DoFn
private PCollection<String> transformPairTable(PCollection<Pair<Entity1, Entity2>> pairPCollection) {
return pairPCollection.parallelDo(new DoFn<Pair<Entity1, Entity2>, String>() {
@Override
public void process(Pair<Entity1, Entity2> entityPair, Emitter<String> emitter) {
Entity1 entity1 = entityPair.first();
Entity2 entity2 = entityPair.second();
if (entity2 == null) {
String campaignId = entity1.getCampaignId();
emitter.emit(campaignId);
}
}
}, Avros.strings());
}
我尝试了writeables.strings(),但它给出了相同的异常
作业中使用的PTable具有Entity2等于null的条目
我试着用很多方法来转换PTable,但它不起作用。我无法找出背后的主要原因
当我使用
Entity1 p1= pairPCollection.first().getValue().first();
它抛出以下提到的异常:
ERROR materialize.MaterializableIterable: Could not materialize: Avro(/tmp/crunch-1893789994/p7)
java.io.IOException: No files found to materialize at: /tmp/crunch-1893789994/p7
at org.apache.crunch.io.CompositePathIterable.create(CompositePathIterable.java:49)
at org.apache.crunch.io.impl.FileSourceImpl.read(FileSourceImpl.java:134)
at org.apache.crunch.io.avro.AvroFileSource.read(AvroFileSource.java:89)
你能添加这个代码吗?在com.xxxx.bb.xxxx.xxx.jobs.GenerateNewCount.getNewCustomersPCollection(GenerateNewCount.java:239)。。这是你的问题。。可能是试图通过构造函数传递一个不可序列化的对象。我在一个非静态函数中使用了DoFn,因此出现了错误。在静态方法内部内联定义的DoFn实例不包含对其外部类的引用,因此可以序列化,而不管外部类是否可序列化。将方法从非静态更改为静态解决了问题。是否可以添加此代码?在com.xxxx.bb.xxxx.xxx.jobs.GenerateNewCount.getNewCustomersPCollection(GenerateNewCount.java:239)。。这是你的问题。。可能是试图通过构造函数传递一个不可序列化的对象。我在一个非静态函数中使用了DoFn,因此出现了错误。在静态方法内部内联定义的DoFn实例不包含对其外部类的引用,因此可以序列化,而不管外部类是否可序列化。将方法从非静态更改为静态解决了问题。
ERROR materialize.MaterializableIterable: Could not materialize: Avro(/tmp/crunch-1893789994/p7)
java.io.IOException: No files found to materialize at: /tmp/crunch-1893789994/p7
at org.apache.crunch.io.CompositePathIterable.create(CompositePathIterable.java:49)
at org.apache.crunch.io.impl.FileSourceImpl.read(FileSourceImpl.java:134)
at org.apache.crunch.io.avro.AvroFileSource.read(AvroFileSource.java:89)