本文整理汇总了Java中backtype.storm.utils.Utils.javaSerialize方法的典型用法代码示例。如果您正苦于以下问题:Java Utils.javaSerialize方法的具体用法?Java Utils.javaSerialize怎么用?Java Utils.javaSerialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类backtype.storm.utils.Utils
的用法示例。
在下文中一共展示了Utils.javaSerialize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: put
import backtype.storm.utils.Utils; //导入方法依赖的package包/类
@Override
public void put(String key, Object value) {
byte[] data = Utils.javaSerialize(value);
try {
db.put(key.getBytes(), data);
} catch (Exception e) {
LOG.error("Failed put into cache, " + key, e);
}
}
示例2: putBatch
import backtype.storm.utils.Utils; //导入方法依赖的package包/类
@Override
public void putBatch(Map<String, Object> map) {
WriteOptions writeOpts = null;
WriteBatch writeBatch = null;
Set<byte[]> putKeys = new HashSet<byte[]>();
try {
writeOpts = new WriteOptions();
writeBatch = new WriteBatch();
for (Entry<String, Object> entry : map.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
byte[] data = Utils.javaSerialize(value);
if (StringUtils.isBlank(key) || data == null || data.length == 0) {
continue;
}
byte[] keyByte = key.getBytes();
writeBatch.put(keyByte, data);
putKeys.add(keyByte);
}
db.write(writeOpts, writeBatch);
} catch (Exception e) {
LOG.error("Failed to putBatch into DB, " + map.keySet(), e);
} finally {
if (writeOpts != null) {
writeOpts.dispose();
}
if (writeBatch != null) {
writeBatch.dispose();
}
}
}
示例3: BatchBoltExecutor
import backtype.storm.utils.Utils; //导入方法依赖的package包/类
public BatchBoltExecutor(IBatchBolt bolt) {
_boltSer = Utils.javaSerialize(bolt);
}