在AWS EMR中连接到Google NGrams数据

问题描述 投票:0回答:1

我正在尝试连接到EMR中AWS上的Google NGrams数据集。 (https://aws.amazon.com/datasets/google-books-ngrams/)但是,当我尝试使用Pig加载数据时,我收到很多错误消息,但没有真实数据,可能是因为上述链接中引用的S3存储桶中的文件已编码。有没有一种方法可以直接从Pig中访问它并进行适当的转换以使其可访问?

我已经尝试加载数据,然后使用limit尝试转储前几行,但是我遇到了一些错误以及很多随机字符和框。

这些是我尝试加载数据的命令:

trigrams = LOAD 's3://datasets.elasticmapreduce/ngrams/books/20090715/eng-us-all/3gram/data' AS (trigram:chararray, year:int, occurrences:float, pages:float, books:float);

out = LIMIT trigrams 10;

我希望获得以下格式的数据输出

n-gram TAB year TAB occurrences TAB pages TAB books

但是,我得到的只是以下错误消息,我无法分析数据。

268988 [main] INFO  org.apache.pig.tools.pigstats.ScriptState  - Pig features used in the script: LIMIT
19/09/04 01:48:04 INFO pigstats.ScriptState: Pig features used in the script: LIMIT
269024 [main] INFO  org.apache.pig.data.SchemaTupleBackend  - Key [pig.schematuple] was not set... will not generate code.
19/09/04 01:48:04 INFO data.SchemaTupleBackend: Key [pig.schematuple] was not set... will not generate code.
269047 [main] INFO  org.apache.pig.newplan.logical.optimizer.LogicalPlanOptimizer  - {RULES_ENABLED=[AddForEach, ColumnMapKeyPrune, ConstantCalculator, GroupByConstParallelSetter, LimitOptimizer, LoadTypeCastInserter, MergeFilter, MergeForEach, NestedLimitOptimizer, PartitionFilterOptimizer, PredicatePushdownOptimizer, PushDownForEachFlatten, PushUpFilter, SplitFilter, StreamTypeCastInserter]}
19/09/04 01:48:04 INFO optimizer.LogicalPlanOptimizer: {RULES_ENABLED=[AddForEach, ColumnMapKeyPrune, ConstantCalculator, GroupByConstParallelSetter, LimitOptimizer, LoadTypeCastInserter, MergeFilter, MergeForEach, NestedLimitOptimizer, PartitionFilterOptimizer, PredicatePushdownOptimizer, PushDownForEachFlatten, PushUpFilter, SplitFilter, StreamTypeCastInserter]}
269103 [main] INFO  org.apache.pig.impl.util.SpillableMemoryManager  - Selected heap (PS Old Gen) of size 699400192 to monitor. collectionUsageThreshold = 489580128, usageThreshold = 489580128
19/09/04 01:48:04 INFO util.SpillableMemoryManager: Selected heap (PS Old Gen) of size 699400192 to monitor. collectionUsageThreshold = 489580128, usageThreshold = 489580128
19/09/04 01:48:04 INFO output.FileOutputCommitter: File Output Committer Algorithm version is 1
19/09/04 01:48:04 INFO output.FileOutputCommitter: FileOutputCommitter skip cleanup _temporary folders under output directory:false, ignore cleanup failures: false
19/09/04 01:48:04 INFO output.DirectFileOutputCommitter: Direct Write: DISABLED
269186 [main] INFO  org.apache.pig.data.SchemaTupleBackend  - Key [pig.schematuple] was not set... will not generate code.
19/09/04 01:48:04 INFO data.SchemaTupleBackend: Key [pig.schematuple] was not set... will not generate code.
269242 [main] WARN  org.apache.pig.data.SchemaTupleBackend  - SchemaTupleBackend has already been initialized
19/09/04 01:48:05 WARN data.SchemaTupleBackend: SchemaTupleBackend has already been initialized
269245 [main] INFO  org.apache.pig.builtin.PigStorage  - Using PigTextInputFormat
19/09/04 01:48:05 INFO builtin.PigStorage: Using PigTextInputFormat
19/09/04 01:48:05 INFO input.FileInputFormat: Total input files to process : 1
269252 [main] INFO  org.apache.pig.backend.hadoop.executionengine.util.MapRedUtil  - Total input paths to process : 1
19/09/04 01:48:05 INFO util.MapRedUtil: Total input paths to process : 1
19/09/04 01:48:05 INFO lzo.GPLNativeCodeLoader: Loaded native gpl library
19/09/04 01:48:05 INFO lzo.LzoCodec: Successfully loaded & initialized native-lzo library [hadoop-lzo rev 7e6c862e89bc8db32c064454a55af74ddff73bae]
19/09/04 01:48:05 INFO s3n.S3NativeFileSystem: Opening 's3://datasets.elasticmapreduce/ngrams/books/20090715/eng-us-all/3gram/data' for reading
19/09/04 01:48:05 INFO output.FileOutputCommitter: Saved output of task 'attempt__0001_m_000001_1' to hdfs://ip-172-31-24-80.ec2.internal:8020/tmp/temp1150533356/tmp1066986243/_temporary/0/task__0001_m_000001
269523 [main] WARN  org.apache.pig.data.SchemaTupleBackend  - SchemaTupleBackend has already been initialized
19/09/04 01:48:05 WARN data.SchemaTupleBackend: SchemaTupleBackend has already been initialized
19/09/04 01:48:05 INFO input.FileInputFormat: Total input files to process : 1
269531 [main] INFO  org.apache.pig.backend.hadoop.executionengine.util.MapRedUtil  - Total input paths to process : 1
19/09/04 01:48:05 INFO util.MapRedUtil: Total input paths to process : 1
(SEQ!org.apache.hadoop.io.LongWritableorg.apache.hadoop.io.Text#com.hadoop.compression.lzo.LzoCodec�+Gz2rF?��n`�m�������+Gz2rF?��n`�m�֎~� ��|y��hx�������,,,,)
(�
  �
�,,,,)
(��������������▒▒���� �!�"�#�$�%�&�'�(�)�*�+�,�-�.�/�0�1�2�3�4�5�6�7�8�9�:�;�<�=�>�?�@�A�B�C�D�E�F�G�H�I�J�K�L�M�N�O�P�Q�R�S�T�U�V�W�X�Y�Z�[�\�]�^�_�`�a�b�c�d�e�f�g�h�i�j�k�l�m�n�o�p�q�r�s�t�u�v�w�x�y�z�{�|�}�~����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������!�!��������������������������������������������������������������A���������������������������������������������������������������a������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������"�@��������������������������������������������������������������B���������������������������������������������������������������b������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������#�@��������������������������������������������������������������C���������������������������������������������������������������c������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������$�@��������������������������������������������������������������D���������������������������������������������������������������d������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������%�@��������������������������������������������������������������E���������������������������������������������������������������e������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������&�@��������������������������������������������������������������F���������������������������������������������������������������f������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������'�@��������������������������������������������������������������G���������������������������������������������������������������g�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������(��������������������������������H��������������������������������h���������������������������������������������������������������������������������������������������������������������������������������������������������������,,,,)
(��,,,,)
(��,,,,)
(��,,,,)
(��,,,,)
(��,,,,)
(��,,,,)
(��,,,,)

对解决这个问题的任何帮助将不胜感激!

amazon-web-services hadoop amazon-s3 apache-pig amazon-emr
1个回答
0
投票

输入文件为序列文件格式。默认的Pig加载程序是基于文本的PigStorage()。如果它是没有自定义Writable对象的直接序列文件,则可以使用SequenceFileLoader。

DEFINE SequenceFileLoader org.apache.pig.piggybank.storage.SequenceFileLoader();
...
trigrams = LOAD 's3://datasets.elasticmapreduce/ngrams/books/20090715/eng-us-all/3gram/data' using SequenceFileLoader AS (trigram:chararray, year:int, occurrences:float, pages:float, books:float);
...
© www.soinside.com 2019 - 2024. All rights reserved.