You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@thrift.apache.org by GitBox <gi...@apache.org> on 2021/09/06 19:53:27 UTC

[GitHub] [thrift] bhalchandrap commented on a change in pull request #2439: THRIFT-5443: add support for partial Thrift deserialization

bhalchandrap commented on a change in pull request #2439:
URL: https://github.com/apache/thrift/pull/2439#discussion_r703055792



##########
File path: lib/java/src/org/apache/thrift/partial/PartialThriftCompactProtocol.java
##########
@@ -0,0 +1,93 @@
+/*
+ * 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.
+ */
+
+package org.apache.thrift.partial;
+
+import org.apache.thrift.TException;
+import org.apache.thrift.protocol.TCompactProtocol;
+import org.apache.thrift.protocol.TField;
+import org.apache.thrift.protocol.TProtocol;
+
+import java.io.Serializable;
+
+/**
+ * Enables partial deserialization of compact-encoded thrift objects.
+ *
+ * This class is meant to be a helper class for {@link PartialThriftDeserializer}.
+ * It cannot be used separately on its own.
+ */
+public class PartialThriftCompactProtocol extends PartialThriftProtocol implements Serializable {
+
+  public PartialThriftCompactProtocol() {
+  }
+
+  @Override
+  protected TProtocol createProtocol() {
+    return new TCompactProtocol(transport);
+  }
+
+  // -----------------------------------------------------------------
+  // Additional methods to improve performance.
+
+  @Override
+  public int readFieldBeginData() throws TException {
+    // Having to call readFieldBegin() to compute TFieldData really results in lower
+    // performance. However, readFieldBegin() accesses some private vars that this method
+    // does not have access to. We could make it more performant when contributing to
+    // origianl source code.

Review comment:
       added a TODO comment for now. That way we can better separate original contribution from subsequent performance improvement changes.




-- 
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: notifications-unsubscribe@thrift.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org