← Back to team overview

syncany-team team mailing list archive

Re: Long ids

 

Hi Gregor,

Le 05/12/2013 23:15, Gregor Trefs a écrit :

> I tried my best to express myself in code.
> 
> https://github.com/gtrefs/syncany/tree/longer-file-id/src/org/syncany
> 
> I made ObjectID generic, so there is no inheritance structure in the ID
> itself and the properties you requested still hold true.

Very nice design, thanks! We still need two things:

1) if we want ObjectID sizes to depend on the indexed type (this is the
case), we need something slightly more complicated. My take would be to
have all indexable classes to implement an Indexable interface with a
preferredSize method which returns the number of bytes needed. Then we
will have ObjectId<T extends Indexable> or something like this.

2) if we want to pack the memory, we need ObjectID to be abstract and
the factory to use concrete types adapted to the requested size. This is
simple to do also.

The only thing that bothers me is the type attribute. I don't think we
need to bother about types in the equal. In theory, you solution is
super clean, but I'm under the impression it is not needed. Indeed,
types will be explicit everywhere and I don't why one would have to
compare an ObjectId<A> with an ObjectId<B>. In practice, we only use
hashCode and equals indirectly in HashMap and related structure. But we
will use something like
HashMap<ObjectId<PartialFileHistory>,PartialFileHistory> so there is no
way a ObjectId<SomethingElse> can get inside that, expect by deliberate
casting. Am I missing something?

Philipp, what do you think? If you're satisfied by Gregor's proposal, I
can merge it into my branch (I've pending unification modifications),
implement the modifications proposed in 1 and 2 (and probably remove the
type attribute if you agree). When ready, a pull request will hit your
mailbox :-) As for names, what about: Index and Indexable, or Id and
Indexable, or Key and WithKey, or whatever simpler than ObjectId which
feels now a bit long...

Thanks again Gregor, very smart design.

Cheers,

Fabrice




References