Skip to content
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

Implement Issue #389 : Support for MessagePack #460

Closed
wants to merge 2 commits into from

Conversation

lxhoan
Copy link
Contributor

@lxhoan lxhoan commented Jun 13, 2018

thi PR for Issue #389 : Support for MessagePack
I use the https://github.com/komamitsu/retrofit-converter-msgpack (thanks to @majst01)

@codecov-io
Copy link

codecov-io commented Jun 13, 2018

Codecov Report

Merging #460 into master will increase coverage by 0.18%.
The diff coverage is 91.04%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #460      +/-   ##
============================================
+ Coverage     86.63%   86.81%   +0.18%     
- Complexity      302      309       +7     
============================================
  Files            20       20              
  Lines          1294     1327      +33     
  Branches        135      137       +2     
============================================
+ Hits           1121     1152      +31     
- Misses          113      115       +2     
  Partials         60       60
Impacted Files Coverage Δ Complexity Δ
src/main/java/org/influxdb/dto/QueryResult.java 96.29% <ø> (ø) 6 <0> (ø) ⬇️
src/main/java/org/influxdb/InfluxDBFactory.java 93.33% <50%> (-6.67%) 5 <0> (ø)
src/main/java/org/influxdb/impl/InfluxDBImpl.java 87.94% <92.3%> (+0.25%) 74 <6> (+6) ⬆️
src/main/java/org/influxdb/InfluxDBException.java 90.9% <0%> (+3.63%) 12% <0%> (+1%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f9ca92f...8923339. Read the comment docs.

Copy link
Collaborator

@majst01 majst01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this PR does not look very clean, maybe our current implementation is not designed to be extendable as it should.

@@ -3,6 +3,8 @@
import java.util.List;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we introduce a new dependency to jackson ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because the converter https://github.com/komamitsu/retrofit-converter-msgpack (you proppsed it) depends on jackson

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, i didnt check that, my fault. But still, using another json converter with this change is not desired. We must think twice "

import com.fasterxml.jackson.databind.MappingIterator;
import com.fasterxml.jackson.databind.MappingJsonFactory;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectReader;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, i really would like to prevent to switch from moshi to jackson with this PR. I am not against changing the json converter library, i just want to do it by "accident" when introducing messagepack format. We should do this move, once decided intentionally and without any other modifications.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@majst01 I believe Jackson is being used here because it's a direct dependency used by the msgpack converter library, as you can see here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again, the convertor depends on Jackson

result = results.nextValue();
consumer.accept(result);
}
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Way too much code in the constructor.

Copy link
Contributor Author

@lxhoan lxhoan Jun 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a minor release, I would like to keep the implementation as back-ward compatible as possible. this constructor

  InfluxDBImpl(final String url, final String username, final String password, final OkHttpClient.Builder client,
          final InfluxDBService influxDBService, final JsonAdapter<QueryResult> adapter) {

in my opinion, even it seems awkward and used nowhere in the source code, we are not used if it is used by any user or not so I decided to keep it. That lead me to introduce the ChunkProcessor so we can have polymorphism for processing chunking query

@majst01, I believe Jackson has a better API on processing HTTP chunked response, You can compare 2 implementation of ChunkProccesor to see how different they are

@@ -130,7 +132,8 @@ public void testFlushDuration() throws InterruptedException {

//check no points writen to DB before the flush duration
QueryResult result = influxDB.query(new Query("select * from weather", dbName));
Assertions.assertNull(result.getResults().get(0).getSeries());
List<Series> series = result.getResults().get(0).getSeries();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why a test must be changed ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because:
+in JSON response (for an empty query), the 'series' element does not exists

  • in MessagePack response (for an empty query), series exist as an empty array
    --> I think none of them are not wrong, just the consistency from server side. I am actually thinking to open an issue for the server

@lxhoan
Copy link
Contributor Author

lxhoan commented Jun 15, 2018

OK, i didnt check that, my fault. But still, using another json converter with this change is not desired. We must think twice "

@majst01 , I think that's not a fault, because I found that this MessagePack retrofit converter is really documented in Retrofit Wiki https://github.com/square/retrofit/wiki/Converters). So I believe it is somewhat recommended by Retrofit guys.

BTW, in a response to your comments. I propose following changes

  • keep using Moshi for keep using Moshi for converting chunked response in JSON - That means I keep all the old implementation for processing JSON format, only use Jackson on MessagePack (it's indispensable)
  • keep QueryResult neutral - do not put Jackson binding annotations on it
    I push these changes to another PR Implement Issue #389 : Support for MessagePack #462

What do you think ?

@lxhoan lxhoan closed this Jul 3, 2018
@lxhoan lxhoan deleted the features/message-pack-5 branch July 3, 2018 04:41
@lxhoan
Copy link
Contributor Author

lxhoan commented Jul 27, 2018

closed because PR #471 is the final PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants