本文整理汇总了Java中backtype.storm.utils.Utils.get方法的典型用法代码示例。如果您正苦于以下问题:Java Utils.get方法的具体用法?Java Utils.get怎么用?Java Utils.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类backtype.storm.utils.Utils
的用法示例。
在下文中一共展示了Utils.get方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: emitPartitionBatch
import backtype.storm.utils.Utils; //导入方法依赖的package包/类
@Override
public MemoryTransactionalSpoutMeta emitPartitionBatch(
TransactionAttempt tx, BatchOutputCollector collector,
int partition, MemoryTransactionalSpoutMeta lastPartitionMeta) {
if (!Boolean.FALSE.equals(getDisabledStatuses().get(partition))) {
int index;
if (lastPartitionMeta == null) {
index = 0;
} else {
index = lastPartitionMeta.index + lastPartitionMeta.amt;
}
List<List<Object>> queue = getQueues().get(partition);
int total = queue.size();
int left = total - index;
int toTake = Math.min(left, _takeAmt);
MemoryTransactionalSpoutMeta ret = new MemoryTransactionalSpoutMeta(
index, toTake);
for (int i = ret.index; i < ret.index + ret.amt; i++) {
List<Object> toEmit = new ArrayList<Object>(queue.get(i));
toEmit.add(0, tx);
collector.emit(toEmit);
}
if (toTake == 0) {
// this is a pretty hacky way to determine when all the
// partitions have been committed
// wait until we've emitted max-spout-pending empty
// partitions for the partition
int curr = Utils.get(_emptyPartitions, partition, 0) + 1;
_emptyPartitions.put(partition, curr);
if (curr > _maxSpoutPending) {
getFinishedStatuses().put(partition, true);
}
}
return ret;
} else {
return null;
}
}
示例2: emitPartitionBatchNew
import backtype.storm.utils.Utils; //导入方法依赖的package包/类
@Override
public MemoryTransactionalSpoutMeta emitPartitionBatchNew(
TransactionAttempt tx, BatchOutputCollector collector,
int partition, MemoryTransactionalSpoutMeta lastPartitionMeta) {
int index;
if (lastPartitionMeta == null) {
index = 0;
} else {
index = lastPartitionMeta.index + lastPartitionMeta.amt;
}
List<List<Object>> queue = getQueues().get(partition);
int total = queue.size();
int left = total - index;
int toTake = Math.min(left, _takeAmt);
MemoryTransactionalSpoutMeta ret = new MemoryTransactionalSpoutMeta(
index, toTake);
emitPartitionBatch(tx, collector, partition, ret);
if (toTake == 0) {
// this is a pretty hacky way to determine when all the
// partitions have been committed
// wait until we've emitted max-spout-pending empty partitions
// for the partition
int curr = Utils.get(_emptyPartitions, partition, 0) + 1;
_emptyPartitions.put(partition, curr);
if (curr > _maxSpoutPending) {
Map<Integer, Boolean> finishedStatuses = getFinishedStatuses();
// will be null in remote mode
if (finishedStatuses != null) {
finishedStatuses.put(partition, true);
}
}
}
return ret;
}
示例3: updateTaskCounts
import backtype.storm.utils.Utils; //导入方法依赖的package包/类
private void updateTaskCounts(List<Integer> tasks) {
if(_currBatch!=null) {
Map<Integer, Integer> taskEmittedTuples = _currBatch.taskEmittedTuples;
for(Integer task: tasks) {
int newCount = Utils.get(taskEmittedTuples, task, 0) + 1;
taskEmittedTuples.put(task, newCount);
}
}
}
示例4: getFloat
import backtype.storm.utils.Utils; //导入方法依赖的package包/类
public static float getFloat(Map<String, Object> conf, String key,
float defaultValue) {
Object obj = Utils.get(conf, key, defaultValue);
if (obj instanceof Double)
return ((Double) obj).floatValue();
return (Float) obj;
}
示例5: emitPartitionBatch
import backtype.storm.utils.Utils; //导入方法依赖的package包/类
@Override
public MemoryTransactionalSpoutMeta emitPartitionBatch(TransactionAttempt tx, BatchOutputCollector collector, int partition,
MemoryTransactionalSpoutMeta lastPartitionMeta) {
if (!Boolean.FALSE.equals(getDisabledStatuses().get(partition))) {
int index;
if (lastPartitionMeta == null) {
index = 0;
} else {
index = lastPartitionMeta.index + lastPartitionMeta.amt;
}
List<List<Object>> queue = getQueues().get(partition);
int total = queue.size();
int left = total - index;
int toTake = Math.min(left, _takeAmt);
MemoryTransactionalSpoutMeta ret = new MemoryTransactionalSpoutMeta(index, toTake);
for (int i = ret.index; i < ret.index + ret.amt; i++) {
List<Object> toEmit = new ArrayList<Object>(queue.get(i));
toEmit.add(0, tx);
collector.emit(toEmit);
}
if (toTake == 0) {
// this is a pretty hacky way to determine when all the partitions have been committed
// wait until we've emitted max-spout-pending empty partitions for the partition
int curr = Utils.get(_emptyPartitions, partition, 0) + 1;
_emptyPartitions.put(partition, curr);
if (curr > _maxSpoutPending) {
getFinishedStatuses().put(partition, true);
}
}
return ret;
} else {
return null;
}
}
示例6: execute
import backtype.storm.utils.Utils; //导入方法依赖的package包/类
@Override
public void execute(Tuple tuple) {
Object key = tuple.getValue(1);
int curr = Utils.get(_counts, key, 0);
_counts.put(key, curr + 1);
}
示例7: execute
import backtype.storm.utils.Utils; //导入方法依赖的package包/类
@Override
public void execute(Tuple tuple) {
Object key = tuple.getValue(1);
Number curr = Utils.get(_sums, key, 0);
_sums.put(key, Numbers.add(curr, tuple.getValue(2)));
}
示例8: execute
import backtype.storm.utils.Utils; //导入方法依赖的package包/类
@Override
public void execute(Tuple tuple) {
Object key = tuple.getValue(1);
Number curr = Utils.get(_sums, key, 0);
_sums.put(key, Numbers.add(curr, tuple.getValue(2)));
}
示例9: getInt
import backtype.storm.utils.Utils; //导入方法依赖的package包/类
public static int getInt(Map<String, Object> conf, String key,
int defaultValue) {
Object obj = Utils.get(conf, key, defaultValue);
return Utils.getInt(obj);
}
示例10: getLong
import backtype.storm.utils.Utils; //导入方法依赖的package包/类
public static long getLong(Map<String, Object> conf, String key,
long defaultValue) {
return (Long) Utils.get(conf, key, defaultValue);
}
示例11: getString
import backtype.storm.utils.Utils; //导入方法依赖的package包/类
public static String getString(Map<String, Object> conf, String key) {
return (String) Utils.get(conf, key, null);
}
示例12: execute
import backtype.storm.utils.Utils; //导入方法依赖的package包/类
@Override
public void execute(Tuple tuple) {
Object key = tuple.getValue(1);
int curr = Utils.get(_counts, key, 0);
_counts.put(key, curr + 1);
}