-
Notifications
You must be signed in to change notification settings - Fork 14
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
Improvements around empty data handling #18
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First CR on this - why is SimpleStore
closeable? Seems strange that the entire store is closeable vs having some sort of transaction that is instead. What if multiple spots access it? Or is SimpleStore
the transaction and consumers must always create a new instance from the factory?
protosimplestore/src/main/java/com/uber/simplestore/proto/impl/SimpleProtoStoreFactory.java
Show resolved
Hide resolved
protosimplestore/src/test/java/com/uber/simplestore/proto/SimpleProtoStoreImplTest.java
Outdated
Show resolved
Hide resolved
@@ -0,0 +1,10 @@ | |||
syntax = "proto2"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not proto3?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
proto3 doesn't buy anything on mobile and in fact has downsides.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a bit vague - can you elaborate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protocolbuffers/protobuf#272 et al.
protosimplestore/src/test/java/com/uber/simplestore/proto/SimpleProtoStoreImplTest.java
Outdated
Show resolved
Hide resolved
protosimplestore/src/test/java/com/uber/simplestore/proto/SimpleProtoStoreImplTest.java
Outdated
Show resolved
Hide resolved
protosimplestore/src/test/java/com/uber/simplestore/proto/SimpleProtoStoreImplTest.java
Outdated
Show resolved
Hide resolved
simplestore/src/main/java/com/uber/simplestore/SimpleStore.java
Outdated
Show resolved
Hide resolved
@@ -28,6 +29,7 @@ | |||
private static final int OPEN = 0; | |||
private static final int CLOSED = 1; | |||
private static final int TOMBSTONED = 2; | |||
private static final byte[] EMPTY_BYTES = new byte[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this preferable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is cleaner than constantly allocating an empty byte array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not what I meant - why is an empty array preferable over null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Futures should not have nulls passed through them just like Observables should not. It is up to the user/data model chose to represent optionality in the model itself instead of the framework requiring everyone everywhere to handle null.
simplestore/src/main/java/com/uber/simplestore/impl/SimpleStoreImpl.java
Outdated
Show resolved
Hide resolved
simplestore/src/test/java/com/uber/simplestore/impl/SimpleStoreImplTest.java
Outdated
Show resolved
Hide resolved
|
* Support cache scope config * Handle empty state properly
Never return null from store methods.
@@ -55,6 +73,14 @@ public static SimpleProtoStoreImpl create(Context context, String scope, ScopeCo | |||
SimpleStoreConfig.getComputationExecutor()); | |||
} | |||
|
|||
@Override | |||
public ListenableFuture<Boolean> contains(String key) { | |||
return Futures.transform( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could consider an index here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will optimize contains down the road.
return create(context, scope, ScopeConfig.DEFAULT); | ||
} | ||
|
||
public static SimpleProtoStore create(Context context, String scope, ScopeConfig config) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
follow up on discussion if a wrap is appropriate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
following up with some prototyping later
No description provided.