git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nigel Magnay <nigel.magnay@gmail.com>
To: "Shawn O. Pearce" <spearce@spearce.org>
Cc: Git ML <git@vger.kernel.org>
Subject: Re: [JGIT PATCH] 1/2: Externalizable items
Date: Mon, 16 Feb 2009 18:09:01 +0000	[thread overview]
Message-ID: <320075ff0902161009s1454e1feu5b3543f898112406@mail.gmail.com> (raw)
In-Reply-To: <20090216172025.GE18525@spearce.org>

> 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..)

>> +     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 :-)

> +             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.

  reply	other threads:[~2009-02-16 18:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-16 16:45 [JGIT PATCH] 1/2: Externalizable items Nigel Magnay
2009-02-16 16:59 ` Johannes Schindelin
2009-02-16 17:10   ` Nigel Magnay
2009-02-16 17:20 ` Shawn O. Pearce
2009-02-16 18:09   ` Nigel Magnay [this message]
2009-02-16 18:16     ` Shawn O. Pearce

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=320075ff0902161009s1454e1feu5b3543f898112406@mail.gmail.com \
    --to=nigel.magnay@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=spearce@spearce.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).