bytemain commented on code in PR #1313:
URL: https://github.com/apache/incubator-fury/pull/1313#discussion_r1443663449


##########
javascript/packages/fury/lib/classResolver.ts:
##########
@@ -158,26 +184,15 @@ export default class SerializerResolver {
         this.writeStringIndex[idx] = this.writeStringCount++;
         binaryWriter.buffer(fullBuffer);
       },
-      bufferLen,
     };
   }
 
-  detectTag(binaryReader: BinaryReader) {
-    const flag = binaryReader.uint8();
-    if (flag === USESTRINGVALUE) {
-      binaryReader.skip(8); // The tag hash is not needed at the moment.
-      return binaryReader.stringUtf8(binaryReader.int16());
-    } else {
-      return this.readStringPool[binaryReader.int16()].toString(binaryReader);
-    }
-  }
-
   readTag(binaryReader: BinaryReader) {
     const flag = binaryReader.uint8();
     if (flag === USESTRINGVALUE) {
       binaryReader.skip(8); // The tag hash is not needed at the moment.
-      const start = binaryReader.getCursor();
       const len = binaryReader.int16();
+      const start = binaryReader.getCursor();
       binaryReader.skip(len);
       this.readStringPool.push(Lazystring.fromPair(start, len));

Review Comment:
   I think the class name should use camel case
   
   ```diff
   - class Lazystring
   + class LazyString
   ```



##########
javascript/packages/fury/lib/gen/index.ts:
##########
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { InternalSerializerType, Fury } from "../type";
+import { ArrayTypeDescription, MapTypeDescription, ObjectTypeDescription, 
SetTypeDescription, TupleTypeDescription, TypeDescription } from 
"../description";
+import { Register } from "./router";
+import { Builder } from "./builder";
+import { Scope } from "./scope";
+import "./array";
+import "./object";
+import "./string";
+import "./binary";
+import "./bool";
+import "./datetime";
+import "./map";
+import "./number";
+import "./set";
+import "./any";
+import "./tuple";
+import "./typedArray";
+
+export const generate = (fury: Fury, description: TypeDescription) => {
+  const InnerGeneratorClass = Register.get(description.type);
+  if (!InnerGeneratorClass) {
+    throw new Error(`${description.type} generator not exists`);
+  }
+  const scope = new Scope();
+  const generator = new InnerGeneratorClass(description, new Builder(scope, 
fury), scope);
+
+  const funcString = generator.toSerializer();
+  return new Function(funcString);
+};
+
+function regDependences(fury: Fury, description: TypeDescription) {

Review Comment:
   ```diff
   - regDependences
   + regDependencies
   ```



##########
javascript/packages/fury/lib/type.ts:
##########
@@ -28,7 +29,7 @@ export type BinaryReader = ReturnType<typeof BinaryReader>;
 export enum InternalSerializerType {
   STRING = 13,
   ARRAY = 25,
-  TUPLE = 25,
+  TUPLE = 25.1,

Review Comment:
   after the enum value change, we can remove the redundant code now:
   <img width="1581" alt="image" 
src="https://github.com/apache/incubator-fury/assets/13938334/54a7cfd9-3541-43bc-82b3-b33207cfab32";>
   



-- 
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]

Reply via email to