我正在使用一个大型数据集,该数据集由两列分隔 - plant_name和tag_id.第二个分区 - tag_id有200000个唯一值,我主要通过特定tag_id值访问数据.如果我使用以下Spark命令:
sqlContext.setConf("spark.sql.hive.metastorePartitionPruning", "true")
sqlContext.setConf("spark.sql.parquet.filterPushdown", "true")
val df = sqlContext.sql("select * from tag_data where plant_name='PLANT01' and tag_id='1000'")
Run Code Online (Sandbox Code Playgroud)
我希望快速响应,因为这解析为单个分区.在Hive和Presto中,这需要几秒钟,但在Spark中运行数小时.
实际数据保存在S3存储桶中,当我提交sql查询时,Spark关闭并首先获取Hive Metastore中的所有分区(其中200000个),然后调用refresh()强制所有这些文件的完整状态列表在S3对象库中(实际调用listLeafFilesInParallel).
这两个操作是如此昂贵,是否有任何设置可以让Spark更早地修剪分区 - 在调用元数据存储期间,还是之后立即?
我使用SparkContext.addFile("hdfs://host:54310/spark/fileName.txt")并将文件添加到SparkContext. 我使用org.apache.spark.SparkFiles.get(fileName.txt). 它显示了一个绝对路径,类似于/tmp/spark-xxxx/userFiles-xxxx/fileName.txt.
现在我想从上面给定的绝对路径位置读取该文件
SparkContext。我试过sc.textFile(org.apache.spark.SparkFiles.get("fileName.txt")).collect().foreach(println)它认为返回的路径SparkFiles.get()为HDFS 路径,这是不正确的。
我进行了广泛的搜索以找到有关此的任何有用的读物,但运气不佳。
方法有什么问题吗?任何帮助都非常感谢。
这是代码和结果:
scala> sc.addFile("hdfs://localhost:54310/spark/fileName.txt")
scala> org.apache.spark.SparkFiles.get("fileName.txt")
res23: String = /tmp/spark-3646b5fe-0a67-4a16-bd25-015cc73533cd/userFiles-a7d54640-fab2-4dfa-a94f-7de6f74a0764/fileName.txt
scala> sc.textFile(org.apache.spark.SparkFiles.get("fileName.txt")).collect().foreach(println)
org.apache.hadoop.mapred.InvalidInputException: Input path does not exist: hdfs://localhost:54310/tmp/spark-3646b5fe-0a67-4a16-bd25-015cc73533cd/userFiles-a7d54640-fab2-4dfa-a94f-7de6f74a0764/fileName.txt
at org.apache.hadoop.mapred.FileInputFormat.singleThreadedListStatus(FileInputFormat.java:287)
at org.apache.hadoop.mapred.FileInputFormat.listStatus(FileInputFormat.java:229)
at org.apache.hadoop.mapred.FileInputFormat.getSplits(FileInputFormat.java:315)
at org.apache.spark.rdd.HadoopRDD.getPartitions(HadoopRDD.scala:200)
at org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:253)
at org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:251)
at scala.Option.getOrElse(Option.scala:121)
at org.apache.spark.rdd.RDD.partitions(RDD.scala:251)
at org.apache.spark.rdd.MapPartitionsRDD.getPartitions(MapPartitionsRDD.scala:35)
at org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:253)
at org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:251)
at scala.Option.getOrElse(Option.scala:121)
at org.apache.spark.rdd.RDD.partitions(RDD.scala:251)
at org.apache.spark.SparkContext.runJob(SparkContext.scala:2092)
at org.apache.spark.rdd.RDD$$anonfun$collect$1.apply(RDD.scala:939)
at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:151)
at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:112)
at org.apache.spark.rdd.RDD.withScope(RDD.scala:363)
at …Run Code Online (Sandbox Code Playgroud) 我是Nutch的新手.我需要抓取网页(比如几百个网页),阅读已抓取的数据并进行一些分析.
我按照链接https://wiki.apache.org/nutch/NutchTutorial(并集成了Solr,因为我将来可能需要搜索文本)并使用一些URL作为种子运行爬网.
现在,我text/html在本地机器上找不到数据.我在哪里可以找到数据以及以文本格式读取数据的最佳方式是什么?
我不确定我们为什么需要这个Hadoop KMS?我浏览了 Apache Hadoop 的官方文档,并没有明确提到为什么我们需要这个概念。我唯一清楚的是,使用它client可以server共享密钥http或https 使用REST APIs然后有多种身份验证方式。是从安全角度考虑吗?有人可以用通俗的语言向我解释它到底是什么吗?
如果我有任何错误,请纠正我。
apache-spark ×2
amazon-s3 ×1
cryptography ×1
hadoop ×1
hive ×1
java ×1
nutch ×1
parquet ×1
web-crawler ×1