You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2019/01/14 03:18:16 UTC
[servicecomb-java-chassis] 10/16: [SCB-1071][WIP] avoid repeated
read schemas always run as dynamic type and support packed value
This is an automated email from the ASF dual-hosted git repository.
liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git
commit 3c7bd93cfd628e2addd96cfa2438700e9b22bb43
Author: wujimin <wu...@huawei.com>
AuthorDate: Sat Jan 5 20:25:20 2019 +0800
[SCB-1071][WIP] avoid repeated read schemas always run as dynamic type and support packed value
---
.../repeated/AbstractPrimitiveReaders.java | 29 ++++++
.../deserializer/repeated/AbstractReaders.java | 48 +++++++++
.../repeated/PrimitiveArrayBuilderWrapper.java | 41 ++++++++
.../deserializer/repeated/RepeatedReadSchemas.java | 110 +++++++++++++++++++++
.../deserializer/repeated/RepeatedReader.java | 25 +++++
.../repeated/impl/AnyRepeatedReadSchemas.java | 50 ++++++++++
.../repeated/impl/BytesRepeatedReadSchemas.java | 47 +++++++++
.../repeated/impl/MessageRepeatedReadSchemas.java | 50 ++++++++++
.../repeated/impl/StringRepeatedReadSchemas.java | 47 +++++++++
.../impl/bools/BoolRepeatedReadSchemas.java | 90 +++++++++++++++++
.../impl/bools/impl/BoolNotPackedReadSchemas.java | 69 +++++++++++++
.../impl/bools/impl/BoolPackedReadSchemas.java | 69 +++++++++++++
.../impl/doubles/DoubleRepeatedReadSchemas.java | 90 +++++++++++++++++
.../doubles/impl/DoubleNotPackedReadSchemas.java | 69 +++++++++++++
.../impl/doubles/impl/DoublePackedReadSchemas.java | 69 +++++++++++++
.../impl/enums/EnumNotPackedReadSchemas.java | 109 ++++++++++++++++++++
.../repeated/impl/enums/EnumPackedReadSchemas.java | 109 ++++++++++++++++++++
.../repeated/impl/enums/EnumSchemaUtils.java | 34 +++++++
.../impl/floats/FloatRepeatedReadSchemas.java | 90 +++++++++++++++++
.../floats/impl/FloatNotPackedReadSchemas.java | 69 +++++++++++++
.../impl/floats/impl/FloatPackedReadSchemas.java | 69 +++++++++++++
.../repeated/impl/ints/IntRepeatedReadSchemas.java | 90 +++++++++++++++++
.../ints/impl/Fixed32NotPackedReadSchemas.java | 69 +++++++++++++
.../impl/ints/impl/Fixed32PackedReadSchemas.java | 69 +++++++++++++
.../impl/ints/impl/Int32NotPackedReadSchemas.java | 69 +++++++++++++
.../impl/ints/impl/Int32PackedReadSchemas.java | 69 +++++++++++++
.../ints/impl/SFixed32NotPackedReadSchemas.java | 69 +++++++++++++
.../impl/ints/impl/SFixed32PackedReadSchemas.java | 69 +++++++++++++
.../impl/ints/impl/SInt32NotPackedReadSchemas.java | 69 +++++++++++++
.../impl/ints/impl/SInt32PackedReadSchemas.java | 69 +++++++++++++
.../impl/ints/impl/UInt32NotPackedReadSchemas.java | 69 +++++++++++++
.../impl/ints/impl/UInt32PackedReadSchemas.java | 69 +++++++++++++
.../impl/longs/LongRepeatedReadSchemas.java | 90 +++++++++++++++++
.../longs/impl/Fixed64NotPackedReadSchemas.java | 69 +++++++++++++
.../impl/longs/impl/Fixed64PackedReadSchemas.java | 69 +++++++++++++
.../impl/longs/impl/Int64NotPackedReadSchemas.java | 69 +++++++++++++
.../impl/longs/impl/Int64PackedReadSchemas.java | 69 +++++++++++++
.../longs/impl/SFixed64NotPackedReadSchemas.java | 69 +++++++++++++
.../impl/longs/impl/SFixed64PackedReadSchemas.java | 69 +++++++++++++
.../longs/impl/SInt64NotPackedReadSchemas.java | 69 +++++++++++++
.../impl/longs/impl/SInt64PackedReadSchemas.java | 69 +++++++++++++
.../longs/impl/UInt64NotPackedReadSchemas.java | 69 +++++++++++++
.../impl/longs/impl/UInt64PackedReadSchemas.java | 69 +++++++++++++
43 files changed, 2943 insertions(+)
diff --git a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/AbstractPrimitiveReaders.java b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/AbstractPrimitiveReaders.java
new file mode 100644
index 0000000..e43f6b6
--- /dev/null
+++ b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/AbstractPrimitiveReaders.java
@@ -0,0 +1,29 @@
+/*
+ * 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.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated;
+
+import io.protostuff.compiler.model.Field;
+
+public abstract class AbstractPrimitiveReaders<PRIMITIVE_ARRAY, PRIMITIVE_WRAPPER> extends
+ AbstractReaders<PRIMITIVE_WRAPPER> {
+ public RepeatedReader<PrimitiveArrayBuilderWrapper<PRIMITIVE_ARRAY>> primitiveArrayReader;
+
+ @SuppressWarnings("unchecked")
+ public AbstractPrimitiveReaders(Field protoField) {
+ super(protoField);
+ }
+}
diff --git a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/AbstractReaders.java b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/AbstractReaders.java
new file mode 100644
index 0000000..0143c12
--- /dev/null
+++ b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/AbstractReaders.java
@@ -0,0 +1,48 @@
+/*
+ * 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.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated;
+
+import static org.apache.servicecomb.foundation.common.utils.ReflectUtils.getFieldArgument;
+
+import java.util.Collection;
+
+import io.protostuff.compiler.model.Field;
+
+public abstract class AbstractReaders<T> {
+ protected final Field protoField;
+
+ protected final int fieldNumber;
+
+ public RepeatedReader<Collection<T>> collectionReader;
+
+ public final Class<T[]> arrayClass;
+
+ @SuppressWarnings("unchecked")
+ public AbstractReaders(Field protoField) {
+ this(protoField, null);
+ }
+
+ public AbstractReaders(Field protoField, Class<T[]> arrayClass) {
+ this.protoField = protoField;
+ this.fieldNumber = protoField.getTag();
+
+ if (arrayClass == null) {
+ arrayClass = getFieldArgument(this.getClass(), "arrayClass");
+ }
+ this.arrayClass = arrayClass;
+ }
+}
diff --git a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/PrimitiveArrayBuilderWrapper.java b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/PrimitiveArrayBuilderWrapper.java
new file mode 100644
index 0000000..cb2bafe
--- /dev/null
+++ b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/PrimitiveArrayBuilderWrapper.java
@@ -0,0 +1,41 @@
+/*
+ * 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.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated;
+
+import com.fasterxml.jackson.databind.util.PrimitiveArrayBuilder;
+
+public class PrimitiveArrayBuilderWrapper<T> {
+ private PrimitiveArrayBuilder<T> builder;
+
+ private T array;
+
+ public PrimitiveArrayBuilderWrapper(PrimitiveArrayBuilder<T> builder) {
+ this.builder = builder;
+ }
+
+ public T getArray() {
+ return array;
+ }
+
+ public void setArray(T array) {
+ this.array = array;
+ }
+
+ public PrimitiveArrayBuilder<T> getBuilder() {
+ return builder;
+ }
+}
diff --git a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/RepeatedReadSchemas.java b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/RepeatedReadSchemas.java
new file mode 100644
index 0000000..771bafd
--- /dev/null
+++ b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/RepeatedReadSchemas.java
@@ -0,0 +1,110 @@
+/*
+ * 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.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated;
+
+import java.io.IOException;
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.apache.servicecomb.foundation.common.utils.bean.Getter;
+import org.apache.servicecomb.foundation.common.utils.bean.Setter;
+import org.apache.servicecomb.foundation.protobuf.internal.ProtoUtils;
+import org.apache.servicecomb.foundation.protobuf.internal.bean.PropertyDescriptor;
+
+import com.fasterxml.jackson.databind.JavaType;
+
+import io.protostuff.InputEx;
+import io.protostuff.compiler.model.Field;
+import io.protostuff.runtime.FieldSchema;
+
+public class RepeatedReadSchemas {
+ public static <T, ELE_TYPE> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor,
+ AbstractReaders<ELE_TYPE> readers) {
+ JavaType javaType = propertyDescriptor.getJavaType();
+ if (readers.arrayClass.isAssignableFrom(javaType.getRawClass())) {
+ return new ArrayRepeatedSchema<>(protoField, propertyDescriptor, readers);
+ }
+
+ if (Collection.class.isAssignableFrom(javaType.getRawClass()) || javaType.isJavaLangObject()) {
+ return new CollectionRepeatedSchema<>(protoField, propertyDescriptor, readers);
+ }
+
+ ProtoUtils.throwNotSupportMerge(protoField, javaType);
+ return null;
+ }
+
+ static class AbstractRepeatedSchema<T, ELE_TYPE> extends FieldSchema<T> {
+ protected final AbstractReaders<ELE_TYPE> readers;
+
+ public AbstractRepeatedSchema(Field protoField, PropertyDescriptor propertyDescriptor,
+ AbstractReaders<ELE_TYPE> readers) {
+ super(protoField, propertyDescriptor.getJavaType());
+ this.readers = readers;
+ }
+ }
+
+ static class CollectionRepeatedSchema<T, ELE_TYPE> extends AbstractRepeatedSchema<T, ELE_TYPE> {
+ private final Getter<T, Collection<ELE_TYPE>> getter;
+
+ private final Setter<T, Collection<ELE_TYPE>> setter;
+
+ public CollectionRepeatedSchema(Field protoField, PropertyDescriptor propertyDescriptor,
+ AbstractReaders<ELE_TYPE> readers) {
+ super(protoField, propertyDescriptor, readers);
+ this.getter = propertyDescriptor.getGetter();
+ this.setter = propertyDescriptor.getSetter();
+ }
+
+ @Override
+ public final int mergeFrom(InputEx input, T message) throws IOException {
+ Collection<ELE_TYPE> collection = getter.get(message);
+ if (collection == null) {
+ collection = new ArrayList<>();
+ setter.set(message, collection);
+ }
+
+ return readers.collectionReader.read(input, collection);
+ }
+ }
+
+ static class ArrayRepeatedSchema<T, ELE_TYPE> extends AbstractRepeatedSchema<T, ELE_TYPE> {
+ private final Getter<T, ELE_TYPE[]> getter;
+
+ private final Setter<T, ELE_TYPE[]> setter;
+
+ public ArrayRepeatedSchema(Field protoField, PropertyDescriptor propertyDescriptor,
+ AbstractReaders<ELE_TYPE> readers) {
+ super(protoField, propertyDescriptor, readers);
+ this.getter = propertyDescriptor.getGetter();
+ this.setter = propertyDescriptor.getSetter();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public final int mergeFrom(InputEx input, T message) throws IOException {
+ ELE_TYPE[] array = getter.get(message);
+ Collection<ELE_TYPE> collection = array == null ? new ArrayList<>() : new ArrayList<>(Arrays.asList(array));
+ int fieldNumber = readers.collectionReader.read(input, collection);
+
+ ELE_TYPE[] newArray = (ELE_TYPE[]) Array.newInstance(readers.arrayClass.getComponentType(), collection.size());
+ setter.set(message, collection.toArray(newArray));
+ return fieldNumber;
+ }
+ }
+}
diff --git a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/RepeatedReader.java b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/RepeatedReader.java
new file mode 100644
index 0000000..fec171f
--- /dev/null
+++ b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/RepeatedReader.java
@@ -0,0 +1,25 @@
+/*
+ * 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.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated;
+
+import java.io.IOException;
+
+import io.protostuff.InputEx;
+
+public interface RepeatedReader<T> {
+ int read(InputEx input, T value) throws IOException;
+}
diff --git a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/AnyRepeatedReadSchemas.java b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/AnyRepeatedReadSchemas.java
new file mode 100644
index 0000000..27251ba
--- /dev/null
+++ b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/AnyRepeatedReadSchemas.java
@@ -0,0 +1,50 @@
+/*
+ * 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.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl;
+
+import org.apache.servicecomb.foundation.protobuf.internal.bean.PropertyDescriptor;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.any.AnyEntrySchema;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.AbstractReaders;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.RepeatedReadSchemas;
+
+import io.protostuff.compiler.model.Field;
+import io.protostuff.runtime.FieldSchema;
+
+public class AnyRepeatedReadSchemas {
+ private static class MessageReaders extends AbstractReaders<Object> {
+ public MessageReaders(Field protoField, AnyEntrySchema anyEntrySchema) {
+ super(protoField);
+
+ collectionReader = (input, collection) -> {
+ while (true) {
+ Object value = anyEntrySchema.deseriaze(input);
+ collection.add(value);
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ return fieldNumber;
+ }
+ }
+ };
+ }
+ }
+
+ public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor,
+ AnyEntrySchema anyEntrySchema) {
+ return RepeatedReadSchemas.create(protoField, propertyDescriptor, new MessageReaders(protoField, anyEntrySchema));
+ }
+}
diff --git a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/BytesRepeatedReadSchemas.java b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/BytesRepeatedReadSchemas.java
new file mode 100644
index 0000000..c1534c9
--- /dev/null
+++ b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/BytesRepeatedReadSchemas.java
@@ -0,0 +1,47 @@
+/*
+ * 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.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl;
+
+import org.apache.servicecomb.foundation.protobuf.internal.bean.PropertyDescriptor;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.AbstractReaders;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.RepeatedReadSchemas;
+
+import io.protostuff.compiler.model.Field;
+import io.protostuff.runtime.FieldSchema;
+
+public class BytesRepeatedReadSchemas {
+ private static class BytesReaders extends AbstractReaders<byte[]> {
+ public BytesReaders(Field protoField) {
+ super(protoField);
+
+ collectionReader = (input, collection) -> {
+ while (true) {
+ collection.add(input.readByteArray());
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ return fieldNumber;
+ }
+ }
+ };
+ }
+ }
+
+ public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
+ return RepeatedReadSchemas.create(protoField, propertyDescriptor, new BytesReaders(protoField));
+ }
+}
diff --git a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/MessageRepeatedReadSchemas.java b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/MessageRepeatedReadSchemas.java
new file mode 100644
index 0000000..7f6dfa7
--- /dev/null
+++ b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/MessageRepeatedReadSchemas.java
@@ -0,0 +1,50 @@
+/*
+ * 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.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl;
+
+import org.apache.servicecomb.foundation.protobuf.internal.bean.PropertyDescriptor;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.AbstractReaders;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.RepeatedReadSchemas;
+
+import io.protostuff.SchemaReader;
+import io.protostuff.compiler.model.Field;
+import io.protostuff.runtime.FieldSchema;
+
+public class MessageRepeatedReadSchemas {
+ private static class MessageReaders extends AbstractReaders<Object> {
+ public MessageReaders(Field protoField, SchemaReader<Object> elementSchema) {
+ super(protoField);
+
+ collectionReader = (input, collection) -> {
+ while (true) {
+ Object value = input.mergeObject(null, elementSchema);
+ collection.add(value);
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ return fieldNumber;
+ }
+ }
+ };
+ }
+ }
+
+ public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor,
+ SchemaReader<Object> elementSchema) {
+ return RepeatedReadSchemas.create(protoField, propertyDescriptor, new MessageReaders(protoField, elementSchema));
+ }
+}
diff --git a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/StringRepeatedReadSchemas.java b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/StringRepeatedReadSchemas.java
new file mode 100644
index 0000000..2f64516
--- /dev/null
+++ b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/StringRepeatedReadSchemas.java
@@ -0,0 +1,47 @@
+/*
+ * 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.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl;
+
+import org.apache.servicecomb.foundation.protobuf.internal.bean.PropertyDescriptor;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.AbstractReaders;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.RepeatedReadSchemas;
+
+import io.protostuff.compiler.model.Field;
+import io.protostuff.runtime.FieldSchema;
+
+public class StringRepeatedReadSchemas {
+ private static class StringReaders extends AbstractReaders<String> {
+ public StringReaders(Field protoField) {
+ super(protoField);
+
+ collectionReader = (input, collection) -> {
+ while (true) {
+ collection.add(input.readString());
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ return fieldNumber;
+ }
+ }
+ };
+ }
+ }
+
+ public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
+ return RepeatedReadSchemas.create(protoField, propertyDescriptor, new StringReaders(protoField));
+ }
+}
diff --git a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/bools/BoolRepeatedReadSchemas.java b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/bools/BoolRepeatedReadSchemas.java
new file mode 100644
index 0000000..c22252e
--- /dev/null
+++ b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/bools/BoolRepeatedReadSchemas.java
@@ -0,0 +1,90 @@
+/*
+ * 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.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.bools;
+
+import java.io.IOException;
+import java.util.Arrays;
+
+import org.apache.servicecomb.foundation.common.utils.bean.Getter;
+import org.apache.servicecomb.foundation.common.utils.bean.Setter;
+import org.apache.servicecomb.foundation.protobuf.internal.bean.PropertyDescriptor;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.AbstractPrimitiveReaders;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.PrimitiveArrayBuilderWrapper;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.RepeatedReadSchemas;
+
+import com.fasterxml.jackson.databind.JavaType;
+
+import io.protostuff.InputEx;
+import io.protostuff.compiler.model.Field;
+import io.protostuff.runtime.FieldSchema;
+
+public class BoolRepeatedReadSchemas {
+ public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor,
+ AbstractPrimitiveReaders<boolean[], Boolean> readers) {
+ JavaType javaType = propertyDescriptor.getJavaType();
+ if (boolean[].class.equals(javaType.getRawClass())) {
+ return new BoolPrimitiveArrayRepeatedSchema<>(protoField, propertyDescriptor, readers);
+ }
+
+ return RepeatedReadSchemas.create(protoField, propertyDescriptor, readers);
+ }
+
+ static class BoolPrimitiveArrayRepeatedSchema<T> extends FieldSchema<T> {
+ private final Getter<T, boolean[]> getter;
+
+ private final Setter<T, boolean[]> setter;
+
+ private final AbstractPrimitiveReaders<boolean[], Boolean> readers;
+
+ public BoolPrimitiveArrayRepeatedSchema(Field protoField, PropertyDescriptor propertyDescriptor,
+ AbstractPrimitiveReaders<boolean[], Boolean> readers) {
+ super(protoField, propertyDescriptor.getJavaType());
+ this.getter = propertyDescriptor.getGetter();
+ this.setter = propertyDescriptor.getSetter();
+ this.readers = readers;
+ }
+
+ @Override
+ public int mergeFrom(InputEx input, T message) throws IOException {
+ PrimitiveArrayBuilderWrapper<boolean[]> builderWrapper = new PrimitiveArrayBuilderWrapper<>(
+ input.getArrayBuilders().getBooleanBuilder());
+
+ int fieldNumber = readers.primitiveArrayReader.read(input, builderWrapper);
+ boolean[] newValue = builderWrapper.getArray();
+ newValue = mergeArray(getter.get(message), newValue);
+ setter.set(message, newValue);
+
+ return fieldNumber;
+ }
+
+ private boolean[] mergeArray(boolean[] oldValue, boolean[] newValue) {
+ if (oldValue == null || oldValue.length == 0) {
+ return newValue;
+ }
+
+ return concatArray(oldValue, newValue);
+ }
+
+ private boolean[] concatArray(boolean[] oldValue, boolean[] newValue) {
+ int len1 = oldValue.length;
+ int len2 = newValue.length;
+ boolean[] result = Arrays.copyOf(oldValue, len1 + len2);
+ System.arraycopy(newValue, 0, result, len1, len2);
+ return result;
+ }
+ }
+}
diff --git a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/bools/impl/BoolNotPackedReadSchemas.java b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/bools/impl/BoolNotPackedReadSchemas.java
new file mode 100644
index 0000000..1aea9b5
--- /dev/null
+++ b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/bools/impl/BoolNotPackedReadSchemas.java
@@ -0,0 +1,69 @@
+/*
+ * 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.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.bools.impl;
+
+import org.apache.servicecomb.foundation.protobuf.internal.bean.PropertyDescriptor;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.AbstractPrimitiveReaders;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.bools.BoolRepeatedReadSchemas;
+
+import com.fasterxml.jackson.databind.util.PrimitiveArrayBuilder;
+
+import io.protostuff.compiler.model.Field;
+import io.protostuff.runtime.FieldSchema;
+
+public class BoolNotPackedReadSchemas {
+ private static class BoolNotPackedReaders extends AbstractPrimitiveReaders<boolean[], Boolean> {
+ public BoolNotPackedReaders(Field protoField) {
+ super(protoField);
+
+ this.primitiveArrayReader = (input, builderWrapper) -> {
+ PrimitiveArrayBuilder<boolean[]> builder = builderWrapper.getBuilder();
+ boolean[] chunk = builder.resetAndStart();
+ int ix = 0;
+
+ while (true) {
+ if (ix >= chunk.length) {
+ chunk = builder.appendCompletedChunk(chunk, ix);
+ ix = 0;
+ }
+ chunk[ix++] = input.readBool();
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ builderWrapper.setArray(builder.completeAndClearBuffer(chunk, ix));
+ return fieldNumber;
+ }
+ }
+ };
+
+ this.collectionReader = (input, collection) -> {
+ while (true) {
+ collection.add(input.readBool());
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ return fieldNumber;
+ }
+ }
+ };
+ }
+ }
+
+ public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
+ return BoolRepeatedReadSchemas.create(protoField, propertyDescriptor, new BoolNotPackedReaders(protoField));
+ }
+}
diff --git a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/bools/impl/BoolPackedReadSchemas.java b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/bools/impl/BoolPackedReadSchemas.java
new file mode 100644
index 0000000..5eb91e5
--- /dev/null
+++ b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/bools/impl/BoolPackedReadSchemas.java
@@ -0,0 +1,69 @@
+/*
+ * 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.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.bools.impl;
+
+import org.apache.servicecomb.foundation.protobuf.internal.bean.PropertyDescriptor;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.AbstractPrimitiveReaders;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.bools.BoolRepeatedReadSchemas;
+
+import com.fasterxml.jackson.databind.util.PrimitiveArrayBuilder;
+
+import io.protostuff.compiler.model.Field;
+import io.protostuff.runtime.FieldSchema;
+
+public class BoolPackedReadSchemas {
+ private static class BoolPackedReaders extends AbstractPrimitiveReaders<boolean[], Boolean> {
+ public BoolPackedReaders(Field protoField) {
+ super(protoField);
+
+ this.primitiveArrayReader = (input, builderWrapper) -> {
+ PrimitiveArrayBuilder<boolean[]> builder = builderWrapper.getBuilder();
+ boolean[] chunk = builder.resetAndStart();
+ int ix = 0;
+
+ while (true) {
+ if (ix >= chunk.length) {
+ chunk = builder.appendCompletedChunk(chunk, ix);
+ ix = 0;
+ }
+ chunk[ix++] = input.readPackedBool();
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ builderWrapper.setArray(builder.completeAndClearBuffer(chunk, ix));
+ return fieldNumber;
+ }
+ }
+ };
+
+ this.collectionReader = (input, collection) -> {
+ while (true) {
+ collection.add(input.readPackedBool());
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ return fieldNumber;
+ }
+ }
+ };
+ }
+ }
+
+ public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
+ return BoolRepeatedReadSchemas.create(protoField, propertyDescriptor, new BoolPackedReaders(protoField));
+ }
+}
diff --git a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/doubles/DoubleRepeatedReadSchemas.java b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/doubles/DoubleRepeatedReadSchemas.java
new file mode 100644
index 0000000..b74ca75
--- /dev/null
+++ b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/doubles/DoubleRepeatedReadSchemas.java
@@ -0,0 +1,90 @@
+/*
+ * 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.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.doubles;
+
+import java.io.IOException;
+import java.util.Arrays;
+
+import org.apache.servicecomb.foundation.common.utils.bean.Getter;
+import org.apache.servicecomb.foundation.common.utils.bean.Setter;
+import org.apache.servicecomb.foundation.protobuf.internal.bean.PropertyDescriptor;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.AbstractPrimitiveReaders;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.PrimitiveArrayBuilderWrapper;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.RepeatedReadSchemas;
+
+import com.fasterxml.jackson.databind.JavaType;
+
+import io.protostuff.InputEx;
+import io.protostuff.compiler.model.Field;
+import io.protostuff.runtime.FieldSchema;
+
+public class DoubleRepeatedReadSchemas {
+ public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor,
+ AbstractPrimitiveReaders<double[], Double> readers) {
+ JavaType javaType = propertyDescriptor.getJavaType();
+ if (double[].class.equals(javaType.getRawClass())) {
+ return new DoublePrimitiveArraySchema<>(protoField, propertyDescriptor, readers);
+ }
+
+ return RepeatedReadSchemas.create(protoField, propertyDescriptor, readers);
+ }
+
+ static class DoublePrimitiveArraySchema<T> extends FieldSchema<T> {
+ private final Getter<T, double[]> getter;
+
+ private final Setter<T, double[]> setter;
+
+ private final AbstractPrimitiveReaders<double[], Double> readers;
+
+ public DoublePrimitiveArraySchema(Field protoField, PropertyDescriptor propertyDescriptor,
+ AbstractPrimitiveReaders<double[], Double> readers) {
+ super(protoField, propertyDescriptor.getJavaType());
+ this.getter = propertyDescriptor.getGetter();
+ this.setter = propertyDescriptor.getSetter();
+ this.readers = readers;
+ }
+
+ @Override
+ public int mergeFrom(InputEx input, T message) throws IOException {
+ PrimitiveArrayBuilderWrapper<double[]> builderWrapper = new PrimitiveArrayBuilderWrapper<>(
+ input.getArrayBuilders().getDoubleBuilder());
+
+ int fieldNumber = readers.primitiveArrayReader.read(input, builderWrapper);
+ double[] newValue = builderWrapper.getArray();
+ newValue = mergeArray(getter.get(message), newValue);
+ setter.set(message, newValue);
+
+ return fieldNumber;
+ }
+
+ public double[] mergeArray(double[] oldValue, double[] newValue) {
+ if (oldValue == null || oldValue.length == 0) {
+ return newValue;
+ }
+
+ return concatArray(oldValue, newValue);
+ }
+
+ private double[] concatArray(double[] oldValue, double[] newValue) {
+ int len1 = oldValue.length;
+ int len2 = newValue.length;
+ double[] result = Arrays.copyOf(oldValue, len1 + len2);
+ System.arraycopy(newValue, 0, result, len1, len2);
+ return result;
+ }
+ }
+}
diff --git a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/doubles/impl/DoubleNotPackedReadSchemas.java b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/doubles/impl/DoubleNotPackedReadSchemas.java
new file mode 100644
index 0000000..3109e52
--- /dev/null
+++ b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/doubles/impl/DoubleNotPackedReadSchemas.java
@@ -0,0 +1,69 @@
+/*
+ * 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.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.doubles.impl;
+
+import org.apache.servicecomb.foundation.protobuf.internal.bean.PropertyDescriptor;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.AbstractPrimitiveReaders;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.doubles.DoubleRepeatedReadSchemas;
+
+import com.fasterxml.jackson.databind.util.PrimitiveArrayBuilder;
+
+import io.protostuff.compiler.model.Field;
+import io.protostuff.runtime.FieldSchema;
+
+public class DoubleNotPackedReadSchemas {
+ private static class DoubleNotPackedReaders extends AbstractPrimitiveReaders<double[], Double> {
+ public DoubleNotPackedReaders(Field protoField) {
+ super(protoField);
+
+ this.primitiveArrayReader = (input, builderWrapper) -> {
+ PrimitiveArrayBuilder<double[]> builder = builderWrapper.getBuilder();
+ double[] chunk = builder.resetAndStart();
+ int ix = 0;
+
+ while (true) {
+ if (ix >= chunk.length) {
+ chunk = builder.appendCompletedChunk(chunk, ix);
+ ix = 0;
+ }
+ chunk[ix++] = input.readDouble();
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ builderWrapper.setArray(builder.completeAndClearBuffer(chunk, ix));
+ return fieldNumber;
+ }
+ }
+ };
+
+ this.collectionReader = (input, collection) -> {
+ while (true) {
+ collection.add(input.readDouble());
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ return fieldNumber;
+ }
+ }
+ };
+ }
+ }
+
+ public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
+ return DoubleRepeatedReadSchemas.create(protoField, propertyDescriptor, new DoubleNotPackedReaders(protoField));
+ }
+}
diff --git a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/doubles/impl/DoublePackedReadSchemas.java b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/doubles/impl/DoublePackedReadSchemas.java
new file mode 100644
index 0000000..e2608f4
--- /dev/null
+++ b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/doubles/impl/DoublePackedReadSchemas.java
@@ -0,0 +1,69 @@
+/*
+ * 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.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.doubles.impl;
+
+import org.apache.servicecomb.foundation.protobuf.internal.bean.PropertyDescriptor;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.AbstractPrimitiveReaders;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.doubles.DoubleRepeatedReadSchemas;
+
+import com.fasterxml.jackson.databind.util.PrimitiveArrayBuilder;
+
+import io.protostuff.compiler.model.Field;
+import io.protostuff.runtime.FieldSchema;
+
+public class DoublePackedReadSchemas {
+ private static class DoublePackedReaders extends AbstractPrimitiveReaders<double[], Double> {
+ public DoublePackedReaders(Field protoField) {
+ super(protoField);
+
+ this.primitiveArrayReader = (input, builderWrapper) -> {
+ PrimitiveArrayBuilder<double[]> builder = builderWrapper.getBuilder();
+ double[] chunk = builder.resetAndStart();
+ int ix = 0;
+
+ while (true) {
+ if (ix >= chunk.length) {
+ chunk = builder.appendCompletedChunk(chunk, ix);
+ ix = 0;
+ }
+ chunk[ix++] = input.readPackedDouble();
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ builderWrapper.setArray(builder.completeAndClearBuffer(chunk, ix));
+ return fieldNumber;
+ }
+ }
+ };
+
+ this.collectionReader = (input, collection) -> {
+ while (true) {
+ collection.add(input.readPackedDouble());
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ return fieldNumber;
+ }
+ }
+ };
+ }
+ }
+
+ public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
+ return DoubleRepeatedReadSchemas.create(protoField, propertyDescriptor, new DoublePackedReaders(protoField));
+ }
+}
diff --git a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/enums/EnumNotPackedReadSchemas.java b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/enums/EnumNotPackedReadSchemas.java
new file mode 100644
index 0000000..a05f3ad
--- /dev/null
+++ b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/enums/EnumNotPackedReadSchemas.java
@@ -0,0 +1,109 @@
+/*
+ * 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.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.enums;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.apache.servicecomb.foundation.common.utils.bean.Getter;
+import org.apache.servicecomb.foundation.common.utils.bean.Setter;
+import org.apache.servicecomb.foundation.protobuf.internal.bean.PropertyDescriptor;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.EnumMeta;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.AbstractReaders;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.RepeatedReadSchemas;
+
+import com.fasterxml.jackson.databind.JavaType;
+
+import io.protostuff.InputEx;
+import io.protostuff.compiler.model.Field;
+import io.protostuff.compiler.model.Type;
+import io.protostuff.runtime.FieldSchema;
+
+public class EnumNotPackedReadSchemas {
+ private static class EnumNotPackedReaders extends AbstractReaders<Enum<?>> {
+ private final EnumMeta enumMeta;
+
+ public EnumNotPackedReaders(Field protoField, JavaType javaType) {
+ super(protoField, EnumSchemaUtils.constructEnumArrayClass(javaType));
+ this.enumMeta = new EnumMeta(protoField, javaType.getContentType());
+
+ collectionReader = (input, collection) -> {
+ while (true) {
+ int value = input.readEnum();
+ Enum<?> enumValue = enumMeta.getEnumByValue(value);
+ if (enumValue == null) {
+ throw new IllegalStateException(
+ String.format("invalid enum value %d for %s, proto field=%s:%s",
+ value,
+ javaType.getRawClass().getName(),
+ ((Type) protoField.getParent()).getCanonicalName(),
+ protoField.getName()));
+ }
+
+ collection.add(enumValue);
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ return fieldNumber;
+ }
+ }
+ };
+ }
+ }
+
+ private static class EnumIntNotPackedSchema<T> extends FieldSchema<T> {
+ private final Getter<T, Collection<Integer>> getter;
+
+ private final Setter<T, Collection<Integer>> setter;
+
+ public EnumIntNotPackedSchema(Field protoField, PropertyDescriptor propertyDescriptor) {
+ super(protoField, propertyDescriptor.getJavaType());
+ this.getter = propertyDescriptor.getGetter();
+ this.setter = propertyDescriptor.getSetter();
+ }
+
+ @Override
+ public int mergeFrom(InputEx input, T message) throws IOException {
+ Collection<Integer> collection = getter.get(message);
+ if (collection == null) {
+ collection = new ArrayList<>();
+ setter.set(message, collection);
+ }
+
+ while (true) {
+ int value = input.readEnum();
+ collection.add(value);
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ return fieldNumber;
+ }
+ }
+ }
+ }
+
+ public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
+ JavaType javaType = propertyDescriptor.getJavaType();
+ if (javaType.isJavaLangObject()) {
+ return new EnumIntNotPackedSchema<>(protoField, propertyDescriptor);
+ }
+
+ return RepeatedReadSchemas
+ .create(protoField, propertyDescriptor, new EnumNotPackedReaders(protoField, propertyDescriptor.getJavaType()));
+ }
+}
diff --git a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/enums/EnumPackedReadSchemas.java b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/enums/EnumPackedReadSchemas.java
new file mode 100644
index 0000000..8a98a18
--- /dev/null
+++ b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/enums/EnumPackedReadSchemas.java
@@ -0,0 +1,109 @@
+/*
+ * 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.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.enums;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.apache.servicecomb.foundation.common.utils.bean.Getter;
+import org.apache.servicecomb.foundation.common.utils.bean.Setter;
+import org.apache.servicecomb.foundation.protobuf.internal.bean.PropertyDescriptor;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.EnumMeta;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.AbstractReaders;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.RepeatedReadSchemas;
+
+import com.fasterxml.jackson.databind.JavaType;
+
+import io.protostuff.InputEx;
+import io.protostuff.compiler.model.Field;
+import io.protostuff.compiler.model.Type;
+import io.protostuff.runtime.FieldSchema;
+
+public class EnumPackedReadSchemas {
+ private static class EnumPackedReaders extends AbstractReaders<Enum<?>> {
+ private final EnumMeta enumMeta;
+
+ public EnumPackedReaders(Field protoField, JavaType javaType) {
+ super(protoField, EnumSchemaUtils.constructEnumArrayClass(javaType));
+ this.enumMeta = new EnumMeta(protoField, javaType.getContentType());
+
+ collectionReader = (input, collection) -> {
+ while (true) {
+ int value = input.readPackedEnum();
+ Enum<?> enumValue = enumMeta.getEnumByValue(value);
+ if (enumValue == null) {
+ throw new IllegalStateException(
+ String.format("invalid enum value %d for %s, proto field=%s:%s",
+ value,
+ javaType.getRawClass().getName(),
+ ((Type) protoField.getParent()).getCanonicalName(),
+ protoField.getName()));
+ }
+
+ collection.add(enumValue);
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ return fieldNumber;
+ }
+ }
+ };
+ }
+ }
+
+ private static class EnumIntPackedSchema<T> extends FieldSchema<T> {
+ private final Getter<T, Collection<Integer>> getter;
+
+ private final Setter<T, Collection<Integer>> setter;
+
+ public EnumIntPackedSchema(Field protoField, PropertyDescriptor propertyDescriptor) {
+ super(protoField, propertyDescriptor.getJavaType());
+ this.getter = propertyDescriptor.getGetter();
+ this.setter = propertyDescriptor.getSetter();
+ }
+
+ @Override
+ public int mergeFrom(InputEx input, T message) throws IOException {
+ Collection<Integer> collection = getter.get(message);
+ if (collection == null) {
+ collection = new ArrayList<>();
+ setter.set(message, collection);
+ }
+
+ while (true) {
+ int value = input.readPackedEnum();
+ collection.add(value);
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ return fieldNumber;
+ }
+ }
+ }
+ }
+
+ public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
+ JavaType javaType = propertyDescriptor.getJavaType();
+ if (javaType.isJavaLangObject()) {
+ return new EnumIntPackedSchema<>(protoField, propertyDescriptor);
+ }
+
+ return RepeatedReadSchemas
+ .create(protoField, propertyDescriptor, new EnumPackedReaders(protoField, propertyDescriptor.getJavaType()));
+ }
+}
diff --git a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/enums/EnumSchemaUtils.java b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/enums/EnumSchemaUtils.java
new file mode 100644
index 0000000..399a4b2
--- /dev/null
+++ b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/enums/EnumSchemaUtils.java
@@ -0,0 +1,34 @@
+/*
+ * 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.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.enums;
+
+import org.apache.servicecomb.foundation.common.utils.ReflectUtils;
+
+import com.fasterxml.jackson.databind.JavaType;
+
+public final class EnumSchemaUtils {
+ private EnumSchemaUtils() {
+ }
+
+ public static <T> T constructEnumArrayClass(JavaType javaType) {
+ if (javaType.isArrayType()) {
+ return ReflectUtils.constructArrayType(javaType.getContentType().getRawClass());
+ }
+
+ return ReflectUtils.constructArrayType(Object.class);
+ }
+}
diff --git a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/floats/FloatRepeatedReadSchemas.java b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/floats/FloatRepeatedReadSchemas.java
new file mode 100644
index 0000000..82b6d13
--- /dev/null
+++ b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/floats/FloatRepeatedReadSchemas.java
@@ -0,0 +1,90 @@
+/*
+ * 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.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.floats;
+
+import java.io.IOException;
+import java.util.Arrays;
+
+import org.apache.servicecomb.foundation.common.utils.bean.Getter;
+import org.apache.servicecomb.foundation.common.utils.bean.Setter;
+import org.apache.servicecomb.foundation.protobuf.internal.bean.PropertyDescriptor;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.AbstractPrimitiveReaders;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.PrimitiveArrayBuilderWrapper;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.RepeatedReadSchemas;
+
+import com.fasterxml.jackson.databind.JavaType;
+
+import io.protostuff.InputEx;
+import io.protostuff.compiler.model.Field;
+import io.protostuff.runtime.FieldSchema;
+
+public class FloatRepeatedReadSchemas {
+ public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor,
+ AbstractPrimitiveReaders<float[], Float> readers) {
+ JavaType javaType = propertyDescriptor.getJavaType();
+ if (float[].class.equals(javaType.getRawClass())) {
+ return new FloatPrimitiveArraySchema<>(protoField, propertyDescriptor, readers);
+ }
+
+ return RepeatedReadSchemas.create(protoField, propertyDescriptor, readers);
+ }
+
+ static class FloatPrimitiveArraySchema<T> extends FieldSchema<T> {
+ private final Getter<T, float[]> getter;
+
+ private final Setter<T, float[]> setter;
+
+ private final AbstractPrimitiveReaders<float[], Float> readers;
+
+ public FloatPrimitiveArraySchema(Field protoField, PropertyDescriptor propertyDescriptor,
+ AbstractPrimitiveReaders<float[], Float> readers) {
+ super(protoField, propertyDescriptor.getJavaType());
+ this.getter = propertyDescriptor.getGetter();
+ this.setter = propertyDescriptor.getSetter();
+ this.readers = readers;
+ }
+
+ @Override
+ public int mergeFrom(InputEx input, T message) throws IOException {
+ PrimitiveArrayBuilderWrapper<float[]> builderWrapper = new PrimitiveArrayBuilderWrapper<>(
+ input.getArrayBuilders().getFloatBuilder());
+
+ int fieldNumber = readers.primitiveArrayReader.read(input, builderWrapper);
+ float[] newValue = builderWrapper.getArray();
+ newValue = mergeArray(getter.get(message), newValue);
+ setter.set(message, newValue);
+
+ return fieldNumber;
+ }
+
+ public float[] mergeArray(float[] oldValue, float[] newValue) {
+ if (oldValue == null || oldValue.length == 0) {
+ return newValue;
+ }
+
+ return concatArray(oldValue, newValue);
+ }
+
+ private float[] concatArray(float[] oldValue, float[] newValue) {
+ int len1 = oldValue.length;
+ int len2 = newValue.length;
+ float[] result = Arrays.copyOf(oldValue, len1 + len2);
+ System.arraycopy(newValue, 0, result, len1, len2);
+ return result;
+ }
+ }
+}
diff --git a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/floats/impl/FloatNotPackedReadSchemas.java b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/floats/impl/FloatNotPackedReadSchemas.java
new file mode 100644
index 0000000..8f8c2e1
--- /dev/null
+++ b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/floats/impl/FloatNotPackedReadSchemas.java
@@ -0,0 +1,69 @@
+/*
+ * 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.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.floats.impl;
+
+import org.apache.servicecomb.foundation.protobuf.internal.bean.PropertyDescriptor;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.AbstractPrimitiveReaders;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.floats.FloatRepeatedReadSchemas;
+
+import com.fasterxml.jackson.databind.util.PrimitiveArrayBuilder;
+
+import io.protostuff.compiler.model.Field;
+import io.protostuff.runtime.FieldSchema;
+
+public class FloatNotPackedReadSchemas {
+ private static class FloatNotPackedReaders extends AbstractPrimitiveReaders<float[], Float> {
+ public FloatNotPackedReaders(Field protoField) {
+ super(protoField);
+
+ this.primitiveArrayReader = (input, builderWrapper) -> {
+ PrimitiveArrayBuilder<float[]> builder = builderWrapper.getBuilder();
+ float[] chunk = builder.resetAndStart();
+ int ix = 0;
+
+ while (true) {
+ if (ix >= chunk.length) {
+ chunk = builder.appendCompletedChunk(chunk, ix);
+ ix = 0;
+ }
+ chunk[ix++] = input.readFloat();
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ builderWrapper.setArray(builder.completeAndClearBuffer(chunk, ix));
+ return fieldNumber;
+ }
+ }
+ };
+
+ this.collectionReader = (input, collection) -> {
+ while (true) {
+ collection.add(input.readFloat());
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ return fieldNumber;
+ }
+ }
+ };
+ }
+ }
+
+ public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
+ return FloatRepeatedReadSchemas.create(protoField, propertyDescriptor, new FloatNotPackedReaders(protoField));
+ }
+}
diff --git a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/floats/impl/FloatPackedReadSchemas.java b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/floats/impl/FloatPackedReadSchemas.java
new file mode 100644
index 0000000..2e5a15a
--- /dev/null
+++ b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/floats/impl/FloatPackedReadSchemas.java
@@ -0,0 +1,69 @@
+/*
+ * 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.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.floats.impl;
+
+import org.apache.servicecomb.foundation.protobuf.internal.bean.PropertyDescriptor;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.AbstractPrimitiveReaders;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.floats.FloatRepeatedReadSchemas;
+
+import com.fasterxml.jackson.databind.util.PrimitiveArrayBuilder;
+
+import io.protostuff.compiler.model.Field;
+import io.protostuff.runtime.FieldSchema;
+
+public class FloatPackedReadSchemas {
+ private static class FloatPackedReaders extends AbstractPrimitiveReaders<float[], Float> {
+ public FloatPackedReaders(Field protoField) {
+ super(protoField);
+
+ this.primitiveArrayReader = (input, builderWrapper) -> {
+ PrimitiveArrayBuilder<float[]> builder = builderWrapper.getBuilder();
+ float[] chunk = builder.resetAndStart();
+ int ix = 0;
+
+ while (true) {
+ if (ix >= chunk.length) {
+ chunk = builder.appendCompletedChunk(chunk, ix);
+ ix = 0;
+ }
+ chunk[ix++] = input.readPackedFloat();
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ builderWrapper.setArray(builder.completeAndClearBuffer(chunk, ix));
+ return fieldNumber;
+ }
+ }
+ };
+
+ this.collectionReader = (input, collection) -> {
+ while (true) {
+ collection.add(input.readPackedFloat());
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ return fieldNumber;
+ }
+ }
+ };
+ }
+ }
+
+ public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
+ return FloatRepeatedReadSchemas.create(protoField, propertyDescriptor, new FloatPackedReaders(protoField));
+ }
+}
diff --git a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/ints/IntRepeatedReadSchemas.java b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/ints/IntRepeatedReadSchemas.java
new file mode 100644
index 0000000..cd0000d
--- /dev/null
+++ b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/ints/IntRepeatedReadSchemas.java
@@ -0,0 +1,90 @@
+/*
+ * 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.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.ints;
+
+import java.io.IOException;
+import java.util.Arrays;
+
+import org.apache.servicecomb.foundation.common.utils.bean.Getter;
+import org.apache.servicecomb.foundation.common.utils.bean.Setter;
+import org.apache.servicecomb.foundation.protobuf.internal.bean.PropertyDescriptor;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.AbstractPrimitiveReaders;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.PrimitiveArrayBuilderWrapper;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.RepeatedReadSchemas;
+
+import com.fasterxml.jackson.databind.JavaType;
+
+import io.protostuff.InputEx;
+import io.protostuff.compiler.model.Field;
+import io.protostuff.runtime.FieldSchema;
+
+public class IntRepeatedReadSchemas {
+ public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor,
+ AbstractPrimitiveReaders<int[], Integer> readers) {
+ JavaType javaType = propertyDescriptor.getJavaType();
+ if (int[].class.equals(javaType.getRawClass())) {
+ return new IntPrimitiveArraySchema<>(protoField, propertyDescriptor, readers);
+ }
+
+ return RepeatedReadSchemas.create(protoField, propertyDescriptor, readers);
+ }
+
+ static class IntPrimitiveArraySchema<T> extends FieldSchema<T> {
+ private final Getter<T, int[]> getter;
+
+ private final Setter<T, int[]> setter;
+
+ private final AbstractPrimitiveReaders<int[], Integer> readers;
+
+ public IntPrimitiveArraySchema(Field protoField, PropertyDescriptor propertyDescriptor,
+ AbstractPrimitiveReaders<int[], Integer> readers) {
+ super(protoField, propertyDescriptor.getJavaType());
+ this.getter = propertyDescriptor.getGetter();
+ this.setter = propertyDescriptor.getSetter();
+ this.readers = readers;
+ }
+
+ @Override
+ public int mergeFrom(InputEx input, T message) throws IOException {
+ PrimitiveArrayBuilderWrapper<int[]> builderWrapper = new PrimitiveArrayBuilderWrapper<>(
+ input.getArrayBuilders().getIntBuilder());
+
+ int fieldNumber = readers.primitiveArrayReader.read(input, builderWrapper);
+ int[] newValue = builderWrapper.getArray();
+ newValue = mergeArray(getter.get(message), newValue);
+ setter.set(message, newValue);
+
+ return fieldNumber;
+ }
+
+ public int[] mergeArray(int[] oldValue, int[] newValue) {
+ if (oldValue == null || oldValue.length == 0) {
+ return newValue;
+ }
+
+ return concatArray(oldValue, newValue);
+ }
+
+ private int[] concatArray(int[] oldValue, int[] newValue) {
+ int len1 = oldValue.length;
+ int len2 = newValue.length;
+ int[] result = Arrays.copyOf(oldValue, len1 + len2);
+ System.arraycopy(newValue, 0, result, len1, len2);
+ return result;
+ }
+ }
+}
diff --git a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/ints/impl/Fixed32NotPackedReadSchemas.java b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/ints/impl/Fixed32NotPackedReadSchemas.java
new file mode 100644
index 0000000..6169b47
--- /dev/null
+++ b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/ints/impl/Fixed32NotPackedReadSchemas.java
@@ -0,0 +1,69 @@
+/*
+ * 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.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.ints.impl;
+
+import org.apache.servicecomb.foundation.protobuf.internal.bean.PropertyDescriptor;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.AbstractPrimitiveReaders;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.ints.IntRepeatedReadSchemas;
+
+import com.fasterxml.jackson.databind.util.PrimitiveArrayBuilder;
+
+import io.protostuff.compiler.model.Field;
+import io.protostuff.runtime.FieldSchema;
+
+public class Fixed32NotPackedReadSchemas {
+ private static class Fixed32NotPackedReaders extends AbstractPrimitiveReaders<int[], Integer> {
+ public Fixed32NotPackedReaders(Field protoField) {
+ super(protoField);
+
+ this.primitiveArrayReader = (input, builderWrapper) -> {
+ PrimitiveArrayBuilder<int[]> builder = builderWrapper.getBuilder();
+ int[] chunk = builder.resetAndStart();
+ int ix = 0;
+
+ while (true) {
+ if (ix >= chunk.length) {
+ chunk = builder.appendCompletedChunk(chunk, ix);
+ ix = 0;
+ }
+ chunk[ix++] = input.readFixed32();
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ builderWrapper.setArray(builder.completeAndClearBuffer(chunk, ix));
+ return fieldNumber;
+ }
+ }
+ };
+
+ this.collectionReader = (input, collection) -> {
+ while (true) {
+ collection.add(input.readFixed32());
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ return fieldNumber;
+ }
+ }
+ };
+ }
+ }
+
+ public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
+ return IntRepeatedReadSchemas.create(protoField, propertyDescriptor, new Fixed32NotPackedReaders(protoField));
+ }
+}
diff --git a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/ints/impl/Fixed32PackedReadSchemas.java b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/ints/impl/Fixed32PackedReadSchemas.java
new file mode 100644
index 0000000..f8d25de
--- /dev/null
+++ b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/ints/impl/Fixed32PackedReadSchemas.java
@@ -0,0 +1,69 @@
+/*
+ * 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.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.ints.impl;
+
+import org.apache.servicecomb.foundation.protobuf.internal.bean.PropertyDescriptor;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.AbstractPrimitiveReaders;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.ints.IntRepeatedReadSchemas;
+
+import com.fasterxml.jackson.databind.util.PrimitiveArrayBuilder;
+
+import io.protostuff.compiler.model.Field;
+import io.protostuff.runtime.FieldSchema;
+
+public class Fixed32PackedReadSchemas {
+ private static class Fixed32PackedReaders extends AbstractPrimitiveReaders<int[], Integer> {
+ public Fixed32PackedReaders(Field protoField) {
+ super(protoField);
+
+ this.primitiveArrayReader = (input, builderWrapper) -> {
+ PrimitiveArrayBuilder<int[]> builder = builderWrapper.getBuilder();
+ int[] chunk = builder.resetAndStart();
+ int ix = 0;
+
+ while (true) {
+ if (ix >= chunk.length) {
+ chunk = builder.appendCompletedChunk(chunk, ix);
+ ix = 0;
+ }
+ chunk[ix++] = input.readPackedFixed32();
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ builderWrapper.setArray(builder.completeAndClearBuffer(chunk, ix));
+ return fieldNumber;
+ }
+ }
+ };
+
+ this.collectionReader = (input, collection) -> {
+ while (true) {
+ collection.add(input.readPackedFixed32());
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ return fieldNumber;
+ }
+ }
+ };
+ }
+ }
+
+ public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
+ return IntRepeatedReadSchemas.create(protoField, propertyDescriptor, new Fixed32PackedReaders(protoField));
+ }
+}
diff --git a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/ints/impl/Int32NotPackedReadSchemas.java b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/ints/impl/Int32NotPackedReadSchemas.java
new file mode 100644
index 0000000..e5e86f9
--- /dev/null
+++ b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/ints/impl/Int32NotPackedReadSchemas.java
@@ -0,0 +1,69 @@
+/*
+ * 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.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.ints.impl;
+
+import org.apache.servicecomb.foundation.protobuf.internal.bean.PropertyDescriptor;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.AbstractPrimitiveReaders;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.ints.IntRepeatedReadSchemas;
+
+import com.fasterxml.jackson.databind.util.PrimitiveArrayBuilder;
+
+import io.protostuff.compiler.model.Field;
+import io.protostuff.runtime.FieldSchema;
+
+public class Int32NotPackedReadSchemas {
+ private static class Int32NotPackedReaders extends AbstractPrimitiveReaders<int[], Integer> {
+ public Int32NotPackedReaders(Field protoField) {
+ super(protoField);
+
+ this.primitiveArrayReader = (input, builderWrapper) -> {
+ PrimitiveArrayBuilder<int[]> builder = builderWrapper.getBuilder();
+ int[] chunk = builder.resetAndStart();
+ int ix = 0;
+
+ while (true) {
+ if (ix >= chunk.length) {
+ chunk = builder.appendCompletedChunk(chunk, ix);
+ ix = 0;
+ }
+ chunk[ix++] = input.readInt32();
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ builderWrapper.setArray(builder.completeAndClearBuffer(chunk, ix));
+ return fieldNumber;
+ }
+ }
+ };
+
+ this.collectionReader = (input, collection) -> {
+ while (true) {
+ collection.add(input.readInt32());
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ return fieldNumber;
+ }
+ }
+ };
+ }
+ }
+
+ public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
+ return IntRepeatedReadSchemas.create(protoField, propertyDescriptor, new Int32NotPackedReaders(protoField));
+ }
+}
diff --git a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/ints/impl/Int32PackedReadSchemas.java b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/ints/impl/Int32PackedReadSchemas.java
new file mode 100644
index 0000000..b578aea
--- /dev/null
+++ b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/ints/impl/Int32PackedReadSchemas.java
@@ -0,0 +1,69 @@
+/*
+ * 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.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.ints.impl;
+
+import org.apache.servicecomb.foundation.protobuf.internal.bean.PropertyDescriptor;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.AbstractPrimitiveReaders;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.ints.IntRepeatedReadSchemas;
+
+import com.fasterxml.jackson.databind.util.PrimitiveArrayBuilder;
+
+import io.protostuff.compiler.model.Field;
+import io.protostuff.runtime.FieldSchema;
+
+public class Int32PackedReadSchemas {
+ private static class Int32PackedReaders extends AbstractPrimitiveReaders<int[], Integer> {
+ public Int32PackedReaders(Field protoField) {
+ super(protoField);
+
+ this.primitiveArrayReader = (input, builderWrapper) -> {
+ PrimitiveArrayBuilder<int[]> builder = builderWrapper.getBuilder();
+ int[] chunk = builder.resetAndStart();
+ int ix = 0;
+
+ while (true) {
+ if (ix >= chunk.length) {
+ chunk = builder.appendCompletedChunk(chunk, ix);
+ ix = 0;
+ }
+ chunk[ix++] = input.readPackedInt32();
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ builderWrapper.setArray(builder.completeAndClearBuffer(chunk, ix));
+ return fieldNumber;
+ }
+ }
+ };
+
+ this.collectionReader = (input, collection) -> {
+ while (true) {
+ collection.add(input.readPackedInt32());
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ return fieldNumber;
+ }
+ }
+ };
+ }
+ }
+
+ public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
+ return IntRepeatedReadSchemas.create(protoField, propertyDescriptor, new Int32PackedReaders(protoField));
+ }
+}
diff --git a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/ints/impl/SFixed32NotPackedReadSchemas.java b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/ints/impl/SFixed32NotPackedReadSchemas.java
new file mode 100644
index 0000000..e92d05f
--- /dev/null
+++ b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/ints/impl/SFixed32NotPackedReadSchemas.java
@@ -0,0 +1,69 @@
+/*
+ * 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.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.ints.impl;
+
+import org.apache.servicecomb.foundation.protobuf.internal.bean.PropertyDescriptor;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.AbstractPrimitiveReaders;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.ints.IntRepeatedReadSchemas;
+
+import com.fasterxml.jackson.databind.util.PrimitiveArrayBuilder;
+
+import io.protostuff.compiler.model.Field;
+import io.protostuff.runtime.FieldSchema;
+
+public class SFixed32NotPackedReadSchemas {
+ private static class SFixed32NotPackedReaders extends AbstractPrimitiveReaders<int[], Integer> {
+ public SFixed32NotPackedReaders(Field protoField) {
+ super(protoField);
+
+ this.primitiveArrayReader = (input, builderWrapper) -> {
+ PrimitiveArrayBuilder<int[]> builder = builderWrapper.getBuilder();
+ int[] chunk = builder.resetAndStart();
+ int ix = 0;
+
+ while (true) {
+ if (ix >= chunk.length) {
+ chunk = builder.appendCompletedChunk(chunk, ix);
+ ix = 0;
+ }
+ chunk[ix++] = input.readSFixed32();
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ builderWrapper.setArray(builder.completeAndClearBuffer(chunk, ix));
+ return fieldNumber;
+ }
+ }
+ };
+
+ this.collectionReader = (input, collection) -> {
+ while (true) {
+ collection.add(input.readSFixed32());
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ return fieldNumber;
+ }
+ }
+ };
+ }
+ }
+
+ public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
+ return IntRepeatedReadSchemas.create(protoField, propertyDescriptor, new SFixed32NotPackedReaders(protoField));
+ }
+}
diff --git a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/ints/impl/SFixed32PackedReadSchemas.java b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/ints/impl/SFixed32PackedReadSchemas.java
new file mode 100644
index 0000000..a4be7f8
--- /dev/null
+++ b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/ints/impl/SFixed32PackedReadSchemas.java
@@ -0,0 +1,69 @@
+/*
+ * 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.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.ints.impl;
+
+import org.apache.servicecomb.foundation.protobuf.internal.bean.PropertyDescriptor;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.AbstractPrimitiveReaders;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.ints.IntRepeatedReadSchemas;
+
+import com.fasterxml.jackson.databind.util.PrimitiveArrayBuilder;
+
+import io.protostuff.compiler.model.Field;
+import io.protostuff.runtime.FieldSchema;
+
+public class SFixed32PackedReadSchemas {
+ private static class SFixed32PackedReaders extends AbstractPrimitiveReaders<int[], Integer> {
+ public SFixed32PackedReaders(Field protoField) {
+ super(protoField);
+
+ this.primitiveArrayReader = (input, builderWrapper) -> {
+ PrimitiveArrayBuilder<int[]> builder = builderWrapper.getBuilder();
+ int[] chunk = builder.resetAndStart();
+ int ix = 0;
+
+ while (true) {
+ if (ix >= chunk.length) {
+ chunk = builder.appendCompletedChunk(chunk, ix);
+ ix = 0;
+ }
+ chunk[ix++] = input.readPackedSFixed32();
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ builderWrapper.setArray(builder.completeAndClearBuffer(chunk, ix));
+ return fieldNumber;
+ }
+ }
+ };
+
+ this.collectionReader = (input, collection) -> {
+ while (true) {
+ collection.add(input.readPackedSFixed32());
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ return fieldNumber;
+ }
+ }
+ };
+ }
+ }
+
+ public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
+ return IntRepeatedReadSchemas.create(protoField, propertyDescriptor, new SFixed32PackedReaders(protoField));
+ }
+}
diff --git a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/ints/impl/SInt32NotPackedReadSchemas.java b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/ints/impl/SInt32NotPackedReadSchemas.java
new file mode 100644
index 0000000..3918c12
--- /dev/null
+++ b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/ints/impl/SInt32NotPackedReadSchemas.java
@@ -0,0 +1,69 @@
+/*
+ * 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.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.ints.impl;
+
+import org.apache.servicecomb.foundation.protobuf.internal.bean.PropertyDescriptor;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.AbstractPrimitiveReaders;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.ints.IntRepeatedReadSchemas;
+
+import com.fasterxml.jackson.databind.util.PrimitiveArrayBuilder;
+
+import io.protostuff.compiler.model.Field;
+import io.protostuff.runtime.FieldSchema;
+
+public class SInt32NotPackedReadSchemas {
+ private static class SInt32NotPackedReaders extends AbstractPrimitiveReaders<int[], Integer> {
+ public SInt32NotPackedReaders(Field protoField) {
+ super(protoField);
+
+ this.primitiveArrayReader = (input, builderWrapper) -> {
+ PrimitiveArrayBuilder<int[]> builder = builderWrapper.getBuilder();
+ int[] chunk = builder.resetAndStart();
+ int ix = 0;
+
+ while (true) {
+ if (ix >= chunk.length) {
+ chunk = builder.appendCompletedChunk(chunk, ix);
+ ix = 0;
+ }
+ chunk[ix++] = input.readSInt32();
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ builderWrapper.setArray(builder.completeAndClearBuffer(chunk, ix));
+ return fieldNumber;
+ }
+ }
+ };
+
+ this.collectionReader = (input, collection) -> {
+ while (true) {
+ collection.add(input.readSInt32());
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ return fieldNumber;
+ }
+ }
+ };
+ }
+ }
+
+ public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
+ return IntRepeatedReadSchemas.create(protoField, propertyDescriptor, new SInt32NotPackedReaders(protoField));
+ }
+}
diff --git a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/ints/impl/SInt32PackedReadSchemas.java b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/ints/impl/SInt32PackedReadSchemas.java
new file mode 100644
index 0000000..ff7984e
--- /dev/null
+++ b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/ints/impl/SInt32PackedReadSchemas.java
@@ -0,0 +1,69 @@
+/*
+ * 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.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.ints.impl;
+
+import org.apache.servicecomb.foundation.protobuf.internal.bean.PropertyDescriptor;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.AbstractPrimitiveReaders;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.ints.IntRepeatedReadSchemas;
+
+import com.fasterxml.jackson.databind.util.PrimitiveArrayBuilder;
+
+import io.protostuff.compiler.model.Field;
+import io.protostuff.runtime.FieldSchema;
+
+public class SInt32PackedReadSchemas {
+ private static class SInt32PackedReaders extends AbstractPrimitiveReaders<int[], Integer> {
+ public SInt32PackedReaders(Field protoField) {
+ super(protoField);
+
+ this.primitiveArrayReader = (input, builderWrapper) -> {
+ PrimitiveArrayBuilder<int[]> builder = builderWrapper.getBuilder();
+ int[] chunk = builder.resetAndStart();
+ int ix = 0;
+
+ while (true) {
+ if (ix >= chunk.length) {
+ chunk = builder.appendCompletedChunk(chunk, ix);
+ ix = 0;
+ }
+ chunk[ix++] = input.readPackedSInt32();
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ builderWrapper.setArray(builder.completeAndClearBuffer(chunk, ix));
+ return fieldNumber;
+ }
+ }
+ };
+
+ this.collectionReader = (input, collection) -> {
+ while (true) {
+ collection.add(input.readPackedSInt32());
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ return fieldNumber;
+ }
+ }
+ };
+ }
+ }
+
+ public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
+ return IntRepeatedReadSchemas.create(protoField, propertyDescriptor, new SInt32PackedReaders(protoField));
+ }
+}
diff --git a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/ints/impl/UInt32NotPackedReadSchemas.java b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/ints/impl/UInt32NotPackedReadSchemas.java
new file mode 100644
index 0000000..dbd719c
--- /dev/null
+++ b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/ints/impl/UInt32NotPackedReadSchemas.java
@@ -0,0 +1,69 @@
+/*
+ * 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.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.ints.impl;
+
+import org.apache.servicecomb.foundation.protobuf.internal.bean.PropertyDescriptor;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.AbstractPrimitiveReaders;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.ints.IntRepeatedReadSchemas;
+
+import com.fasterxml.jackson.databind.util.PrimitiveArrayBuilder;
+
+import io.protostuff.compiler.model.Field;
+import io.protostuff.runtime.FieldSchema;
+
+public class UInt32NotPackedReadSchemas {
+ private static class UInt32NotPackedReaders extends AbstractPrimitiveReaders<int[], Integer> {
+ public UInt32NotPackedReaders(Field protoField) {
+ super(protoField);
+
+ this.primitiveArrayReader = (input, builderWrapper) -> {
+ PrimitiveArrayBuilder<int[]> builder = builderWrapper.getBuilder();
+ int[] chunk = builder.resetAndStart();
+ int ix = 0;
+
+ while (true) {
+ if (ix >= chunk.length) {
+ chunk = builder.appendCompletedChunk(chunk, ix);
+ ix = 0;
+ }
+ chunk[ix++] = input.readUInt32();
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ builderWrapper.setArray(builder.completeAndClearBuffer(chunk, ix));
+ return fieldNumber;
+ }
+ }
+ };
+
+ this.collectionReader = (input, collection) -> {
+ while (true) {
+ collection.add(input.readUInt32());
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ return fieldNumber;
+ }
+ }
+ };
+ }
+ }
+
+ public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
+ return IntRepeatedReadSchemas.create(protoField, propertyDescriptor, new UInt32NotPackedReaders(protoField));
+ }
+}
diff --git a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/ints/impl/UInt32PackedReadSchemas.java b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/ints/impl/UInt32PackedReadSchemas.java
new file mode 100644
index 0000000..3afff30
--- /dev/null
+++ b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/ints/impl/UInt32PackedReadSchemas.java
@@ -0,0 +1,69 @@
+/*
+ * 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.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.ints.impl;
+
+import org.apache.servicecomb.foundation.protobuf.internal.bean.PropertyDescriptor;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.AbstractPrimitiveReaders;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.ints.IntRepeatedReadSchemas;
+
+import com.fasterxml.jackson.databind.util.PrimitiveArrayBuilder;
+
+import io.protostuff.compiler.model.Field;
+import io.protostuff.runtime.FieldSchema;
+
+public class UInt32PackedReadSchemas {
+ private static class UInt32PackedReaders extends AbstractPrimitiveReaders<int[], Integer> {
+ public UInt32PackedReaders(Field protoField) {
+ super(protoField);
+
+ this.primitiveArrayReader = (input, builderWrapper) -> {
+ PrimitiveArrayBuilder<int[]> builder = builderWrapper.getBuilder();
+ int[] chunk = builder.resetAndStart();
+ int ix = 0;
+
+ while (true) {
+ if (ix >= chunk.length) {
+ chunk = builder.appendCompletedChunk(chunk, ix);
+ ix = 0;
+ }
+ chunk[ix++] = input.readPackedUInt32();
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ builderWrapper.setArray(builder.completeAndClearBuffer(chunk, ix));
+ return fieldNumber;
+ }
+ }
+ };
+
+ this.collectionReader = (input, collection) -> {
+ while (true) {
+ collection.add(input.readPackedUInt32());
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ return fieldNumber;
+ }
+ }
+ };
+ }
+ }
+
+ public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
+ return IntRepeatedReadSchemas.create(protoField, propertyDescriptor, new UInt32PackedReaders(protoField));
+ }
+}
diff --git a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/longs/LongRepeatedReadSchemas.java b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/longs/LongRepeatedReadSchemas.java
new file mode 100644
index 0000000..0830830
--- /dev/null
+++ b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/longs/LongRepeatedReadSchemas.java
@@ -0,0 +1,90 @@
+/*
+ * 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.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.longs;
+
+import java.io.IOException;
+import java.util.Arrays;
+
+import org.apache.servicecomb.foundation.common.utils.bean.Getter;
+import org.apache.servicecomb.foundation.common.utils.bean.Setter;
+import org.apache.servicecomb.foundation.protobuf.internal.bean.PropertyDescriptor;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.AbstractPrimitiveReaders;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.PrimitiveArrayBuilderWrapper;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.RepeatedReadSchemas;
+
+import com.fasterxml.jackson.databind.JavaType;
+
+import io.protostuff.InputEx;
+import io.protostuff.compiler.model.Field;
+import io.protostuff.runtime.FieldSchema;
+
+public class LongRepeatedReadSchemas {
+ public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor,
+ AbstractPrimitiveReaders<long[], Long> readers) {
+ JavaType javaType = propertyDescriptor.getJavaType();
+ if (long[].class.equals(javaType.getRawClass())) {
+ return new LongPrimitiveArraySchema<>(protoField, propertyDescriptor, readers);
+ }
+
+ return RepeatedReadSchemas.create(protoField, propertyDescriptor, readers);
+ }
+
+ static class LongPrimitiveArraySchema<T> extends FieldSchema<T> {
+ private final Getter<T, long[]> getter;
+
+ private final Setter<T, long[]> setter;
+
+ private final AbstractPrimitiveReaders<long[], Long> readers;
+
+ public LongPrimitiveArraySchema(Field protoField, PropertyDescriptor propertyDescriptor,
+ AbstractPrimitiveReaders<long[], Long> readers) {
+ super(protoField, propertyDescriptor.getJavaType());
+ this.getter = propertyDescriptor.getGetter();
+ this.setter = propertyDescriptor.getSetter();
+ this.readers = readers;
+ }
+
+ @Override
+ public int mergeFrom(InputEx input, T message) throws IOException {
+ PrimitiveArrayBuilderWrapper<long[]> builderWrapper = new PrimitiveArrayBuilderWrapper<>(
+ input.getArrayBuilders().getLongBuilder());
+
+ int fieldNumber = readers.primitiveArrayReader.read(input, builderWrapper);
+ long[] newValue = builderWrapper.getArray();
+ newValue = mergeArray(getter.get(message), newValue);
+ setter.set(message, newValue);
+
+ return fieldNumber;
+ }
+
+ public long[] mergeArray(long[] oldValue, long[] newValue) {
+ if (oldValue == null || oldValue.length == 0) {
+ return newValue;
+ }
+
+ return concatArray(oldValue, newValue);
+ }
+
+ private long[] concatArray(long[] oldValue, long[] newValue) {
+ int len1 = oldValue.length;
+ int len2 = newValue.length;
+ long[] result = Arrays.copyOf(oldValue, len1 + len2);
+ System.arraycopy(newValue, 0, result, len1, len2);
+ return result;
+ }
+ }
+}
diff --git a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/longs/impl/Fixed64NotPackedReadSchemas.java b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/longs/impl/Fixed64NotPackedReadSchemas.java
new file mode 100644
index 0000000..7ad1b5a
--- /dev/null
+++ b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/longs/impl/Fixed64NotPackedReadSchemas.java
@@ -0,0 +1,69 @@
+/*
+ * 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.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.longs.impl;
+
+import org.apache.servicecomb.foundation.protobuf.internal.bean.PropertyDescriptor;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.AbstractPrimitiveReaders;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.longs.LongRepeatedReadSchemas;
+
+import com.fasterxml.jackson.databind.util.PrimitiveArrayBuilder;
+
+import io.protostuff.compiler.model.Field;
+import io.protostuff.runtime.FieldSchema;
+
+public class Fixed64NotPackedReadSchemas {
+ private static class Fixed64NotPackedReaders extends AbstractPrimitiveReaders<long[], Long> {
+ public Fixed64NotPackedReaders(Field protoField) {
+ super(protoField);
+
+ this.primitiveArrayReader = (input, builderWrapper) -> {
+ PrimitiveArrayBuilder<long[]> builder = builderWrapper.getBuilder();
+ long[] chunk = builder.resetAndStart();
+ int ix = 0;
+
+ while (true) {
+ if (ix >= chunk.length) {
+ chunk = builder.appendCompletedChunk(chunk, ix);
+ ix = 0;
+ }
+ chunk[ix++] = input.readFixed64();
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ builderWrapper.setArray(builder.completeAndClearBuffer(chunk, ix));
+ return fieldNumber;
+ }
+ }
+ };
+
+ this.collectionReader = (input, collection) -> {
+ while (true) {
+ collection.add(input.readFixed64());
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ return fieldNumber;
+ }
+ }
+ };
+ }
+ }
+
+ public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
+ return LongRepeatedReadSchemas.create(protoField, propertyDescriptor, new Fixed64NotPackedReaders(protoField));
+ }
+}
diff --git a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/longs/impl/Fixed64PackedReadSchemas.java b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/longs/impl/Fixed64PackedReadSchemas.java
new file mode 100644
index 0000000..28a4f36
--- /dev/null
+++ b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/longs/impl/Fixed64PackedReadSchemas.java
@@ -0,0 +1,69 @@
+/*
+ * 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.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.longs.impl;
+
+import org.apache.servicecomb.foundation.protobuf.internal.bean.PropertyDescriptor;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.AbstractPrimitiveReaders;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.longs.LongRepeatedReadSchemas;
+
+import com.fasterxml.jackson.databind.util.PrimitiveArrayBuilder;
+
+import io.protostuff.compiler.model.Field;
+import io.protostuff.runtime.FieldSchema;
+
+public class Fixed64PackedReadSchemas {
+ private static class Fixed64PackedReaders extends AbstractPrimitiveReaders<long[], Long> {
+ public Fixed64PackedReaders(Field protoField) {
+ super(protoField);
+
+ this.primitiveArrayReader = (input, builderWrapper) -> {
+ PrimitiveArrayBuilder<long[]> builder = builderWrapper.getBuilder();
+ long[] chunk = builder.resetAndStart();
+ int ix = 0;
+
+ while (true) {
+ if (ix >= chunk.length) {
+ chunk = builder.appendCompletedChunk(chunk, ix);
+ ix = 0;
+ }
+ chunk[ix++] = input.readPackedFixed64();
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ builderWrapper.setArray(builder.completeAndClearBuffer(chunk, ix));
+ return fieldNumber;
+ }
+ }
+ };
+
+ this.collectionReader = (input, collection) -> {
+ while (true) {
+ collection.add(input.readPackedFixed64());
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ return fieldNumber;
+ }
+ }
+ };
+ }
+ }
+
+ public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
+ return LongRepeatedReadSchemas.create(protoField, propertyDescriptor, new Fixed64PackedReaders(protoField));
+ }
+}
diff --git a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/longs/impl/Int64NotPackedReadSchemas.java b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/longs/impl/Int64NotPackedReadSchemas.java
new file mode 100644
index 0000000..83b158a
--- /dev/null
+++ b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/longs/impl/Int64NotPackedReadSchemas.java
@@ -0,0 +1,69 @@
+/*
+ * 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.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.longs.impl;
+
+import org.apache.servicecomb.foundation.protobuf.internal.bean.PropertyDescriptor;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.AbstractPrimitiveReaders;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.longs.LongRepeatedReadSchemas;
+
+import com.fasterxml.jackson.databind.util.PrimitiveArrayBuilder;
+
+import io.protostuff.compiler.model.Field;
+import io.protostuff.runtime.FieldSchema;
+
+public class Int64NotPackedReadSchemas {
+ private static class Int64NotPackedReaders extends AbstractPrimitiveReaders<long[], Long> {
+ public Int64NotPackedReaders(Field protoField) {
+ super(protoField);
+
+ this.primitiveArrayReader = (input, builderWrapper) -> {
+ PrimitiveArrayBuilder<long[]> builder = builderWrapper.getBuilder();
+ long[] chunk = builder.resetAndStart();
+ int ix = 0;
+
+ while (true) {
+ if (ix >= chunk.length) {
+ chunk = builder.appendCompletedChunk(chunk, ix);
+ ix = 0;
+ }
+ chunk[ix++] = input.readInt64();
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ builderWrapper.setArray(builder.completeAndClearBuffer(chunk, ix));
+ return fieldNumber;
+ }
+ }
+ };
+
+ this.collectionReader = (input, collection) -> {
+ while (true) {
+ collection.add(input.readInt64());
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ return fieldNumber;
+ }
+ }
+ };
+ }
+ }
+
+ public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
+ return LongRepeatedReadSchemas.create(protoField, propertyDescriptor, new Int64NotPackedReaders(protoField));
+ }
+}
diff --git a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/longs/impl/Int64PackedReadSchemas.java b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/longs/impl/Int64PackedReadSchemas.java
new file mode 100644
index 0000000..5a4efbc
--- /dev/null
+++ b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/longs/impl/Int64PackedReadSchemas.java
@@ -0,0 +1,69 @@
+/*
+ * 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.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.longs.impl;
+
+import org.apache.servicecomb.foundation.protobuf.internal.bean.PropertyDescriptor;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.AbstractPrimitiveReaders;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.longs.LongRepeatedReadSchemas;
+
+import com.fasterxml.jackson.databind.util.PrimitiveArrayBuilder;
+
+import io.protostuff.compiler.model.Field;
+import io.protostuff.runtime.FieldSchema;
+
+public class Int64PackedReadSchemas {
+ private static class Int64PackedReaders extends AbstractPrimitiveReaders<long[], Long> {
+ public Int64PackedReaders(Field protoField) {
+ super(protoField);
+
+ this.primitiveArrayReader = (input, builderWrapper) -> {
+ PrimitiveArrayBuilder<long[]> builder = builderWrapper.getBuilder();
+ long[] chunk = builder.resetAndStart();
+ int ix = 0;
+
+ while (true) {
+ if (ix >= chunk.length) {
+ chunk = builder.appendCompletedChunk(chunk, ix);
+ ix = 0;
+ }
+ chunk[ix++] = input.readPackedInt64();
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ builderWrapper.setArray(builder.completeAndClearBuffer(chunk, ix));
+ return fieldNumber;
+ }
+ }
+ };
+
+ this.collectionReader = (input, collection) -> {
+ while (true) {
+ collection.add(input.readPackedInt64());
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ return fieldNumber;
+ }
+ }
+ };
+ }
+ }
+
+ public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
+ return LongRepeatedReadSchemas.create(protoField, propertyDescriptor, new Int64PackedReaders(protoField));
+ }
+}
diff --git a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/longs/impl/SFixed64NotPackedReadSchemas.java b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/longs/impl/SFixed64NotPackedReadSchemas.java
new file mode 100644
index 0000000..93aa095
--- /dev/null
+++ b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/longs/impl/SFixed64NotPackedReadSchemas.java
@@ -0,0 +1,69 @@
+/*
+ * 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.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.longs.impl;
+
+import org.apache.servicecomb.foundation.protobuf.internal.bean.PropertyDescriptor;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.AbstractPrimitiveReaders;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.longs.LongRepeatedReadSchemas;
+
+import com.fasterxml.jackson.databind.util.PrimitiveArrayBuilder;
+
+import io.protostuff.compiler.model.Field;
+import io.protostuff.runtime.FieldSchema;
+
+public class SFixed64NotPackedReadSchemas {
+ private static class SFixed64NotPackedReaders extends AbstractPrimitiveReaders<long[], Long> {
+ public SFixed64NotPackedReaders(Field protoField) {
+ super(protoField);
+
+ this.primitiveArrayReader = (input, builderWrapper) -> {
+ PrimitiveArrayBuilder<long[]> builder = builderWrapper.getBuilder();
+ long[] chunk = builder.resetAndStart();
+ int ix = 0;
+
+ while (true) {
+ if (ix >= chunk.length) {
+ chunk = builder.appendCompletedChunk(chunk, ix);
+ ix = 0;
+ }
+ chunk[ix++] = input.readSFixed64();
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ builderWrapper.setArray(builder.completeAndClearBuffer(chunk, ix));
+ return fieldNumber;
+ }
+ }
+ };
+
+ this.collectionReader = (input, collection) -> {
+ while (true) {
+ collection.add(input.readSFixed64());
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ return fieldNumber;
+ }
+ }
+ };
+ }
+ }
+
+ public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
+ return LongRepeatedReadSchemas.create(protoField, propertyDescriptor, new SFixed64NotPackedReaders(protoField));
+ }
+}
diff --git a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/longs/impl/SFixed64PackedReadSchemas.java b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/longs/impl/SFixed64PackedReadSchemas.java
new file mode 100644
index 0000000..a04a7d5
--- /dev/null
+++ b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/longs/impl/SFixed64PackedReadSchemas.java
@@ -0,0 +1,69 @@
+/*
+ * 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.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.longs.impl;
+
+import org.apache.servicecomb.foundation.protobuf.internal.bean.PropertyDescriptor;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.AbstractPrimitiveReaders;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.longs.LongRepeatedReadSchemas;
+
+import com.fasterxml.jackson.databind.util.PrimitiveArrayBuilder;
+
+import io.protostuff.compiler.model.Field;
+import io.protostuff.runtime.FieldSchema;
+
+public class SFixed64PackedReadSchemas {
+ private static class SFixed64PackedReaders extends AbstractPrimitiveReaders<long[], Long> {
+ public SFixed64PackedReaders(Field protoField) {
+ super(protoField);
+
+ this.primitiveArrayReader = (input, builderWrapper) -> {
+ PrimitiveArrayBuilder<long[]> builder = builderWrapper.getBuilder();
+ long[] chunk = builder.resetAndStart();
+ int ix = 0;
+
+ while (true) {
+ if (ix >= chunk.length) {
+ chunk = builder.appendCompletedChunk(chunk, ix);
+ ix = 0;
+ }
+ chunk[ix++] = input.readPackedSFixed64();
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ builderWrapper.setArray(builder.completeAndClearBuffer(chunk, ix));
+ return fieldNumber;
+ }
+ }
+ };
+
+ this.collectionReader = (input, collection) -> {
+ while (true) {
+ collection.add(input.readPackedSFixed64());
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ return fieldNumber;
+ }
+ }
+ };
+ }
+ }
+
+ public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
+ return LongRepeatedReadSchemas.create(protoField, propertyDescriptor, new SFixed64PackedReaders(protoField));
+ }
+}
diff --git a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/longs/impl/SInt64NotPackedReadSchemas.java b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/longs/impl/SInt64NotPackedReadSchemas.java
new file mode 100644
index 0000000..e3bd0c3
--- /dev/null
+++ b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/longs/impl/SInt64NotPackedReadSchemas.java
@@ -0,0 +1,69 @@
+/*
+ * 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.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.longs.impl;
+
+import org.apache.servicecomb.foundation.protobuf.internal.bean.PropertyDescriptor;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.AbstractPrimitiveReaders;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.longs.LongRepeatedReadSchemas;
+
+import com.fasterxml.jackson.databind.util.PrimitiveArrayBuilder;
+
+import io.protostuff.compiler.model.Field;
+import io.protostuff.runtime.FieldSchema;
+
+public class SInt64NotPackedReadSchemas {
+ private static class SInt64NotPackedReaders extends AbstractPrimitiveReaders<long[], Long> {
+ public SInt64NotPackedReaders(Field protoField) {
+ super(protoField);
+
+ this.primitiveArrayReader = (input, builderWrapper) -> {
+ PrimitiveArrayBuilder<long[]> builder = builderWrapper.getBuilder();
+ long[] chunk = builder.resetAndStart();
+ int ix = 0;
+
+ while (true) {
+ if (ix >= chunk.length) {
+ chunk = builder.appendCompletedChunk(chunk, ix);
+ ix = 0;
+ }
+ chunk[ix++] = input.readSInt64();
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ builderWrapper.setArray(builder.completeAndClearBuffer(chunk, ix));
+ return fieldNumber;
+ }
+ }
+ };
+
+ this.collectionReader = (input, collection) -> {
+ while (true) {
+ collection.add(input.readSInt64());
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ return fieldNumber;
+ }
+ }
+ };
+ }
+ }
+
+ public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
+ return LongRepeatedReadSchemas.create(protoField, propertyDescriptor, new SInt64NotPackedReaders(protoField));
+ }
+}
diff --git a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/longs/impl/SInt64PackedReadSchemas.java b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/longs/impl/SInt64PackedReadSchemas.java
new file mode 100644
index 0000000..5a253c0
--- /dev/null
+++ b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/longs/impl/SInt64PackedReadSchemas.java
@@ -0,0 +1,69 @@
+/*
+ * 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.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.longs.impl;
+
+import org.apache.servicecomb.foundation.protobuf.internal.bean.PropertyDescriptor;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.AbstractPrimitiveReaders;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.longs.LongRepeatedReadSchemas;
+
+import com.fasterxml.jackson.databind.util.PrimitiveArrayBuilder;
+
+import io.protostuff.compiler.model.Field;
+import io.protostuff.runtime.FieldSchema;
+
+public class SInt64PackedReadSchemas {
+ private static class SInt64PackedReaders extends AbstractPrimitiveReaders<long[], Long> {
+ public SInt64PackedReaders(Field protoField) {
+ super(protoField);
+
+ this.primitiveArrayReader = (input, builderWrapper) -> {
+ PrimitiveArrayBuilder<long[]> builder = builderWrapper.getBuilder();
+ long[] chunk = builder.resetAndStart();
+ int ix = 0;
+
+ while (true) {
+ if (ix >= chunk.length) {
+ chunk = builder.appendCompletedChunk(chunk, ix);
+ ix = 0;
+ }
+ chunk[ix++] = input.readPackedSInt64();
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ builderWrapper.setArray(builder.completeAndClearBuffer(chunk, ix));
+ return fieldNumber;
+ }
+ }
+ };
+
+ this.collectionReader = (input, collection) -> {
+ while (true) {
+ collection.add(input.readPackedSInt64());
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ return fieldNumber;
+ }
+ }
+ };
+ }
+ }
+
+ public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
+ return LongRepeatedReadSchemas.create(protoField, propertyDescriptor, new SInt64PackedReaders(protoField));
+ }
+}
diff --git a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/longs/impl/UInt64NotPackedReadSchemas.java b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/longs/impl/UInt64NotPackedReadSchemas.java
new file mode 100644
index 0000000..4421d13
--- /dev/null
+++ b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/longs/impl/UInt64NotPackedReadSchemas.java
@@ -0,0 +1,69 @@
+/*
+ * 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.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.longs.impl;
+
+import org.apache.servicecomb.foundation.protobuf.internal.bean.PropertyDescriptor;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.AbstractPrimitiveReaders;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.longs.LongRepeatedReadSchemas;
+
+import com.fasterxml.jackson.databind.util.PrimitiveArrayBuilder;
+
+import io.protostuff.compiler.model.Field;
+import io.protostuff.runtime.FieldSchema;
+
+public class UInt64NotPackedReadSchemas {
+ private static class UInt64NotPackedReaders extends AbstractPrimitiveReaders<long[], Long> {
+ public UInt64NotPackedReaders(Field protoField) {
+ super(protoField);
+
+ this.primitiveArrayReader = (input, builderWrapper) -> {
+ PrimitiveArrayBuilder<long[]> builder = builderWrapper.getBuilder();
+ long[] chunk = builder.resetAndStart();
+ int ix = 0;
+
+ while (true) {
+ if (ix >= chunk.length) {
+ chunk = builder.appendCompletedChunk(chunk, ix);
+ ix = 0;
+ }
+ chunk[ix++] = input.readUInt64();
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ builderWrapper.setArray(builder.completeAndClearBuffer(chunk, ix));
+ return fieldNumber;
+ }
+ }
+ };
+
+ this.collectionReader = (input, collection) -> {
+ while (true) {
+ collection.add(input.readUInt64());
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ return fieldNumber;
+ }
+ }
+ };
+ }
+ }
+
+ public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
+ return LongRepeatedReadSchemas.create(protoField, propertyDescriptor, new UInt64NotPackedReaders(protoField));
+ }
+}
diff --git a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/longs/impl/UInt64PackedReadSchemas.java b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/longs/impl/UInt64PackedReadSchemas.java
new file mode 100644
index 0000000..055c6cf
--- /dev/null
+++ b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/schema/deserializer/repeated/impl/longs/impl/UInt64PackedReadSchemas.java
@@ -0,0 +1,69 @@
+/*
+ * 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.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.longs.impl;
+
+import org.apache.servicecomb.foundation.protobuf.internal.bean.PropertyDescriptor;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.AbstractPrimitiveReaders;
+import org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.repeated.impl.longs.LongRepeatedReadSchemas;
+
+import com.fasterxml.jackson.databind.util.PrimitiveArrayBuilder;
+
+import io.protostuff.compiler.model.Field;
+import io.protostuff.runtime.FieldSchema;
+
+public class UInt64PackedReadSchemas {
+ private static class UInt64PackedReaders extends AbstractPrimitiveReaders<long[], Long> {
+ public UInt64PackedReaders(Field protoField) {
+ super(protoField);
+
+ this.primitiveArrayReader = (input, builderWrapper) -> {
+ PrimitiveArrayBuilder<long[]> builder = builderWrapper.getBuilder();
+ long[] chunk = builder.resetAndStart();
+ int ix = 0;
+
+ while (true) {
+ if (ix >= chunk.length) {
+ chunk = builder.appendCompletedChunk(chunk, ix);
+ ix = 0;
+ }
+ chunk[ix++] = input.readPackedUInt64();
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ builderWrapper.setArray(builder.completeAndClearBuffer(chunk, ix));
+ return fieldNumber;
+ }
+ }
+ };
+
+ this.collectionReader = (input, collection) -> {
+ while (true) {
+ collection.add(input.readPackedUInt64());
+
+ int fieldNumber = input.readFieldNumber();
+ if (fieldNumber != this.fieldNumber) {
+ return fieldNumber;
+ }
+ }
+ };
+ }
+ }
+
+ public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
+ return LongRepeatedReadSchemas.create(protoField, propertyDescriptor, new UInt64PackedReaders(protoField));
+ }
+}