-
Notifications
You must be signed in to change notification settings - Fork 26.5k
Merge dubbo-serialization-avro into incubator-dubbo #3708 #3717
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 12 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
49a931c
Merge dubbo-serialization-avro into incubator-dubbo #3708
CrazyHZM 6c596cb
modify
CrazyHZM 9b30c06
modify
CrazyHZM 8676a2e
add license
CrazyHZM fc6d6a7
modify xsd
CrazyHZM 5f33202
licnese
CrazyHZM 8f48465
modify
CrazyHZM a84b7df
add license
CrazyHZM 77dac63
delete useless config
CrazyHZM a92460a
delete <?xml version="1.0" encoding="UTF-8"?>
CrazyHZM 30b3ab5
modify
CrazyHZM 86190f2
modify
CrazyHZM c94e980
Merge branch 'master' into mergeAvro
CrazyHZM d31660b
update version
CrazyHZM 8aec7fd
add static
CrazyHZM 5661f8d
Merge branch 'master' into mergeAvro
CrazyHZM 371fc6c
delete dependency
CrazyHZM File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| <!-- | ||
| 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. | ||
| --> | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
| <parent> | ||
| <groupId>org.apache.dubbo</groupId> | ||
| <artifactId>dubbo-serialization</artifactId> | ||
| <version>2.7.1-SNAPSHOT</version> | ||
|
ralf0131 marked this conversation as resolved.
Outdated
|
||
| </parent> | ||
| <artifactId>dubbo-serialization-avro</artifactId> | ||
| <packaging>jar</packaging> | ||
| <name>${project.artifactId}</name> | ||
| <description>The avro serialization module of dubbo project</description> | ||
| <properties> | ||
| <skip_maven_deploy>false</skip_maven_deploy> | ||
| </properties> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>org.apache.dubbo</groupId> | ||
| <artifactId>dubbo-serialization-api</artifactId> | ||
| <version>${project.parent.version}</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.apache.avro</groupId> | ||
| <artifactId>avro</artifactId> | ||
| </dependency> | ||
| </dependencies> | ||
| </project> | ||
116 changes: 116 additions & 0 deletions
116
...ialization-avro/src/main/java/org/apache/dubbo/common/serialize/avro/AvroObjectInput.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| /* | ||
| * 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.dubbo.common.serialize.avro; | ||
|
|
||
| import org.apache.avro.io.BinaryDecoder; | ||
| import org.apache.avro.io.DecoderFactory; | ||
| import org.apache.avro.reflect.ReflectDatumReader; | ||
| import org.apache.avro.util.Utf8; | ||
| import org.apache.dubbo.common.serialize.ObjectInput; | ||
|
|
||
| import java.io.IOException; | ||
| import java.io.InputStream; | ||
| import java.lang.reflect.Type; | ||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
|
|
||
| public class AvroObjectInput implements ObjectInput{ | ||
| private DecoderFactory decoderFactory=DecoderFactory.get();; | ||
|
ralf0131 marked this conversation as resolved.
Outdated
|
||
| private BinaryDecoder decoder; | ||
|
|
||
| public AvroObjectInput(InputStream in){ | ||
| decoder=decoderFactory.binaryDecoder(in, null); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean readBool() throws IOException { | ||
| return decoder.readBoolean(); | ||
| } | ||
|
|
||
| @Override | ||
| public byte readByte() throws IOException { | ||
| byte[] bytes=new byte[1]; | ||
| decoder.readFixed(bytes); | ||
| return bytes[0]; | ||
| } | ||
|
|
||
| @Override | ||
| public short readShort() throws IOException { | ||
| return (short) decoder.readInt(); | ||
| } | ||
|
|
||
| @Override | ||
| public int readInt() throws IOException { | ||
| return decoder.readInt(); | ||
| } | ||
|
|
||
| @Override | ||
| public long readLong() throws IOException { | ||
| return decoder.readLong(); | ||
| } | ||
|
|
||
| @Override | ||
| public float readFloat() throws IOException { | ||
| return decoder.readFloat(); | ||
| } | ||
|
|
||
| @Override | ||
| public double readDouble() throws IOException { | ||
| return decoder.readDouble(); | ||
| } | ||
|
|
||
| @Override | ||
| public String readUTF() throws IOException { | ||
| Utf8 result= new Utf8(); | ||
| result=decoder.readString(result); | ||
| return result.toString(); | ||
| } | ||
|
|
||
| @Override | ||
| public byte[] readBytes() throws IOException { | ||
| String resultStr = decoder.readString(); | ||
| return resultStr.getBytes("utf8"); | ||
| } | ||
|
|
||
| /** | ||
| * will lost all attribute | ||
| */ | ||
| @Override | ||
| public Object readObject() throws IOException, ClassNotFoundException { | ||
| ReflectDatumReader<Object> reader = new ReflectDatumReader<>(Object.class); | ||
| return reader.read(null, decoder); | ||
| } | ||
|
|
||
| @Override | ||
| @SuppressWarnings(value={"unchecked"}) | ||
| public <T> T readObject(Class<T> cls) throws IOException, ClassNotFoundException { | ||
| //Map interface class change to HashMap implement | ||
| if(cls==Map.class){ | ||
| cls=(Class<T>) HashMap.class; | ||
| } | ||
|
|
||
| ReflectDatumReader<T> reader = new ReflectDatumReader<>(cls); | ||
| return reader.read(null, decoder); | ||
| } | ||
|
|
||
| @Override | ||
| public <T> T readObject(Class<T> cls, Type type) throws IOException, ClassNotFoundException { | ||
| ReflectDatumReader<T> reader = new ReflectDatumReader<>(cls); | ||
| return reader.read(null, decoder); | ||
| } | ||
|
|
||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.