[infinispan-dev] Annotated encoded entries

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[infinispan-dev] Annotated encoded entries

Radim Vansa
Hi guys,

recently the new encoding stuff has dawned in the codebase, and I must
admit that keeping track what's in storage-format and what's not (and I
think I've spotted some bugs). I think that we could use Java 8's type
annotations that would explicitly mark the contents as encoded or not
encoded:

@Target({ ElementType.FIELD, ElementType.LOCAL_VARIABLE,
ElementType.PARAMETER, ElementType.TYPE_PARAMETER, ElementType.TYPE_USE })
public @interface Storage {
}

@Target({ ElementType.FIELD, ElementType.LOCAL_VARIABLE,
ElementType.PARAMETER, ElementType.TYPE_PARAMETER, ElementType.TYPE_USE })
public @interface External {
}

Then the Encoder would look like:

public interface Encoder {
    @Storage Object toStorage(@External Object content);
    @External Object fromStorage(@Storage Object content);

}

Eventually we could use tools like the Checker Framework [1] to enforce
explicit casts from non-annotated type to annotated. I am still not
fully decided if we should have separate annotations for keys & values.

While this gives some clarity on use, those annotations would have to be
rather ubiquitous (code bloat?). Nevertheless, what do you think about it?

Radim

[1] https://checkerframework.org/jsr308/




--
Radim Vansa <[hidden email]>
JBoss Performance Team

_______________________________________________
infinispan-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/infinispan-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [infinispan-dev] Annotated encoded entries

Adrian Nistor
That's clever, but a bit too much bloat I'm afraid.

On 07/27/2017 05:02 PM, Radim Vansa wrote:

> Hi guys,
>
> recently the new encoding stuff has dawned in the codebase, and I must
> admit that keeping track what's in storage-format and what's not (and I
> think I've spotted some bugs). I think that we could use Java 8's type
> annotations that would explicitly mark the contents as encoded or not
> encoded:
>
> @Target({ ElementType.FIELD, ElementType.LOCAL_VARIABLE,
> ElementType.PARAMETER, ElementType.TYPE_PARAMETER, ElementType.TYPE_USE })
> public @interface Storage {
> }
>
> @Target({ ElementType.FIELD, ElementType.LOCAL_VARIABLE,
> ElementType.PARAMETER, ElementType.TYPE_PARAMETER, ElementType.TYPE_USE })
> public @interface External {
> }
>
> Then the Encoder would look like:
>
> public interface Encoder {
>      @Storage Object toStorage(@External Object content);
>      @External Object fromStorage(@Storage Object content);
>
> }
>
> Eventually we could use tools like the Checker Framework [1] to enforce
> explicit casts from non-annotated type to annotated. I am still not
> fully decided if we should have separate annotations for keys & values.
>
> While this gives some clarity on use, those annotations would have to be
> rather ubiquitous (code bloat?). Nevertheless, what do you think about it?
>
> Radim
>
> [1] https://checkerframework.org/jsr308/
>
>
>
>

_______________________________________________
infinispan-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/infinispan-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [infinispan-dev] Annotated encoded entries

Gustavo Fernandes-2
On Thu, Jul 27, 2017 at 10:08 PM, Adrian Nistor <[hidden email]> wrote:
That's clever, but a bit too much bloat I'm afraid.


Your mileage may vary, but in the spots I needed to handle those conversions, a mix
of comments and proper local variable naming seemed enough, so I'm with Adrian
in this.

Gustavo


_______________________________________________
infinispan-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/infinispan-dev
Loading...