Hadoop的Text类型实现
来源:互联网 发布:mac word 剪切板 编辑:程序博客网 时间:2024/05/17 05:29
Hadoop的Text类型是将字符串用UTF-8编码转换成bytes位数组。
/**
* Converts the provided String to bytes using the* UTF-8 encoding. If <code>replace</code> is true, then
* malformed input is replaced with the
* substitution character, which is U+FFFD. Otherwise the
* method throws a MalformedInputException.
* @return ByteBuffer: bytes stores at ByteBuffer.array()
* and length is ByteBuffer.limit()
*/
public static ByteBuffer encode(String string, boolean replace)
throws CharacterCodingException {
CharsetEncoder encoder = ENCODER_FACTORY.get();
if (replace) {
encoder.onMalformedInput(CodingErrorAction.REPLACE);
encoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
}
ByteBuffer bytes =
encoder.encode(CharBuffer.wrap(string.toCharArray()));
if (replace) {
encoder.onMalformedInput(CodingErrorAction.REPORT);
encoder.onUnmappableCharacter(CodingErrorAction.REPORT);
}
return bytes;
}
- Hadoop的Text类型实现
- Hadoop中Text类型 与 String的区别
- Hadoop中Text类型 与 String的区别
- Hadoop之sequencefile与text类型转化
- Hadoop -实现自定义的Key类型
- MSSQL Server实现text字段类型的字符替换
- hadoop命令源码之text实现
- text类型字段的读写
- text 类型和image 类型的转换
- Hadoop之Text与String的异同
- 实现表单中text类型取消其所有效果,让其成为一个无效果的text,并且实现只读效果
- [MSSQLServer]Text类型的字符串替换
- mysql数据库 text类型的长度限制
- slq server 中text类型的比较
- 存储过程参数Text类型的长度
- sqlite中text类型的比较规则
- MySQL text类型的最大长度
- mysql字段text类型的使用
- python 字典(dict)按键和值排序
- android实用代码段2
- C++:#pragma once与 #ifndef的区别
- Codeforces Round 12
- Ubuntu下安装vsftp遇到的一些问题
- Hadoop的Text类型实现
- 计算机右击后“管理” win7 系统 这一项打不开怎么办
- Android动画实现小结
- Android实用代码1 - 转自农民伯伯
- 如何保护Java程序 防止Java反编译
- java.lang.RuntimeException: PermGen space 解决方案
- Gson简要使用笔记
- linux devel包 和 非devel包的区别
- 66. 在C#里模拟LotusScript里的字符串截取函数