You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Jeff Varszegi <jv...@yahoo.com> on 2002/11/14 20:17:31 UTC

Pleasedtameetcha, and a couple of questions

I'm a newbie to the Apache mailing lists; I ask forgiveness in advance for asking stupid
questions.

I've developed some things that I would like someone to take a look at to see if they are useful. 


The first is a LinkedList implementation that reduces object creation/garbage collection that
works twice as fast as LinkedList.

The second is a double-ended queue that offers good speed and deterministic delivery to waiting
threads.  In other words, if thread A requests something from the queue before thread B, thread A
is guaranteed to get a result before thread B, even if both of them are initially forced to wait. 
This was an absolute requirement for some code I'm writing, and if it can be useful to someone I
don't want to waste the chance.  I would also like someone to look over the queue code, to check
for correctness and maybe suggest improvements.

Is there any interest in these two items?  I have other general-purpose utility stuff too, but I'm
not sure of the proper way to submit it all.  Do I just send the code to this list, or what?

I like what I see in the Commons project!  I like Sun's Collections API in general, but there's
nastiness everywhere-- unnecessary object creation, etc.

Jeff Varszegi

P.S.  Anyone contribute a SkipList implementation yet?  How about array-based Red-Black tree or
something similar?  I've found that most of the slowness in TreeSet and TreeMap is due to
unnecessary object creation.

__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [collections] Pleasedtameetcha, and a couple of questions

Posted by Stephen Colebourne <sc...@btopenworld.com>.
----- Original Message -----
From: "Jeff Varszegi" <jv...@yahoo.com>
> > > The second is a double-ended queue
> > May be too specialised. Don't know without looking. Does it implement
our
> > Buffer interface?
>
> Did you have a chance to take a look?  Anyone, anyone?
Unfortunately we are all time pressurised, and at the moment it seems as
though I'm the only one keeping an eye out for [collections] which isn't
ideal.


