Ich habe eine HashMap < String, ArrayList < Integer>>. Ich möchte mein HashMap-Objekt (hmap) zum HDFS-Speicherort serialisieren und es später bei Mapper and Reducers für die Verwendung deserialisieren.How to Serialize Objekt in Hadoop (in HDFS)
Zu meinem HashMap Objekt auf HDFS Ich benutzte normale Java-Objekt Serialisierungscode Serialisierung wie folgt aber erhielt Fehler (Berechtigung verweigert)
try
{
FileOutputStream fileOut =new FileOutputStream("hashmap.ser");
ObjectOutputStream out = new ObjectOutputStream(fileOut);
out.writeObject(hm);
out.close();
}
catch(Exception e)
{
e.printStackTrace();
}
ich die folgende Ausnahme
bekamjava.io.FileNotFoundException: hashmap.ser (Permission denied)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:221)
at java.io.FileOutputStream.<init>(FileOutputStream.java:110)
at KMerIndex.createIndex(KMerIndex.java:121)
at MyDriverClass.formRefIndex(MyDriverClass.java:717)
at MyDriverClass.main(MyDriverClass.java:768)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.hadoop.util.RunJar.run(RunJar.java:221)
at org.apache.hadoop.util.RunJar.main(RunJar.java:136)
Kann jemand bitte vorschlagen oder teilen Sie den Beispielcode, wie Objekt in Hadoop auf hdfs serialisieren?
dies scheint wie Dateierlaubnis Problem. Aber um es einfach zu machen, bitte überprüfen Sie meine Antwort –