git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [JGIT PATCH] 1/2: Externalizable items

From
Nigel Magnay <nigel.magnay@gmail.com>
Date
Feb 16, 2009, 18:09 UTC
Message-ID
<320075ff0902161009s1454e1feu5b3543f898112406@mail.gmail.com>
In-Reply-To
<20090216172025.GE18525@spearce.org>
Show 6 quoted lines
> Yikes.  Do we really need a public no-arg constructor for
> Externalizable?  If we do, maybe we should use Serializable instead
> so we can hide this constructor.  I don't like the idea of people
> creating ObjectId.zeroId() by new ObjectId().  That's not a pattern
> we should encourage.
>
Yes, you have to have a public no-args constructor for Externalizable.
 I agree, it's hideous. But I thought that was known as you explicitly
asked for Externalizable rather than Serializable with readObject /
writeObject... :-/

More than happy to re-roll with Serializable instead - do you want this for all 4? (RemoteConfig also gained a no-args constructor because of Externalizable..)

Show 12 quoted lines
>> +     public void writeExternal(ObjectOutput out) throws IOException {
>> +             byte[] sha1 = new byte[20];
>> +             copyRawTo(sha1, 0);
>> +             out.write(sha1);
>> +     }
>
> Hmm.  I was thinking of just writing the 5 ints out, and reading
> the 5 ints back in.  We're always talking to another Java process.
> The ints are written in network byte order anyway on a serialization
> stream.  Doing this conversion to a byte[] thrases the caller's
> per-thread new generation rather hard.  I think applications using
> this type in a serialization stream would expect it to be quick.
I've taken the request for "the 20 byte SHA-1" too literally :-)
Show 6 quoted lines
> +             Map<String, Collection<String>> map = new HashMap<String,
> Collection<String>>();
> +             for (int i = 0; i < items; i++) {
> +                     String key = in.readUTF();
> +                     String value = in.readUTF();
>Why not just serialize the Map in the stream?

Sure - if you're happy with that representation - it's not " a map of keys/values as it appears in the config " though as it's a map to a list because of the multi-values that are available for things like URL and Fetch.

Previous: Shawn O. PearceNext: Shawn O. Pearce
Message 5 of 6 in “1/2: Externalizable items”
  1. 1/2: Externalizable itemsNigel Magnay, Feb 16, 2009
  2. Johannes SchindelinFeb 16, 2009
  3. Nigel MagnayFeb 16, 2009
  4. Shawn O. PearceFeb 16, 2009
  5. Nigel MagnayFeb 16, 2009
  6. Shawn O. PearceFeb 16, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.