> The Buffer interface is very simple, and
> it wouldn't be hard to make a collection implement it, but it is opposed
to the problem that is
> solved by the queue I sent to the list.  I created it to serve as a
double-ended queue (which has
> very wide application) and also to serve as an information conduit/buffer
between separate threads
> in an application.
The quick look I did take made me wonder if this would fit better in a
[thread] project, rather than generic [collections]. Not sure. It depends on
whether the most significant part is the threading or the double-ended part.
(Of course we haven't really got an active [thread] project ;--)

Stephen

> The fact that Buffer always throws an exception if a read attempt is made
without something being
> in the queue woudl be a detriment if the queue were being used in this
way; also, the Buffer
> interface says nothing about peeking.  The peeking is okay, since that
could be behavior just not
> guaranteed by the interface.
>
> I modeled the remove/peek methods after JMS queue methods where you can
specify a certain number
> of milliseconds to wait.  This is useful because you immediately get a
return whenever there is
> one, and you are given the chance to interrupt your waiting-for-work in
order to poll for state
> changes (like would happen when you're application's shutting down).
>
> Know what I mean?  If a Buffer always returns something immediately or
throws an exception, then
> to accept work from a Buffer means that you must implement your own
sleeping loop outside of read
> calls to the Buffer.  And, of course, when you're sleeping you can't read,
so you're guaranteed to
> get any result from a Buffer an average of half your sleep interval after
you could've received it
> in an optimal situation.
>
> Sorry for being so blasted unintelligible, but I'm coping with a raging
cold here.
>
> Your friend,
> Jeff
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Web Hosting - Let the expert host your site
> http://webhosting.yahoo.com
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [all]Naming conventions (where do I find 'em?)

Posted by Stephen Colebourne <sc...@btopenworld.com>.
From: "Jeff Varszegi" <jv...@yahoo.com>
> 1. Are there naming standards to which the Jakarta community adheres?
Current commons charter states that each commons subproject choses its own
standards. [Collections] has a document called developers-guide.html. It
would certainly make sense to expand on this for [collections] and add a new
file for [lang]

> 2. Is everything that has been previously named set in stone?  (If so, I
won't bring such things
> up.)
Pretty much. The commons charter says that we aim to really minimise API
change, as we are the low level utilities. Each case should be considered on
its own merits though as it comes up.

Stephen


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [PROPOSAL] set a standard location for a component's coding standards

Posted by Scott Sanders <sa...@apache.org>.
On Mon, Nov 18, 2002 at 07:12:12PM +0000, robert burrell donkin wrote:
> PROPOSAL
> ========
> components are supposed to adhere to the jakarta coding standards (ie. the 
> sun coding standards) unless they document the coding standards they use. 
> at the moment, this document can be located anywhere and is therefore 
> difficult to find. it therefore seems sensible to choose a standard 
> filename and location for this file.
> 
> i think that it'd be easier to establish the principle before choosing a 
> name and location but anyone who has any good ideas is very welcome to 
> propose them now.
> 

I would prefer that it be listed in the STATUS file, or least have a link from the STATUS file.

I also like the collections DEVELOPERS-GUIDE concept.


-- 
Scott Sanders - sanders@apache.org

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [PROPOSAL] set a standard location for a component's coding standards

Posted by Stephen Colebourne <sc...@btopenworld.com>.
+1
The [collections] version is DEVELOPER-GUIDE.html in the root
Stephen

----- Original Message -----
From: "robert burrell donkin" <ro...@blueyonder.co.uk>


> PROPOSAL
> ========
> components are supposed to adhere to the jakarta coding standards (ie. the
> sun coding standards) unless they document the coding standards they use.
> at the moment, this document can be located anywhere and is therefore
> difficult to find. it therefore seems sensible to choose a standard
> filename and location for this file.
>
> i think that it'd be easier to establish the principle before choosing a
> name and location but anyone who has any good ideas is very welcome to
> propose them now.
>
> - robert
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


[PROPOSAL] set a standard location for a component's coding standards

Posted by robert burrell donkin <ro...@blueyonder.co.uk>.
PROPOSAL
========
components are supposed to adhere to the jakarta coding standards (ie. the 
sun coding standards) unless they document the coding standards they use. 
at the moment, this document can be located anywhere and is therefore 
difficult to find. it therefore seems sensible to choose a standard 
filename and location for this file.

i think that it'd be easier to establish the principle before choosing a 
name and location but anyone who has any good ideas is very welcome to 
propose them now.

- robert


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [all]Naming conventions (where do I find 'em?)

Posted by robert burrell donkin <ro...@blueyonder.co.uk>.
On Sunday, November 17, 2002, at 08:05 PM, Jeff Varszegi wrote:

> Thanks for your thoughtful reply.  I think that code that has standard 
> naming conventions is
> easier for people to understand, and makes it more likely to be adopted 
> (in addition to making it
> look more professional).  Maybe it comes from my English-geek background;
>  one of the things I love
> about object-oriented languages like Java is that my code turns out to 
> read almost like a story if
> I've taken time with the naming of things.
>
> I am having a blast digging through all the Jakarta projects for the 
> first time, but at first I
> was a little confused as to some of the website organization.  I just 
> figured I was missing the
> coding-standards documentation if I didn't immediately see any.

the web site has grown rather than been designed. this has advantages and 
disadvantages. it grows organically by the efforts of our contributors. so,
  if you can see an improvement, then why not submit a patch.

if you want to submit an improvement for a subproject site (eg. 
jakarata-commons) then you need to find out how their site is built and 
then either post your patch to their dev mailing list or add it to 
bugzilla. (jakarta-commons is build with anakia and the documents you need 
to patch live in the top level xdocs folder.)

if it's for the jakarta site, then you need should read

http://jakarta.apache.org/site/jakarta-site2.html

(though it's mainly aimed at committers) and then post your patches to 
general@jakarta.apache.org.

- robert


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [all]Naming conventions (where do I find 'em?)

Posted by Jeff Varszegi <jv...@yahoo.com>.
Thanks for your thoughtful reply.  I think that code that has standard naming conventions is
easier for people to understand, and makes it more likely to be adopted (in addition to making it
look more professional).  Maybe it comes from my English-geek background; one of the things I love
about object-oriented languages like Java is that my code turns out to read almost like a story if
I've taken time with the naming of things.

I am having a blast digging through all the Jakarta projects for the first time, but at first I
was a little confused as to some of the website organization.  I just figured I was missing the
coding-standards documentation if I didn't immediately see any.

Jeff

--- robert burrell donkin <ro...@blueyonder.co.uk> wrote:
> On Sunday, November 17, 2002, at 12:47 AM, Henri Yandell wrote:
> 
> > On Sat, 16 Nov 2002, Jeff Varszegi wrote:
> 
> <snip>
> 
> >> 1. Are there naming standards to which the Jakarta community adheres?
> >
> > The Sun coding standards are often adhered to. There are some other
> > Jakarta projects which have coding standards, Turbine do I think, and
> > Avalon might as well. Tomcat? And their standards are often chosen by
> > particular projects in Commons.
> 
> just for the record (and hopefully people will set me right if i go wrong)
> ...
> 
> jakarta uses lazy delegation for coding standards. jakarta has a top level 
> set of standards. but any subproject can override any standard or add 
> enhancements by explictly creating their own standards. components in the 
> commons can in addition lazily delegate from any commons subproject-level 
> coding standards.
> 
> avalon and turbine are two projects which have well developed (but 
> different) coding standards. a number of other subprojects use those 
> standards rather than creating their own.
> 
> AFAIK commons has been too lazy to draw up any coding standards and so we 
> default to the sun standards.
> 
> 
> where would you look to find coding standards for components?
> 
> IMHO they should be in the top level of the component's cvs folder. they 
> should probably have a specified name and format so that people can find 
> them. but at the moment, this hasn't been done. i'd say that this is an 
> oversight that needs correcting.
> 
> 
> >> 2. Is everything that has been previously named set in stone?  (If so,
> >> I won't bring such things up.)
> >
> > Depends on releases ususally. Things have to be slowly deprecated for a
> > rename and often it's not worth the 2 or 3 releases worth of management.
> >
> > I agree with both of your renamings though. The renamed ones make more
> > sense if they could be applied.
> 
> IMHO pure renaming is the easiest deprecation case to maintain. what's 
> crucial, though, is that time's taken to ensure that the improved names 
> are exactly right.
> 
> - robert
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 


__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [all]Naming conventions (where do I find 'em?)

Posted by robert burrell donkin <ro...@blueyonder.co.uk>.
On Sunday, November 17, 2002, at 12:47 AM, Henri Yandell wrote:

> On Sat, 16 Nov 2002, Jeff Varszegi wrote:

<snip>

>> 1. Are there naming standards to which the Jakarta community adheres?
>
> The Sun coding standards are often adhered to. There are some other
> Jakarta projects which have coding standards, Turbine do I think, and
> Avalon might as well. Tomcat? And their standards are often chosen by
> particular projects in Commons.

just for the record (and hopefully people will set me right if i go wrong)
...

jakarta uses lazy delegation for coding standards. jakarta has a top level 
set of standards. but any subproject can override any standard or add 
enhancements by explictly creating their own standards. components in the 
commons can in addition lazily delegate from any commons subproject-level 
coding standards.

avalon and turbine are two projects which have well developed (but 
different) coding standards. a number of other subprojects use those 
standards rather than creating their own.

AFAIK commons has been too lazy to draw up any coding standards and so we 
default to the sun standards.


where would you look to find coding standards for components?

IMHO they should be in the top level of the component's cvs folder. they 
should probably have a specified name and format so that people can find 
them. but at the moment, this hasn't been done. i'd say that this is an 
oversight that needs correcting.


>> 2. Is everything that has been previously named set in stone?  (If so,
>> I won't bring such things up.)
>
> Depends on releases ususally. Things have to be slowly deprecated for a
> rename and often it's not worth the 2 or 3 releases worth of management.
>
> I agree with both of your renamings though. The renamed ones make more
> sense if they could be applied.

IMHO pure renaming is the easiest deprecation case to maintain. what's 
crucial, though, is that time's taken to ensure that the improved names 
are exactly right.

- robert


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


[lang][SUBMIT] Some utility classes for generating IDs

Posted by Jeff Varszegi <jv...@yahoo.com>.
Sorry I forgot to put the SUBMIT tag on the preceding email.  -Jeff

__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [lang][SUBMIT] Some utility classes for generating IDs

Posted by Henri Yandell <ba...@generationjava.com>.
Nah, there's actually a jakarta-commons-sandbox project called Patterns.
Stephen used it to do some research work, most of which has ended up in
the Lang tree now:

http://cvs.apache.org/viewcvs.cgi/jakarta-commons-sandbox/pattern/src/java/org/apache/commons/pattern/identifier/

I liked the XML parser, was fun to make, but didn't seem any point in
competing with all the others, NanoXml etc. Weirdly, this is the second
time it's been mentioned this week as a port I made to LPC[Pike-like
language] looks like it might get used somewhere :)

Hen

On Sun, 17 Nov 2002, Jeff Varszegi wrote:

> I agree with you.  By Patterns were you referring to Betwixt?  I
> checked out your website.  Your tiny XML parser is nice-- I did
> something very similar about a year ago. -Jeff
>
> --- Henri Yandell <ba...@generationjava.com> wrote:
> >
> > There are some ID generating bits in the Commons Sandbox. In the Patterns
> > project and I think there's one in the Util project.
> >
> > Neither have yet made their way into a release project yet. I've been
> > pondering whether something like this would go in DbUtils, but the
> > database specificness gets quite painful.
> >
> > So as far as Lang goes, I'm not sure :) They've always seemed a bit above
> > Lang's basic aims.
> >
> > Hen
> >
> > On Sat, 16 Nov 2002, Jeff Varszegi wrote:
> >
> > > I use these to generate IDs for EJBs and in a couple of other ways.  Does anyone think they
> > could
> > > be usefully included in a project?  I did look around to see if there was something already in
> > > Commons for this, but I didn't see anything.
> > >
> > > The IDGenerator interface provides one method, generateID().  A few implementations are
> > provided,
> > > including one that generates 32-character UUIDs.  A lookup class is also provided for
> > acquiring an
> > > IDGenerator by name.
> > >
> > > Jeff
> > >
> > >
> > > __________________________________________________
> > > Do you Yahoo!?
> > > Yahoo! Web Hosting - Let the expert host your site
> > > http://webhosting.yahoo.com
> >
> >
> > --
> > To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> > For additional commands, e-mail: <ma...@jakarta.apache.org>
> >
>
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Web Hosting - Let the expert host your site
> http://webhosting.yahoo.com
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [lang][SUBMIT] Some utility classes for generating IDs

Posted by Jeff Varszegi <jv...@yahoo.com>.
I agree with you.  By Patterns were you referring to Betwixt?  I checked out your website.  Your
tiny XML parser is nice-- I did something very similar about a year ago. -Jeff

--- Henri Yandell <ba...@generationjava.com> wrote:
> 
> There are some ID generating bits in the Commons Sandbox. In the Patterns
> project and I think there's one in the Util project.
> 
> Neither have yet made their way into a release project yet. I've been
> pondering whether something like this would go in DbUtils, but the
> database specificness gets quite painful.
> 
> So as far as Lang goes, I'm not sure :) They've always seemed a bit above
> Lang's basic aims.
> 
> Hen
> 
> On Sat, 16 Nov 2002, Jeff Varszegi wrote:
> 
> > I use these to generate IDs for EJBs and in a couple of other ways.  Does anyone think they
> could
> > be usefully included in a project?  I did look around to see if there was something already in
> > Commons for this, but I didn't see anything.
> >
> > The IDGenerator interface provides one method, generateID().  A few implementations are
> provided,
> > including one that generates 32-character UUIDs.  A lookup class is also provided for
> acquiring an
> > IDGenerator by name.
> >
> > Jeff
> >
> >
> > __________________________________________________
> > Do you Yahoo!?
> > Yahoo! Web Hosting - Let the expert host your site
> > http://webhosting.yahoo.com
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 


__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [lang][SUBMIT] Some utility classes for generating IDs

Posted by Henri Yandell <ba...@generationjava.com>.
There are some ID generating bits in the Commons Sandbox. In the Patterns
project and I think there's one in the Util project.

Neither have yet made their way into a release project yet. I've been
pondering whether something like this would go in DbUtils, but the
database specificness gets quite painful.

So as far as Lang goes, I'm not sure :) They've always seemed a bit above
Lang's basic aims.

Hen

On Sat, 16 Nov 2002, Jeff Varszegi wrote:

> I use these to generate IDs for EJBs and in a couple of other ways.  Does anyone think they could
> be usefully included in a project?  I did look around to see if there was something already in
> Commons for this, but I didn't see anything.
>
> The IDGenerator interface provides one method, generateID().  A few implementations are provided,
> including one that generates 32-character UUIDs.  A lookup class is also provided for acquiring an
> IDGenerator by name.
>
> Jeff
>
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Web Hosting - Let the expert host your site
> http://webhosting.yahoo.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


[lang] Some utility classes for generating IDs

Posted by Jeff Varszegi <jv...@yahoo.com>.
I use these to generate IDs for EJBs and in a couple of other ways.  Does anyone think they could
be usefully included in a project?  I did look around to see if there was something already in
Commons for this, but I didn't see anything.

The IDGenerator interface provides one method, generateID().  A few implementations are provided,
including one that generates 32-character UUIDs.  A lookup class is also provided for acquiring an
IDGenerator by name.

Jeff


__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com

Re: [all]Naming conventions (where do I find 'em?)

Posted by Henri Yandell <ba...@generationjava.com>.
Must finish the inbox before replying, *slaps self*.

Hen

On Sat, 16 Nov 2002, Henri Yandell wrote:

>
>
> On Sat, 16 Nov 2002, Jeff Varszegi wrote:
>
> > I was looking over the FastArrayList class (which I like) and noticed the methods setFast(boolean)
> > and getFast().  In my opinion, these would better (and more standardly) be named
> > 'setFastModeEnabled' and 'isFastModeEnabled'.  At the very least, shouldn't getFast() be named
> > 'isFast'?  It's a boolean indicator.
>
> I'd agree, but getFast is legal for a boolean too.
>
> > For another example, I also noticed methods called 'getNumActive' and
> 'getNumIdle' in ObjectPool.
> > I think these would be better named 'getActiveCount' and
> > 'getIdleCount' or something similar.  This would reduce the
> > unnecessary use of abbreviations and be more like stuff found
> > elsewhere in Java.
>
> Abbreviations are bad, true.
>
> > 1. Are there naming standards to which the Jakarta community adheres?
>
> The Sun coding standards are often adhered to. There are some other
> Jakarta projects which have coding standards, Turbine do I think, and
> Avalon might as well. Tomcat? And their standards are often chosen by
> particular projects in Commons.
>
> > 2. Is everything that has been previously named set in stone?  (If so,
> > I won't bring such things up.)
>
> Depends on releases ususally. Things have to be slowly deprecated for a
> rename and often it's not worth the 2 or 3 releases worth of management.
>
> I agree with both of your renamings though. The renamed ones make more
> sense if they could be applied.
>
> My tuppence,
>
> Hen
>
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [all]Naming conventions (where do I find 'em?)

Posted by Henri Yandell <ba...@generationjava.com>.

On Sat, 16 Nov 2002, Jeff Varszegi wrote:

> I was looking over the FastArrayList class (which I like) and noticed the methods setFast(boolean)
> and getFast().  In my opinion, these would better (and more standardly) be named
> 'setFastModeEnabled' and 'isFastModeEnabled'.  At the very least, shouldn't getFast() be named
> 'isFast'?  It's a boolean indicator.

I'd agree, but getFast is legal for a boolean too.

> For another example, I also noticed methods called 'getNumActive' and
'getNumIdle' in ObjectPool.
> I think these would be better named 'getActiveCount' and
> 'getIdleCount' or something similar.  This would reduce the
> unnecessary use of abbreviations and be more like stuff found
> elsewhere in Java.

Abbreviations are bad, true.

> 1. Are there naming standards to which the Jakarta community adheres?

The Sun coding standards are often adhered to. There are some other
Jakarta projects which have coding standards, Turbine do I think, and
Avalon might as well. Tomcat? And their standards are often chosen by
particular projects in Commons.

> 2. Is everything that has been previously named set in stone?  (If so,
> I won't bring such things up.)

Depends on releases ususally. Things have to be slowly deprecated for a
rename and often it's not worth the 2 or 3 releases worth of management.

I agree with both of your renamings though. The renamed ones make more
sense if they could be applied.

My tuppence,

Hen


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [lang] Performance enhancement for SerializationUtils

Posted by Stephen Colebourne <sc...@btopenworld.com>.
Thanks for this advice, I've included it in the CVS.

(I've added specific comments for the stream methods about buffering)

Stephen

----- Original Message -----
From: "Jeff Varszegi" <jv...@yahoo.com>
> Here is the code for the serialize(Serializable) method:
>
>     public static byte[] serialize(Serializable obj) {
>         ByteArrayOutputStream baos = new ByteArrayOutputStream();
>         serialize(obj, baos);
>         return baos.toByteArray();
>     }
>
> This can be sped up a significant amount just by using a different
constructor for the
> ByteArrayInputStream instance, passing in a number higher than 32, so it
constructs a bigger
> initial buffer than it otherwise would.  Bumping up the initial buffer
size to 128 worked about as
> well as bumping it up to 512 on my machine.
>
> This alone resulted in an overall 6% speed increase for the
clone(Serializable) method on my
> machine.
>
> For the methods serialize(Serializable, OutputStream) and
deserialize(InputStream) it may be
> desirable to wrap the passed streams in buffered streams.  Serialization
to/from streams is
> typically done for persistence, passing objects between JVMs, etc. and
it's not hard to imagine
> someone passing in unbuffered streams in these situations...
>
> Jeff
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Web Hosting - Let the expert host your site
> http://webhosting.yahoo.com
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


[lang] Performance enhancement for SerializationUtils

Posted by Jeff Varszegi <jv...@yahoo.com>.
Here is the code for the serialize(Serializable) method:

    public static byte[] serialize(Serializable obj) {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        serialize(obj, baos);
        return baos.toByteArray();
    }

This can be sped up a significant amount just by using a different constructor for the
ByteArrayInputStream instance, passing in a number higher than 32, so it constructs a bigger
initial buffer than it otherwise would.  Bumping up the initial buffer size to 128 worked about as
well as bumping it up to 512 on my machine.

This alone resulted in an overall 6% speed increase for the clone(Serializable) method on my
machine.

For the methods serialize(Serializable, OutputStream) and deserialize(InputStream) it may be
desirable to wrap the passed streams in buffered streams.  Serialization to/from streams is
typically done for persistence, passing objects between JVMs, etc. and it's not hard to imagine
someone passing in unbuffered streams in these situations...

Jeff

__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


[all]Naming conventions (where do I find 'em?)

Posted by Jeff Varszegi <jv...@yahoo.com>.
I was looking over the FastArrayList class (which I like) and noticed the methods setFast(boolean)
and getFast().  In my opinion, these would better (and more standardly) be named
'setFastModeEnabled' and 'isFastModeEnabled'.  At the very least, shouldn't getFast() be named
'isFast'?  It's a boolean indicator.

For another example, I also noticed methods called 'getNumActive' and 'getNumIdle' in ObjectPool. 
I think these would be better named 'getActiveCount' and 'getIdleCount' or something similar. 
This would reduce the unnecessary use of abbreviations and be more like stuff found elsewhere in
Java.

I'm not on a high horse-- what I'm really wondering is

1. Are there naming standards to which the Jakarta community adheres?
2. Is everything that has been previously named set in stone?  (If so, I won't bring such things
up.)

Thanks a lot.

Jeff

__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [collections] Pleasedtameetcha, and a couple of questions

Posted by Jeff Varszegi <jv...@yahoo.com>.
> > The second is a double-ended queue
> May be too specialised. Don't know without looking. Does it implement our
> Buffer interface?

Did you have a chance to take a look?  Anyone, anyone?  The Buffer interface is very simple, and
it wouldn't be hard to make a collection implement it, but it is opposed to the problem that is
solved by the queue I sent to the list.  I created it to serve as a double-ended queue (which has
very wide application) and also to serve as an information conduit/buffer between separate threads
in an application.

The fact that Buffer always throws an exception if a read attempt is made without something being
in the queue woudl be a detriment if the queue were being used in this way; also, the Buffer
interface says nothing about peeking.  The peeking is okay, since that could be behavior just not
guaranteed by the interface.

I modeled the remove/peek methods after JMS queue methods where you can specify a certain number
of milliseconds to wait.  This is useful because you immediately get a return whenever there is
one, and you are given the chance to interrupt your waiting-for-work in order to poll for state
changes (like would happen when you're application's shutting down).  

Know what I mean?  If a Buffer always returns something immediately or throws an exception, then
to accept work from a Buffer means that you must implement your own sleeping loop outside of read
calls to the Buffer.  And, of course, when you're sleeping you can't read, so you're guaranteed to
get any result from a Buffer an average of half your sleep interval after you could've received it
in an optimal situation.

Sorry for being so blasted unintelligible, but I'm coping with a raging cold here.

Your friend,
Jeff

__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [collections] Pleasedtameetcha, and a couple of questions

Posted by Jeff Varszegi <jv...@yahoo.com>.
>> SkipList???

ftp://ftp.cs.umd.edu/pub/skipLists/skiplists.pdf

There is other interesting information on William Pugh's website, including a paper on why the
double-checked-locking idiom for lazy initialization doesn't work in Java.

Jeff

__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


[collections] Pleasedtameetcha, and a couple of questions

Posted by Stephen Colebourne <sc...@btopenworld.com>.
From: "Jeff Varszegi" <jv...@yahoo.com>
> I'm a newbie to the Apache mailing lists; I ask forgiveness in advance for
asking stupid
> questions.

Quick hint - watch what others do before posting yourself...such as the
[collections] tag in the Subject line ;-)


> The first is a LinkedList implementation that reduces object
creation/garbage collection that
> works twice as fast as LinkedList.
Sounds promising


> The second is a double-ended queue that offers good speed and
deterministic delivery to waiting
> threads.  In other words, if thread A requests something from the queue
before thread B, thread A
> is guaranteed to get a result before thread B, even if both of them are
initially forced to wait.
> This was an absolute requirement for some code I'm writing, and if it can
be useful to someone I
> don't want to waste the chance.  I would also like someone to look over
the queue code, to check
> for correctness and maybe suggest improvements.
May be too specialised. Don't know without looking. Does it implement our
Buffer interface?


> Is there any interest in these two items?  I have other general-purpose
utility stuff too, but I'm
> not sure of the proper way to submit it all.  Do I just send the code to
this list, or what?
I suggest starting a new thread (with a clear Subject line) for each
submission, eg.
 [collections][SUBMIT] Faster LinkedList
and attach the code

> P.S.  Anyone contribute a SkipList implementation yet?  How about
array-based Red-Black tree or
> something similar?  I've found that most of the slowness in TreeSet and
TreeMap is due to
> unnecessary object creation.
SkipList???
Tree was discussed about 8 months ago but never got in. It should do though.

Stephen




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>