我們可以使用函數(shù) BinStorage() 和 TextLoader() 在Apache Pig中加載和存儲壓縮數(shù)據(jù)。
假設(shè)在HDFS目錄 /pigdata/ 中有一個名為 employee.txt.zip 的文件。然后,我們可以將壓縮文件加載到pig,如下所示。
Using PigStorage: grunt> data = LOAD 'hdfs://localhost:9000/pig_data/employee.txt.zip' USING PigStorage(','); Using TextLoader: grunt> data = LOAD 'hdfs://localhost:9000/pig_data/employee.txt.zip' USING TextLoader;
同樣,我們可以將壓縮文件存儲在pig中,如下所示。
Using PigStorage: grunt> store data INTO 'hdfs://localhost:9000/pig_Output/data.bz' USING PigStorage(',');
更多建議: