本文整理了Java中com.netflix.spectator.api.Utils.size()
方法的一些代码示例,展示了Utils.size()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.size()
方法的具体详情如下:
包路径:com.netflix.spectator.api.Utils
类名称:Utils
方法名:size
[英]Returns the size of an iterable. This method should only be used with fixed size collections. It will attempt to find an efficient method to get the size before falling back to a traversal of the iterable.
[中]
代码示例来源:origin: Netflix/spectator
private static void appendMeasurement(
JsonGenerator gen,
Map<String, Integer> strings,
Map<String, String> commonTags,
Id id,
double value) throws IOException {
int op = operation(id);
if (shouldSend(op, value)) {
// Number of tag entries, commonTags + name + tags
int n = commonTags.size() + 1 + Utils.size(id.tags());
gen.writeNumber(n);
// Write out the key/value pairs for the tags
for (Map.Entry<String, String> entry : commonTags.entrySet()) {
gen.writeNumber(strings.get(entry.getKey()));
gen.writeNumber(strings.get(entry.getValue()));
}
for (Tag t : id.tags()) {
gen.writeNumber(strings.get(t.key()));
gen.writeNumber(strings.get(t.value()));
}
gen.writeNumber(strings.get("name"));
gen.writeNumber(strings.get(id.name()));
// Write out the operation and delta value
gen.writeNumber(op);
gen.writeNumber(value);
}
}
代码示例来源:origin: com.netflix.spectator/spectator-reg-stateless
private static void appendMeasurement(
JsonGenerator gen,
Map<String, Integer> strings,
Map<String, String> commonTags,
Id id,
double value) throws IOException {
int op = operation(id);
if (shouldSend(op, value)) {
// Number of tag entries, commonTags + name + tags
int n = commonTags.size() + 1 + Utils.size(id.tags());
gen.writeNumber(n);
// Write out the key/value pairs for the tags
for (Map.Entry<String, String> entry : commonTags.entrySet()) {
gen.writeNumber(strings.get(entry.getKey()));
gen.writeNumber(strings.get(entry.getValue()));
}
for (Tag t : id.tags()) {
gen.writeNumber(strings.get(t.key()));
gen.writeNumber(strings.get(t.value()));
}
gen.writeNumber(strings.get("name"));
gen.writeNumber(strings.get(id.name()));
// Write out the operation and delta value
gen.writeNumber(op);
gen.writeNumber(value);
}
}
内容来源于网络,如有侵权,请联系作者删除!