Re: code generation for hash maps

2009-12-18 Thread Benson Margulies
And, in fact, after a bit more thinking, Velocity it is. On Fri, Dec 18, 2009 at 4:31 PM, Benson Margulies wrote: > 1) velocity spews endless useless log messages whenever you touch it. > 2) I found an ant task for fmpp that could be easily mutated into a > maven mojo. I didn't find the equivalen

Re: code generation for hash maps

2009-12-18 Thread Benson Margulies
1) velocity spews endless useless log messages whenever you touch it. 2) I found an ant task for fmpp that could be easily mutated into a maven mojo. I didn't find the equivalent for velocity, but I think I got distracted in the process. I think that the templates in this case will be so simple as

Re: code generation for hash maps

2009-12-18 Thread Ted Dunning
I don't think I know enough to comment intelligently. But I will comment anyway. :-) I see three options, off-hand, a) velocity (the standard answer, don't know if it fits) b) freemarker (a more fashionable answer, don't know any strong reason it is better than (a)) c) something off the wall

Re: code generation for hash maps

2009-12-18 Thread Benson Margulies
Meanwhile, on this thread, anyone object to FreeMarker as the template language? On Fri, Dec 18, 2009 at 7:02 AM, Benson Margulies wrote: > If you want speed, you want a shortcut for this. > > On Fri, Dec 18, 2009 at 2:40 AM, Sean Owen wrote: >> Agree, but isn't the conclusion that the internal

Re: code generation for hash maps

2009-12-18 Thread Benson Margulies
If you want speed, you want a shortcut for this. On Fri, Dec 18, 2009 at 2:40 AM, Sean Owen wrote: > Agree, but isn't the conclusion that the internal map returns NaN, and > if desired, the vector converts that to 0.0? > In my world of maps, I don't have any case where 'null' should mean '0'. > >

Re: code generation for hash maps

2009-12-17 Thread Sean Owen
Agree, but isn't the conclusion that the internal map returns NaN, and if desired, the vector converts that to 0.0? In my world of maps, I don't have any case where 'null' should mean '0'. On Thu, Dec 17, 2009 at 2:18 AM, Ted Dunning wrote: > This seems most congenial.  As Jake says, 0 is definit

Re: code generation for hash maps

2009-12-16 Thread Benson Margulies
I don't anticipate any big problems in making the default value configurable. Yes, Trove has the complete cross-product, so matching that sure makes a code generator attractive. On Wed, Dec 16, 2009 at 6:18 PM, Ted Dunning wrote: > This seems most congenial.  As Jake says, 0 is definitely handi

Re: code generation for hash maps

2009-12-16 Thread Ted Dunning
This seems most congenial. As Jake says, 0 is definitely handier for the sparse matrix/vector case and NaN is very nice for the collection case. On Wed, Dec 16, 2009 at 3:10 PM, Jake Mannix wrote: > Of course, you could also just have the {X}{Y}Map take a default value in > the constructor, and

Re: code generation for hash maps

2009-12-16 Thread Jake Mannix
On Tue, Dec 15, 2009 at 5:26 AM, Benson Margulies wrote: > As to float and double, they may need to be special cases. Ask > yourself: "What should get(k) return when containsKey(k) is false and > the payload is double?" > > Answer 1: NaN. > Answer 2: zero, like with the int types. > I actually fe

Re: code generation for hash maps

2009-12-15 Thread Benson Margulies
My focus is at the moment on the colt-derived code. I'll report in when I get that far. On Tue, Dec 15, 2009 at 10:10 AM, Sean Owen wrote: > There are other solutions that aren't too expensive like maintaining a > bit set of entries that are valid (which is fast since it initializes > to all fals

Re: code generation for hash maps

2009-12-15 Thread Sean Owen
There are other solutions that aren't too expensive like maintaining a bit set of entries that are valid (which is fast since it initializes to all false/0). I've got a fast implementation in the code already. I'd prefer to not let the performance consideration convince us to not implement the sema

Re: code generation for hash maps

2009-12-15 Thread Benson Margulies
I had better be more clear. The problem is that Arrays.fill does use some time. If you just say new double[1000], you've got 0. To get NaN, you then need a fill. Last summer, when I was trying to get an E+M procedure to run in reasonable time, and trying to initialize many arrays with NaNs to dete

Re: code generation for hash maps

2009-12-15 Thread Sean Owen
NaN is my vote too from a correctness standpoint. Really, Arrays.fill() is unnaturally slow to fill in NaN? this sounds odd. Is it significant? On Tue, Dec 15, 2009 at 1:26 PM, Benson Margulies wrote: > My first reaction was to be opposed to checking in generated output, > but now I can't really

Re: code generation for hash maps

2009-12-15 Thread Benson Margulies
My first reaction was to be opposed to checking in generated output, but now I can't really think of a strong objection. A separate maven profile to enable the generator, and off we go. As to float and double, they may need to be special cases. Ask yourself: "What should get(k) return when contain

Re: code generation for hash maps

2009-12-15 Thread Grant Ingersoll
On Dec 14, 2009, at 11:38 PM, Sean Owen wrote: > I think both are desirable. Check in the generator and also the > generated code. It just keeps it simple. +1. This is what Lucene does w/ the QueryParser (JavaCC) and the Ant script detects when the two are out of sync and then regenerates. >

Re: code generation for hash maps

2009-12-14 Thread Sean Owen
I think both are desirable. Check in the generator and also the generated code. It just keeps it simple. On Tue, Dec 15, 2009 at 1:43 AM, Benson Margulies wrote: > The idea here is that the templates are checked in. The build process > goes template-to-java and then compiles the java. In other wo

Re: code generation for hash maps

2009-12-14 Thread Jake Mannix
On Mon, Dec 14, 2009 at 5:43 PM, Benson Margulies wrote: > If this is not acceptable, I'll just manually create all the classes. > It's just easier to keep them in sync if there's one source instead of > 16 to edit. (The presumption here is that all of 16 classes > {Byte,Char,Int,Long}x{Byte,Int,C

Re: code generation for hash maps

2009-12-14 Thread Benson Margulies
The idea here is that the templates are checked in. The build process goes template-to-java and then compiles the java. In other words, the java classes are not checked in and editable. If this is not acceptable, I'll just manually create all the classes. It's just easier to keep them in sync if t

Re: code generation for hash maps

2009-12-14 Thread Ted Dunning
not if there is editable and compilable source of some kind. On Mon, Dec 14, 2009 at 3:28 PM, Benson Margulies wrote: > The Trove people use a code generator to get all the variations of > IntByte, IntChar, IntInt, IntLong. Does anyone have strenuous > objections to this sort of thing? > -- T