Commit b04949c62cff2ae1960bb35657fd8fa6368addda

Authored by Igor Kulikov
1 parent 1298f6b1

Null values support for subscription update values proto

... ... @@ -492,12 +492,14 @@ public class DefaultSubscriptionManagerService extends TbApplicationEventListene
492 492 boolean hasData = false;
493 493 for (Object v : value) {
494 494 Object[] array = (Object[]) v;
495   - dataBuilder.addTs((long) array[0]);
  495 + TbSubscriptionUpdateTsValue.Builder tsValueBuilder = TbSubscriptionUpdateTsValue.newBuilder();
  496 + tsValueBuilder.setTs((long) array[0]);
496 497 String strVal = (String) array[1];
497 498 if (strVal != null) {
498 499 hasData = true;
499   - dataBuilder.addValue(strVal);
  500 + tsValueBuilder.setValue(strVal);
500 501 }
  502 + dataBuilder.addTsValue(tsValueBuilder.build());
501 503 }
502 504 if (!ignoreEmptyUpdates || hasData) {
503 505 builder.addData(dataBuilder.build());
... ...
... ... @@ -42,6 +42,7 @@ import org.thingsboard.server.gen.transport.TransportProtos.TbSubscriptionCloseP
42 42 import org.thingsboard.server.gen.transport.TransportProtos.TbSubscriptionKetStateProto;
43 43 import org.thingsboard.server.gen.transport.TransportProtos.TbSubscriptionProto;
44 44 import org.thingsboard.server.gen.transport.TransportProtos.TbSubscriptionUpdateProto;
  45 +import org.thingsboard.server.gen.transport.TransportProtos.TbSubscriptionUpdateTsValue;
45 46 import org.thingsboard.server.gen.transport.TransportProtos.TbTimeSeriesSubscriptionProto;
46 47 import org.thingsboard.server.gen.transport.TransportProtos.TbTimeSeriesUpdateProto;
47 48 import org.thingsboard.server.gen.transport.TransportProtos.ToCoreMsg;
... ... @@ -171,10 +172,11 @@ public class TbSubscriptionUtils {
171 172 Map<String, List<Object>> data = new TreeMap<>();
172 173 proto.getDataList().forEach(v -> {
173 174 List<Object> values = data.computeIfAbsent(v.getKey(), k -> new ArrayList<>());
174   - for (int i = 0; i < v.getTsCount(); i++) {
  175 + for (int i = 0; i < v.getTsValueCount(); i++) {
175 176 Object[] value = new Object[2];
176   - value[0] = v.getTs(i);
177   - value[1] = v.getValue(i);
  177 + TbSubscriptionUpdateTsValue tsValue = v.getTsValue(i);
  178 + value[0] = tsValue.getTs();
  179 + value[1] = tsValue.hasValue() ? tsValue.getValue() : null;
178 180 values.add(value);
179 181 }
180 182 });
... ...
... ... @@ -14,6 +14,7 @@
14 14 * limitations under the License.
15 15 */
16 16 syntax = "proto3";
  17 +
17 18 package transport;
18 19
19 20 option java_package = "org.thingsboard.server.gen.transport";
... ... @@ -581,8 +582,12 @@ message TbSubscriptionKetStateProto {
581 582
582 583 message TbSubscriptionUpdateValueListProto {
583 584 string key = 1;
584   - repeated int64 ts = 2;
585   - repeated string value = 3;
  585 + repeated TbSubscriptionUpdateTsValue tsValue = 2;
  586 +}
  587 +
  588 +message TbSubscriptionUpdateTsValue {
  589 + int64 ts = 1;
  590 + optional string value = 2;
586 591 }
587 592
588 593 /**
... ...