LiangliangSui commented on code in PR #1549:
URL: https://github.com/apache/incubator-fury/pull/1549#discussion_r1574037436
##########
javascript/packages/fury/lib/gen/map.ts:
##########
@@ -21,77 +21,237 @@ import { MapTypeDescription, TypeDescription } from
"../description";
import { CodecBuilder } from "./builder";
import { BaseSerializerGenerator, RefState } from "./serializer";
import { CodegenRegistry } from "./router";
-import { InternalSerializerType } from "../type";
+import { InternalSerializerType, RefFlags, Serializer } from "../type";
import { Scope } from "./scope";
+import Fury from "../fury";
-class MapSerializerGenerator extends BaseSerializerGenerator {
- description: MapTypeDescription;
+const MapFlags = {
+ /** Whether track elements ref. */
+ TRACKING_REF: 0b1,
+
+ /** Whether collection has null. */
+ HAS_NULL: 0b10,
+
+ /** Whether collection elements type is not declare type. */
+ NOT_DECL_ELEMENT_TYPE: 0b100,
+
+ /** Whether collection elements type different. */
+ NOT_SAME_TYPE: 0b1000,
+};
+
+class MapChunkWriter {
+ private kFlag = 0;
+ private vFlag = 0;
+
+ private chunkSize = 0;
+ private chunkOffset = 0;
+ private header = 0;
+
+ constructor(private fury: Fury) {
- constructor(description: TypeDescription, builder: CodecBuilder, scope:
Scope) {
- super(description, builder, scope);
- this.description = <MapTypeDescription>description;
}
- private innerMeta() {
- const key = this.description.options.key;
- const value = this.description.options.value;
- return [this.builder.meta(key), this.builder.meta(value)];
+ private getHead(keyFlag: number, valueFlag: number) {
+ let flag = 0;
+ if (keyFlag & 0b10) {
+ flag |= MapFlags.HAS_NULL;
+ }
+ if (keyFlag & 0b01) {
+ flag |= MapFlags.TRACKING_REF;
+ }
+ flag <<= 4;
+ if (valueFlag & 0b10) {
+ flag |= MapFlags.HAS_NULL;
+ }
+ if (valueFlag & 0b01) {
+ flag |= MapFlags.TRACKING_REF;
+ }
+ return flag;
+ }
Review Comment:
```suggestion
private getHead(keyFlag: number, valueFlag: number) {
let flag = 0;
if (keyFlag & MapFlags.HAS_NULL) {
flag |= MapFlags.HAS_NULL;
}
if (keyFlag & MapFlags.TRACKING_REF) {
flag |= MapFlags.TRACKING_REF;
}
flag <<= 4;
if (valueFlag & MapFlags.HAS_NULL) {
flag |= MapFlags.HAS_NULL;
}
if (valueFlag & MapFlags.TRACKING_REF) {
flag |= MapFlags.TRACKING_REF;
}
return flag;
}
```
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]