我正在研究Haskell Book,在第10章(折叠列表)中,我正在尝试解决关于从包含不同类型元素的列表中仅获取一种特定类型元素的练习.
作者给出了以下代码:
import Data.Time
data DatabaseItem = DbString String
| DbNumber Integer
| DbDate UTCTime
deriving (Eq, Ord, Show)
theDatabase :: [DatabaseItem]
theDatabase = [ DbDate (UTCTime
(fromGregorian 1911 5 1)
(secondsToDiffTime 34123))
, DbNumber 9001
, DbString "Hello, world!"
, DbDate (UTCTime
(fromGregorian 1921 5 1)
(secondsToDiffTime 34123))
]
Run Code Online (Sandbox Code Playgroud)
第一个问题是:
编写一个过滤DbDate值的函数,并返回其中的UTCTime值列表.
filterDbDate :: [DatabaseItem] -> [UTCTime]
filterDbDate = undefined
Run Code Online (Sandbox Code Playgroud)
由于本章是关于折叠列表的,所以我认为可以使用,例如,foldr.
我最初的尝试是首先编写一些辅助函数并在a中使用它们foldr,例如:
getDbDate1 :: DatabaseItem -> UTCTime
getDbDate1 (DbDate utcTime) = utcTime
isDbDate …Run Code Online (Sandbox Code Playgroud) 我坚持在Haskell Book中练习,"第22章读者".练习说"实施阅读器的应用",它给出了以下内容:
{-# LANGUAGE InstanceSigs #-}
newtype Reader r a =
Reader { runReader :: r -> a }
instance Applicative (Reader r) where
pure :: a -> Reader r a
pure a = Reader $ ???
(<*>) :: Reader r (a -> b) -> Reader r a -> Reader r b
(Reader rab) <*> (Reader ra) = Reader $ \r -> ???
Run Code Online (Sandbox Code Playgroud)
我pure之后也写了一个Functor实例(我编写了Functor实例,因为否则GHC抱怨"没有(Functor (Reader r)) …实例声明的超类引起的实例在实例声明中为‘Applicative (Reader r)’ …
我有以下jq命令:
cat myFile.json | jq -r '.tickets[] | [.created_at, .id, .via.channel, .tags[]] | @csv'
Run Code Online (Sandbox Code Playgroud)
它输出一行如下:
"2016-02-02T10:00:00Z",99999,"web","tag1","tag2","tag3","tag4"
Run Code Online (Sandbox Code Playgroud)
我想join在.tags[]阵列,这样我就可以得到:
"2016-02-19T13:25:55Z",99999,"web","tag1,tag2,tag3,tag4"
Run Code Online (Sandbox Code Playgroud)
我尝试过一些东西,比如
cat myFile.json | jq -r '.tickets[] | [.created_at, .id, .via.channel, (.tags[] | join(","))] | @csv'
Run Code Online (Sandbox Code Playgroud)
但它给出了诸如此类的错误
jq: error (at <stdin>:0): Cannot iterate over string ("tag1...)
Run Code Online (Sandbox Code Playgroud)
那么,我如何加入.tags[]上面的命令,以便不是单独的字段,而是获得单个字符串值(包含逗号分隔的标记值)?
我的Solr系统有两个内核(Solr版本3.6.1).当我在我们的专用Solr服务器上调用以下命令行来添加然后索引文件时:
java -Durl=http://solrprod:8080/solr/original/update -jar /home/solr/solr3/biomina/solr/post.jar /home/solr/tmp/2008/c2m-dump-01.noDEID_clean.xml
Run Code Online (Sandbox Code Playgroud)
我在/usr/share/tomcat7/logs/solr.2013-12-11.log文件中得到一个异常(等待大约6分钟后):
SEVERE: org.apache.lucene.store.LockObtainFailedException: Lock obtain timed out: NativeFSLock@/home/solr/solr3/biomina/solr/original/data/index/write.lock
Run Code Online (Sandbox Code Playgroud)
(您可以在此消息的末尾看到它的详细输出).
我试图修改锁定的超时(通过设置writeLockTimeout为300000),但这并没有解决问题.我没有使用任何自定义脚本,只是post.jarSolr 3.1.6附带的脚本来添加和索引.
有关需要更改哪些内容以消除此错误并成功将XML文件添加到Solr并将其编入索引的任何想法?
内容/home/solr/solr3/biomina/solr/solr.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not …Run Code Online (Sandbox Code Playgroud) 我正在使用当前版本的Hadoop,并运行一些TestDFSIO基准测试(v.1.8)来比较默认文件系统是HDFS与默认文件系统的情况是S3存储桶(通过S3a使用).
当使用默认文件系统读取100 x 1 MB文件作为S3a时,我观察到YARN Web UI中的最大容器数量少于默认情况下HDFS的情况,S3a 慢大约4倍.
当使用默认文件系统读取1000 x 10 KB文件作为S3a时,我观察到YARN Web UI中的最大容器数量至少比默认情况下HDFS的情况少10倍,而S3a的速度大约慢16倍.(例如,HDFS默认为50秒的测试执行时间,而S3a默认为16分钟的测试执行时间.)
在每种情况下,启动的地图任务的数量都是预期的,没有区别.但是为什么 YARN创造的容器数量减少至少10倍(例如HDFS上的117个,而S3a上的8个)?当集群的vcores,RAM和作业的输入分裂以及启动的map任务相同时,YARN如何决定创建多少个容器; 并且只存储后端有什么不同?
当运行相同的TestDFSIO作业时,期望HDFS与Amazon S3(通过S3a)之间的性能差异当然很好,我所了解的是YARN如何决定在这些作业期间启动的最大容器数量,其中只更改默认文件系统,因为当前,当默认文件系统为S3a时,YARN几乎不使用90%的并行性(默认文件系统为HDFS时通常会这样做).
该集群是一个15节点集群,具有1个NameNode,1个ResourceManager(YARN)和13个DataNode(工作节点).每个节点有128 GB RAM和48核CPU.这是一个专用的测试集群:在TestDFSIO测试运行期间,集群上没有其他任何运行.
对于HDFS,它dfs.blocksize是256m,并且它使用4个HDD(dfs.datanode.data.dir设置为file:///mnt/hadoopData1,file:///mnt/hadoopData2,file:///mnt/hadoopData3,file:///mnt/hadoopData4).
对于S3a,fs.s3a.block.size设置268435456为256m,与HDFS默认块大小相同.
Hadoop tmp目录位于SSD上(通过设置hadoop.tmp.dir为/mnt/ssd1/tmpin core-site.xml,并设置mapreduce.cluster.local.dir为/mnt/ssd1/mapred/localin mapred-site.xml) …
我在win 32上运行Python 2.5(r25:51908,2006年9月19日,09:52:17)[MSC v.1310 32位(英特尔)]
当我问Python时
>>> "u11-Phrase 099.wav" < "u11-Phrase 1000.wav"
True
Run Code Online (Sandbox Code Playgroud)
没关系.当我问
>>> "u11-Phrase 100.wav" < "u11-Phrase 1000.wav"
True
Run Code Online (Sandbox Code Playgroud)
那也没关系.但是,当我问
>>> "u11-Phrase 101.wav" < "u11-Phrase 1000.wav"
False
Run Code Online (Sandbox Code Playgroud)
因此根据Python"u11-Phrase 100.wav"出现在"u11-Phrase 1000.wav"之前,但"u11-Phrase 101.wav"出现在"u11-Phrase 1000.wav"之后!这对我来说是有问题的,因为我正在尝试编写文件重命名程序,这种排序会破坏功能.
我该怎么做才能克服这个问题?我应该编写自己的cmp函数并测试边缘情况,还是有一个更简单的快捷方式来给我我想要的顺序?
另一方面,如果我修改字符串,如
>>> "u11-Phrase 0101.wav" < "u11-Phrase 1000.wav"
True
Run Code Online (Sandbox Code Playgroud)
但是这些字符串来自目录的文件列表,例如:
files = glob.glob('*.wav')
files.sort()
for file in files:
...
Run Code Online (Sandbox Code Playgroud)
所以我不想在它们被glob创建后对字符串进行外科手术.不,我也不想更改该文件夹中的原始文件名.
任何提示?
I've installed spark-1.6.1-bin-hadoop2.6.tgz on a 15-node Hadoop cluster. All nodes run Java 1.8.0_72 and the latest version of Hadoop. The Hadoop cluster itself is functional, e.g. YARN can run various MapReduce jobs successfully.
I can run Spark Shell locally on a node without any problems with the following command: $SPARK_HOME/bin/spark-shell.
I can also run some Spark examples successfully, such as SparkPi using YARN and cluster mode.
But when I try to run Spark Shell on YARN with deploy mode …
版本信息:
Django 1.3版pre-alpha SVN-13858
Ubuntu GNU/Linux 10.10
我对Django中的i18n和l10n完全不熟悉,目前我正在尝试用荷兰语提供我的Django项目(除了默认语言:英语).我试图应用http://docs.djangoproject.com/en/dev/topics/i18n/translation/和http://www.djangobook.com/en/2.0/chapter19/上给出的说明,但我没有成功.我不知道这是否与我的目录结构和模板文件在一个完全不同的目录中有关(我的意思不是我的Django项目目录中的子目录).我的项目目录如下所示:
/home/emre/mydjango/myproject
/home/emre/mydjango/myproject/myapp1
/home/emre/mydjangotemplates
/home/emre/mydjangotemplates/myapp1
Run Code Online (Sandbox Code Playgroud)
在myproject和myapp1目录中,我尝试发出以下命令:
django-admin.py makemessages -l nl
Run Code Online (Sandbox Code Playgroud)
但收到以下错误:
Error: This script should be run from the Django SVN tree or your project or
app tree. If you did indeed run it from the SVN checkout or your project or
application, maybe you are just missing the conf/locale (in the django tree)
or locale (for project and application) directory? It is not created automatically,
you have to …Run Code Online (Sandbox Code Playgroud) 我已经在Java中成功构建了一个非常简单的Spark Streaming应用程序,该应用程序基于Scala中的HdfsCount示例.
当我将此应用程序提交给我的本地Spark时,它会等待将文件写入给定目录,当我创建该文件时,它会成功打印出单词数.我按Ctrl + C终止应用程序.
现在我已经尝试为这个功能创建一个非常基本的单元测试,但在测试中我无法打印相同的信息,即单词的数量.
我错过了什么?
下面是单元测试文件,之后我还包含了显示countWords方法的代码片段:
import com.google.common.io.Files;
import org.apache.spark.streaming.Duration;
import org.apache.spark.streaming.api.java.JavaDStream;
import org.apache.spark.streaming.api.java.JavaPairDStream;
import org.apache.spark.streaming.api.java.JavaStreamingContext;
import org.junit.*;
import java.io.*;
public class StarterAppTest {
JavaStreamingContext ssc;
File tempDir;
@Before
public void setUp() {
ssc = new JavaStreamingContext("local", "test", new Duration(3000));
tempDir = Files.createTempDir();
tempDir.deleteOnExit();
}
@After
public void tearDown() {
ssc.stop();
ssc = null;
}
@Test
public void testInitialization() {
Assert.assertNotNull(ssc.sc());
}
@Test
public void testCountWords() {
StarterApp starterApp = new StarterApp();
try …Run Code Online (Sandbox Code Playgroud) 我正在尝试将hadoop与英特尔光泽融为一体.我已添加hadoop-lustre-plugin-3.1.0到hadoop-2.7.3/lib/native文件夹.Lustre安装在/mnt/lustre.当我开始使用hadoop时,我遇到了以下错误start-all.sh
[root@master hadoop]# start-all.sh
This script is Deprecated. Instead use start-dfs.sh and start-yarn.sh
17/04/06 17:36:55 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Incorrect configuration: namenode address dfs.namenode.servicerpc-address or dfs.namenode.rpc-address is not configured.
Starting namenodes on [ ]
...
Run Code Online (Sandbox Code Playgroud)
core-site.xml:
<property>
<name>fs.defaultFS</name>
<value>lustre:///</value>
</property>
<property>
<name>fs.lustre.impl</name>
<value>org.apache.hadoop.fs.LustreFileSystem</value>
</property>
<property>
<name>fs.AbstractFileSystem.lustre.impl</name>
<value>org.apache.hadoop.fs.LustreFileSystemlustre</value>
</property
<property>
<name>fs.lustrefs.mount</name>
<value>/mnt/lustre/hadoop</value>
<description>This is the directory on Lustre that acts as the root …Run Code Online (Sandbox Code Playgroud) hadoop ×3
apache-spark ×2
hadoop-yarn ×2
haskell ×2
java ×2
amazon-s3 ×1
applicative ×1
csv ×1
django ×1
jq ×1
json ×1
linux ×1
localization ×1
lucene ×1
lustre ×1
python ×1
solr ×1
sorting ×1
unit-testing ×1
xml ×1