ademakov commented on code in PR #1152:
URL: https://github.com/apache/ignite-3/pull/1152#discussion_r985764110
##########
modules/binary-tuple/src/main/java/org/apache/ignite/internal/binarytuple/BinaryTupleBuilder.java:
##########
@@ -527,6 +529,78 @@ public BinaryTupleBuilder appendTimestamp(Instant value) {
return value == null ? appendNull() : appendTimestampNotNull(value);
}
+ /**
+ * Append a value for the current element.
+ *
+ * @param value Element value.
+ * @return {@code this} for chaining.
+ */
+ public BinaryTupleBuilder appendDurationNotNull(Duration value) {
+ if (value != BinaryTupleCommon.DEFAULT_DURATION) {
+ long seconds = value.getSeconds();
+ int nanos = value.getNano();
+ putLong(seconds);
+ if (nanos != 0) {
+ putInt(nanos);
+ }
+ }
+ return proceed();
+ }
+
+ /**
+ * Append a value for the current element.
+ *
+ * @param value Element value.
+ * @return {@code this} for chaining.
+ */
+ public BinaryTupleBuilder appendDuration(Duration value) {
+ return value == null ? appendNull() : appendDurationNotNull(value);
+ }
+
+ /**
+ * Append a value for the current element.
+ *
+ * @param value Element value.
+ * @return {@code this} for chaining.
+ */
+ public BinaryTupleBuilder appendPeriodNotNull(Period value) {
+ if (value != BinaryTupleCommon.DEFAULT_PERIOD) {
+ int years = value.getYears();
+ int months = value.getMonths();
+ int days = value.getDays();
+
+ if (Byte.MIN_VALUE <= years && years <= Byte.MAX_VALUE
+ && Byte.MIN_VALUE <= months && months <= Byte.MAX_VALUE
+ && Byte.MIN_VALUE <= days && days <= Byte.MAX_VALUE) {
+ putByte((byte) years);
+ putByte((byte) months);
+ putByte((byte) days);
+ } else if (Short.MIN_VALUE <= years && years <= Short.MAX_VALUE
+ && Short.MIN_VALUE <= months && months <= Short.MAX_VALUE
+ && Short.MIN_VALUE <= days && days <= Short.MAX_VALUE) {
+ putShort((short) years);
+ putShort((short) months);
+ putShort((short) days);
+ } else {
+ putInt(years);
+ putInt(months);
+ putInt(days);
+ }
+ }
Review Comment:
I see, thanks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]