- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我们正在尝试实现REST-API,在其中接收json响应并将其转换为字符串json格式。我们正在尝试通过打开流将此字符串内容写入Mapr FS。
FileSystem mfsHandler;
...
...
fsDataStream = mfsHandler.create(new Path("/demo/test.txt"), true);
String name = "Just to test";
byte[] namebytes = name.getBytes();
// fsDataStream.write(namebytes);
BufferedOutputStream bos = new BufferedOutputStream(fsDataStream);
bos.write(namebytes);
http://stackoverflow.com/questions/19687576/unwanted-chars-written-from-java-rest-api-to-hadoopdfs-using-fsdataoutputstream
进行操作,但无法解决。
最佳答案
这里的问题与Java字符串的编码有关。您可以在调用getBytes时选择要使用的编码。
例如,这是一个微型程序,它输出三种不同编码的字节:
public void testEncoding() throws UnsupportedEncodingException {
String s = "Sample text üø 漢字";
asHex(System.out, s, "UTF-8");
asHex(System.out, s, "UTF-16");
asHex(System.out, s, "SHIFT_JIS");
}
public void asHex(PrintStream out, String msg, String encoding) throws UnsupportedEncodingException {
byte[] buf = msg.getBytes(encoding);
System.out.printf("\n\n%s - %s\n", msg, encoding);
for (int i = 0; i < buf.length; i++) {
byte b = buf[i];
System.out.printf("%02x ", b & 0xff);
if (i % 16 == 15) {
System.out.printf("\n");
}
}
System.out.printf("\n");
}
Sample text üø 漢字 - UTF-8
53 61 6d 70 6c 65 20 74 65 78 74 20 c3 bc c3 b8
20 e6 bc a2 e5 ad 97
Sample text üø 漢字 - UTF-16
fe ff 00 53 00 61 00 6d 00 70 00 6c 00 65 00 20
00 74 00 65 00 78 00 74 00 20 00 fc 00 f8 00 20
6f 22 5b 57
Sample text üø 漢字 - SHIFT_JIS
53 61 6d 70 6c 65 20 74 65 78 74 20 3f 3f 20 8a
bf 8e 9a
getBytes()
,则将获得任何默认字符集。这可能在各地发生变化,因此几乎总是最好指定您想要的东西。
关于java - 在Mapr FS中写入字符串内容时附加了垃圾字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43833184/
安装 MapR 时遇到问题安装程序。它无法从存储库中读取。请检查以下链接以了解详细错误。让我知道如何克服这一点。 http://justpaste.it/q6vl 最佳答案 您可以尝试清理 repo
我不小心删除了 hadoop.tmp.dir,在我的例子中是/tmp/{user.name}/*。现在每次当我从 CLI 运行配置单元查询时,mapred 作业将在任务尝试时失败,如下所示: Erro
大家好, 我在 Centos 6.4, 64 位上使用 Mapr M7 版本。我正在 MapR 上测试 MapR-tables,但单击 MapR-tables --> Error Home direc
我没有对 mapred-site.xml 中 mapred.local.dir 指定的目录的写入权限(也没有对 mapred-site.xml 的写入权限)有没有一种方法可以在每个 session 基
我正在使用 Hadoop 版本 0.20.2(Cloudera 发行版 cdh3u6)并发现问题。据我了解,如果我在 /etc/hadoop/conf/mapred-site.xml 中设置一个值,它
我正在尝试从 mapr fs origin 进行简单的数据移动到 mapr fs destination (这不是我的用例,只是为了测试目的做这个简单的 Action )。尝试 validate 时这
我在MapR DB中创建了一个表,并使用hbase shell将一些原始数据加载到该表中。我在哪里可以在MapR文件系统上找到这些数据?像 hive 数据一样存储在仓库目录中,MapR DB如何工作?
MapR 自带了一种不同于HDFS 方式的新架构(Container Architecture)。有什么区别?这如何存储数据?有什么优点和缺点? 最佳答案 参见 https://www.youtube
我无法找到向我解释元数据如何在 MAPR(文件元数据)中分布的特定链接。当我查看 cloudera/hortonworks/apache hadoop 时,我知道元数据存储在 namenode 的内存
用于MapR DB的MapR REST API似乎无法正常工作。我只是尝试将列系列的列表命令用作过滤器,但它没有给我适当的输出,但它与maprcli选项完美配合。这是我所做的操作列表。 使用maprc
嗨,我正在尝试在 ubuntu 12.04 上精确安装 MapR,但面临一些问题。我按照下面的链接进行安装 http://doc.mapr.com/display/MapR/Quick+Install
我在 mapr-clusters.conf 中指定了两个集群 cluster1 secure=true cldb1:7222 cldb2:7222 cldb3:7222 cluster2 secure
是否正在进行将 Hadoop 管道从 mapred 移植到 mapreduce 包的工作? 谢谢,梅格 最佳答案 JIRA 问题 MAPREDUCE-1362解决了将管道升级到新的 mapreduce
我正在玩 Mapr Sandbox,我不明白 Mapr Warden 应用程序的作用是什么。 Mapr 网站包含对配置文件的引用,但没有程序本身的描述。 最佳答案 Warden 是一个轻型 Java
我使用 MapR,我想从 LDAP 创建用户。 我可以创建我的用户,但 Hue 不想创建关联文件夹,我收到此消息:“获取当前用户的用户信息时出错,***(错误 500)” 我尝试使用本地用户,但这是同
我现在使用 CDH 5.1。它通过 YARN 启动正常的 Hadoop 作业,但 hive 仍然可以使用 mapred。有时一个大查询会挂起很长时间,我想杀死它。 我可以通过 JobTracker W
本文整理了Java中org.apache.hadoop.mapred.YARNRunner类的一些代码示例,展示了YARNRunner类的具体用法。这些代码示例主要来源于Github/Stackove
本文整理了Java中org.apache.hadoop.mapred.YarnChild类的一些代码示例,展示了YarnChild类的具体用法。这些代码示例主要来源于Github/Stackoverf
本文整理了Java中org.apache.hadoop.mapred.YarnOutputFiles类的一些代码示例,展示了YarnOutputFiles类的具体用法。这些代码示例主要来源于Githu
本文整理了Java中org.apache.hadoop.mapred.YarnClientProtocolProvider类的一些代码示例,展示了YarnClientProtocolProvider类
我是一名优秀的程序员,十分优秀!