本文整理汇总了Java中org.iotp.infomgt.data.kv.BasicTsKvEntry类的典型用法代码示例。如果您正苦于以下问题:Java BasicTsKvEntry类的具体用法?Java BasicTsKvEntry怎么用?Java BasicTsKvEntry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BasicTsKvEntry类属于org.iotp.infomgt.data.kv包,在下文中一共展示了BasicTsKvEntry类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parse
import org.iotp.infomgt.data.kv.BasicTsKvEntry; //导入依赖的package包/类
private List<DeviceData> parse(String topic, List<String> srcList) {
List<DeviceData> result = new ArrayList<>(srcList.size());
for (String src : srcList) {
DocumentContext document = JsonPath.parse(src);
long ts = System.currentTimeMillis();
String deviceName;
if (!StringUtils.isEmpty(deviceNameTopicExpression)) {
deviceName = eval(topic);
} else {
deviceName = eval(document, deviceNameJsonExpression);
}
if (!StringUtils.isEmpty(deviceName)) {
List<KvEntry> attrData = getKvEntries(document, attributes);
List<TsKvEntry> tsData = getKvEntries(document, timeseries).stream().map(kv -> new BasicTsKvEntry(ts, kv))
.collect(Collectors.toList());
result.add(new DeviceData(deviceName, attrData, tsData, timeout));
}
}
return result;
}
示例2: getTsKvEntries
import org.iotp.infomgt.data.kv.BasicTsKvEntry; //导入依赖的package包/类
private List<TsKvEntry> getTsKvEntries(DocumentContext document, List<? extends TimeseriesMapping> mappings, long defaultTs) throws ParseException {
List<TsKvEntry> result = new ArrayList<>();
if (mappings != null) {
for (TransformerKVMapping mapping : mappings) {
String key = eval(document, mapping.getKey());
String strVal = eval(document, mapping.getValue());
long ts = defaultTs;
if (!StringUtils.isEmpty(mapping.getTs())) {
String tsVal = eval(document, mapping.getTs());
if (!StringUtils.isEmpty(mapping.getTsFormat())) {
SimpleDateFormat formatter = formatters.computeIfAbsent(mapping.getTsFormat(), SimpleDateFormat::new);
ts = formatter.parse(tsVal).getTime();
} else {
ts = Long.parseLong(tsVal);
}
}
DataValueTransformer transformer = mapping.getTransformer();
if (transformer != null && transformer.isApplicable(strVal)) {
result.add(new BasicTsKvEntry(ts, getKvEntry(mapping, key, strVal, transformer)));
} else if (transformer == null) {
result.add(new BasicTsKvEntry(ts, getKvEntry(mapping, key, strVal)));
}
}
}
return result;
}
示例3: onAttributesUpdateFromServer
import org.iotp.infomgt.data.kv.BasicTsKvEntry; //导入依赖的package包/类
public void onAttributesUpdateFromServer(PluginContext ctx, EntityId entityId, String scope, List<AttributeKvEntry> attributes) {
Optional<ServerAddress> serverAddress = ctx.resolve(entityId);
if (!serverAddress.isPresent()) {
onLocalSubscriptionUpdate(ctx, entityId, SubscriptionType.ATTRIBUTES, s -> {
List<TsKvEntry> subscriptionUpdate = new ArrayList<TsKvEntry>();
for (AttributeKvEntry kv : attributes) {
if (s.isAllKeys() || s.getKeyStates().containsKey(kv.getKey())) {
subscriptionUpdate.add(new BasicTsKvEntry(kv.getLastUpdateTs(), kv));
}
}
return subscriptionUpdate;
});
} else {
rpcHandler.onAttributesUpdate(ctx, serverAddress.get(), entityId, scope, attributes);
}
}
示例4: getAffectedTimeseries
import org.iotp.infomgt.data.kv.BasicTsKvEntry; //导入依赖的package包/类
public List<TsKvEntry> getAffectedTimeseries(NodeId tagId, DataValue dataValue) {
List<AttributesMapping> attributes = getAttributesMapping(tagId);
if (attributes.size() > 0) {
return getKvEntries(attributes).stream()
.map(kv -> new BasicTsKvEntry(dataValue.getSourceTime().getJavaTime(), kv))
.collect(Collectors.toList());
} else {
return Collections.emptyList();
}
}
示例5: parse
import org.iotp.infomgt.data.kv.BasicTsKvEntry; //导入依赖的package包/类
private List<DeviceData> parse(String topic, List<String> srcList) {
List<DeviceData> result = new ArrayList<>(srcList.size());
for (String src : srcList) {
DocumentContext document = JsonPath.parse(src);
long ts = System.currentTimeMillis();
String deviceName;
String deviceType = null;
if (!StringUtils.isEmpty(deviceNameTopicExpression)) {
deviceName = evalDeviceName(topic);
} else {
deviceName = eval(document, deviceNameJsonExpression);
}
if (!StringUtils.isEmpty(deviceTypeTopicExpression)) {
deviceType = evalDeviceType(topic);
} else if (!StringUtils.isEmpty(deviceTypeJsonExpression)) {
deviceType = eval(document, deviceTypeJsonExpression);
}
if (!StringUtils.isEmpty(deviceName)) {
List<KvEntry> attrData = getKvEntries(document, attributes);
List<TsKvEntry> tsData = getKvEntries(document, timeseries).stream()
.map(kv -> new BasicTsKvEntry(ts, kv))
.collect(Collectors.toList());
result.add(new DeviceData(deviceName, deviceType, attrData, tsData, timeout));
}
}
return result;
}
示例6: pushTsEntries
import org.iotp.infomgt.data.kv.BasicTsKvEntry; //导入依赖的package包/类
private static void pushTsEntries(VelocityContext context, TelemetryUploadRequest payload) {
payload.getData().forEach((k, vList) -> {
vList.forEach(v -> {
context.put(v.getKey(), new BasicTsKvEntry(k, v));
});
});
}
示例7: convertResultToTsKvEntry
import org.iotp.infomgt.data.kv.BasicTsKvEntry; //导入依赖的package包/类
private TsKvEntry convertResultToTsKvEntry(String key, Row row) {
if (row != null) {
long ts = row.getLong(ModelConstants.TS_COLUMN);
return new BasicTsKvEntry(ts, toKvEntry(row, key));
} else {
return new BasicTsKvEntry(System.currentTimeMillis(), new StringDataEntry(key, null));
}
}
示例8: toTimeseries
import org.iotp.infomgt.data.kv.BasicTsKvEntry; //导入依赖的package包/类
private TsKvEntry toTimeseries(KeyValueProto proto) {
return new BasicTsKvEntry(proto.getTs(), getKvEntry(proto));
}