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

Use simpleserializer with TypeLayer #90

Open
keith-turner opened this issue Jul 20, 2016 · 0 comments
Open

Use simpleserializer with TypeLayer #90

keith-turner opened this issue Jul 20, 2016 · 0 comments

Comments

@keith-turner
Copy link
Contributor

After #82 I think it may make sense to drop the Encoder used by the TypeLayer and instead use the SimpleSerlializer. This will result in a more uniform and consistent user experience. It will also allow the addition of set(Object) and T toObject(Class<T> clazz) methods.

SimpleConfiguration appConfig = ...
Transaction tx = ...
//The serialzer implementation is read from app config
TypeLayer tl = ...
TypedTransaction ttx = tl.wrap(tx);

String r = ...;
String f = ...;
long q = ...;

//some pojo type
SomePojo sp = ... 

ttx.mutate().row(r).fam(f).qual(q).set(sp)
SomePojo sp2 = ttx.get().row(r).fam(f).qual(q).toObject(SomePojo.class)

//get with default value
SomePojo default = ...
SomePojo sp3 = ttx.get().row(r).fam(f).qual(q).toObject(SomePojo.class, default)

There are some things I am uncertain about. First I was thinking that one SimpleSerializer should replace Encoder, but then I thought about the case where want to encode key fields differently than values. For example may want to encode long types in row, family and qualifier in a certain way so that they sort properly. Also, I am thinking it should be possible to use config to get class types.

One option could be to drop encoder, replacing it with simplerserializer and optionally support using a different type of simpleserializer for key fields. This could possible be done with a builder pattern. I am not sure if I like this approach yet.

//build a type layer getting key and value SimpleSerializer type from config. 
tl = TypeLayer.builder().config(...).build()

//build a type layer with a specific SimpleSerializerfor keys and get the simple serializer for values from config
tl = TypeLayer.builder().keySerializer(....).config(....).build()
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

No branches or pull requests

1 participant