snuyanzin commented on code in PR #29026:
URL: https://github.com/apache/flink/pull/29026#discussion_r3907440168
##########
flink-core/src/main/java/org/apache/flink/types/variant/BinaryVariantInternalBuilder.java:
##########
@@ -304,41 +321,41 @@ public void appendBinary(byte[] binary) {
writePos += binary.length;
}
- // Add a key to the variant dictionary. If the key already exists, the
dictionary is not
- // modified.
- // In either case, return the id of the key.
+ /**
+ * Add a key to the variant dictionary. If the key already exists, the
dictionary is not
+ * modified. In either case, return the id of the key.
+ */
public int addKey(String key) {
- int id;
- if (dictionary.containsKey(key)) {
- id = dictionary.get(key);
- } else {
+ Integer id = dictionary.get(key);
+ if (id == null) {
id = dictionaryKeys.size();
dictionary.put(key, id);
dictionaryKeys.add(key.getBytes(StandardCharsets.UTF_8));
}
return id;
}
- // Return the current write position of the variant builder. It is used
together with
- // `finishWritingObject` or `finishWritingArray`.
+ /**
+ * Return the current write position of the variant builder. It is used
together with
+ * `finishWritingObject` or `finishWritingArray`.
+ */
public int getWritePos() {
return writePos;
}
- // Finish writing a variant object after all of its fields have already
been written. The
- // process
- // is as follows:
- // 1. The caller calls `getWritePos` before writing any fields to obtain
the `start` parameter.
- // 2. The caller appends all the object fields to the builder. In the
meantime, it should
- // maintain
- // the `fields` parameter. Before appending each field, it should append
an entry to `fields` to
- // record the offset of the field. The offset is computed as
`getWritePos() - start`.
- // 3. The caller calls `finishWritingObject` to finish writing a variant
object.
- //
- // This function is responsible to sort the fields by key. If there are
duplicate field keys:
- // - when `allowDuplicateKeys` is true, the field with the greatest offset
value (the last
- // appended one) is kept.
- // - otherwise, throw an exception.
+ /**
+ * Finish writing a variant object after all of its fields have already
been written. The
+ * process is as follows: 1. The caller calls `getWritePos` before writing
any fields to obtain
+ * the `start` parameter. 2. The caller appends all the object fields to
the builder. In the
+ * meantime, it should maintain the `fields` parameter. Before appending
each field, it should
+ * append an entry to `fields` to record the offset of the field. The
offset is computed as
+ * `getWritePos() - start`. 3. The caller calls `finishWritingObject` to
finish writing a
Review Comment:
if there are 1., 2., 3. bullets
should there be `<ol>`, <li>` used?
##########
flink-core/src/main/java/org/apache/flink/types/variant/BinaryVariantInternalBuilder.java:
##########
@@ -304,41 +321,41 @@ public void appendBinary(byte[] binary) {
writePos += binary.length;
}
- // Add a key to the variant dictionary. If the key already exists, the
dictionary is not
- // modified.
- // In either case, return the id of the key.
+ /**
+ * Add a key to the variant dictionary. If the key already exists, the
dictionary is not
+ * modified. In either case, return the id of the key.
+ */
public int addKey(String key) {
- int id;
- if (dictionary.containsKey(key)) {
- id = dictionary.get(key);
- } else {
+ Integer id = dictionary.get(key);
+ if (id == null) {
id = dictionaryKeys.size();
dictionary.put(key, id);
dictionaryKeys.add(key.getBytes(StandardCharsets.UTF_8));
}
return id;
}
- // Return the current write position of the variant builder. It is used
together with
- // `finishWritingObject` or `finishWritingArray`.
+ /**
+ * Return the current write position of the variant builder. It is used
together with
+ * `finishWritingObject` or `finishWritingArray`.
+ */
public int getWritePos() {
return writePos;
}
- // Finish writing a variant object after all of its fields have already
been written. The
- // process
- // is as follows:
- // 1. The caller calls `getWritePos` before writing any fields to obtain
the `start` parameter.
- // 2. The caller appends all the object fields to the builder. In the
meantime, it should
- // maintain
- // the `fields` parameter. Before appending each field, it should append
an entry to `fields` to
- // record the offset of the field. The offset is computed as
`getWritePos() - start`.
- // 3. The caller calls `finishWritingObject` to finish writing a variant
object.
- //
- // This function is responsible to sort the fields by key. If there are
duplicate field keys:
- // - when `allowDuplicateKeys` is true, the field with the greatest offset
value (the last
- // appended one) is kept.
- // - otherwise, throw an exception.
+ /**
+ * Finish writing a variant object after all of its fields have already
been written. The
+ * process is as follows: 1. The caller calls `getWritePos` before writing
any fields to obtain
+ * the `start` parameter. 2. The caller appends all the object fields to
the builder. In the
+ * meantime, it should maintain the `fields` parameter. Before appending
each field, it should
+ * append an entry to `fields` to record the offset of the field. The
offset is computed as
+ * `getWritePos() - start`. 3. The caller calls `finishWritingObject` to
finish writing a
Review Comment:
if there are 1., 2., 3. bullets
should there be `<ol>`, `<li>` used?
--
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]