我有一些打印BooleanField的django代码
它呈现为True或False,我可以将标签更改为Agree/Disagree,还是需要在模板中为其编写逻辑?
在开发使用STORE命令的Pig脚本时,我必须删除每次运行的输出目录,否则脚本会停止并提供:
2012-06-19 19:22:49,680 [main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 6000: Output Location Validation Failed for: 'hdfs://[server]/user/[user]/foo/bar More info to follow:
Output directory hdfs://[server]/user/[user]/foo/bar already exists
Run Code Online (Sandbox Code Playgroud)
所以我正在寻找一个in-Pig解决方案来自动删除目录,如果目录在呼叫时不存在,那么该目录也不会阻塞.
在Pig Latin Reference中我找到了shell命令调用者fs.不幸的是,只要出现任何错误,Pig脚本就会中断.所以我不能用
fs -rmr foo/bar
Run Code Online (Sandbox Code Playgroud)
(即递归删除)因为如果目录不存在它会中断.我想我可以用一会儿
fs -test -e foo/bar
Run Code Online (Sandbox Code Playgroud)
这是一个测试,不应该打破或所以我想.但是,Pig再次将test不存在的目录上的返回代码解释为失败代码并中断.
Pig项目有一个JIRA票据解决了我的问题,并为STORE命令建议了一个可选参数OVERWRITE或FORCE_WRITE.无论如何,我正在使用Pig 0.8.1,并且没有这样的参数.
是否可以String.fromCharCode在JavaScript 中将十六进制值转换为其各自的ASCII字符,而不是使用该方法?
例如:
JavaScript的:
0x61 // 97
String.fromCharCode(0x61) // a
Run Code Online (Sandbox Code Playgroud)
类似C:
(char)0x61 // a
Run Code Online (Sandbox Code Playgroud) 对于我的一个项目,我想分析大约2 TB的Protobuf对象.我想通过"大象鸟"库在Pig脚本中使用这些对象.但是,我不清楚如何将文件写入HDFS,以便ProtobufPigLoader类可以使用它.
这就是我所拥有的:
猪脚本:
register ../fs-c/lib/*.jar // this includes the elephant bird library
register ../fs-c/*.jar
raw_data = load 'hdfs://XXX/fsc-data2/XXX*' using com.twitter.elephantbird.pig.load.ProtobufPigLoader('de.pc2.dedup.fschunk.pig.PigProtocol.File');
Run Code Online (Sandbox Code Playgroud)
导入工具(部分):
def getWriter(filenamePath: Path) : ProtobufBlockWriter[de.pc2.dedup.fschunk.pig.PigProtocol.File] = {
val conf = new Configuration()
val fs = FileSystem.get(filenamePath.toUri(), conf)
val os = fs.create(filenamePath, true)
val writer = new ProtobufBlockWriter[de.pc2.dedup.fschunk.pig.PigProtocol.File](os, classOf[de.pc2.dedup.fschunk.pig.PigProtocol.File])
return writer
}
val writer = getWriter(new Path(filename))
val builder = de.pc2.dedup.fschunk.pig.PigProtocol.File.newBuilder()
writer.write(builder.build)
writer.finish()
writer.close()
Run Code Online (Sandbox Code Playgroud)
导入工具运行正常.我有一些ProtobufPigLoader的问题因为我不能使用hadoop-lzo压缩库,并且没有修复(见这里)ProtobufPigLoader不起作用.我遇到问题的问题是DUMP raw_data;退货Unable to open …
apache-pig ×2
ascii ×1
c ×1
django ×1
elephantbird ×1
hadoop ×1
hdfs ×1
hex ×1
javascript ×1
string ×1