John Calabasas

Greenhorn
+ Follow
since Jun 11, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by John Calabasas

Many a time the engineers will need to work at the client site, and not in any facility owned by the sponsoring company. And companies like Infosys typically sponsor H1 visas for their own projects, nor for sending them to third party companies. Intra company transfer visas (L1) are also used when they have a registered office onsite.
17 years ago
I dont see any real case for Entity beans, and there are many alternate approaches like ORM tools. Maybe EJB3 makes it better.

When it comes to Session Beans, it make sense to use only in the following conditions.

1. Need to expose services remotely to other Java applications
2. Need to support transaction and security propagation from clients

MDBs however are quite useful if you have Async messaging in your application. I dont know of any alternatives considering the container support for the same w.r.to Transactions, Pooling, configurability etc. Of course we can have a MessageListener. But then it need to be managed programatically.
[ July 04, 2006: Message edited by: John Calabasas ]

Tmpfs is probably the best RAM disk-like system available for Linux right now, and is a new feature of kernel 2.4.



The above says it all. Its not even "cross-platform" within Linux versions. And I dont think this is related to Java by any means...
[ July 04, 2006: Message edited by: John Calabasas ]
18 years ago
See this thread on same issue...

Link

Also
Sun documentation
18 years ago
May be you can try double clicking the file if the extension is registered for a text file reader?

If you want to do it in single step, you can write a script to run the java progam and then invoke your text reader.



You can also invoke external programs from within the code using Runtime.exec()
[ July 04, 2006: Message edited by: John Calabasas ]
18 years ago
If its a file with line breaks and delimiters (ex, csv) between column values, I think it will be possible to use a combination of iterating over rows using readLine() and iterating over columns using Scanner.next() or String.split() or Regex to achieve the purpose. However this may not be a good approach in case the file is very big.

If the file contains fixed width columns, then you can try using RandomAccessFile.seek() to take you to the appropriate value using some math.

If its a delimited file which is not too big, another option will be to read and populate a 2-dim String Array from the file and read directly using the co-ords.
[ July 04, 2006: Message edited by: John Calabasas ]
18 years ago
Nose[] = new Nose[3];

This does not create an instance of Nose. And you cant create also, since its an interface.It just creates an array of Nose type.

Regarding returning int for iMethod(), it has the same effect of writing SOP in each of the implementations. This way we can avoid writing it for each class and make the caller decide what to do with the returned data.
18 years ago
Jim,

I have tried with the -server option in JVM which gave me a good 25% performance boost and also using Java 1.6 (Mustang) Beta which gave me another 10%. But still I find that indexOf() is faster with these options.

Here is the code. It is essentially the same that you suggested earlier. To avoid OOM, I am using a higher heap size (2gb) for now.


[ July 02, 2006: Message edited by: John Calabasas ]
18 years ago
Hi all,

I tried with doing a mini benchmarking exercise for comparing the performance of a searching a 1 gb text file using the method described here and also using String.indexOf(). Trial was done for about 15 different Strings as search param.


Using Regex and NIO:- 120 to 210 seconds
Using indexOf():- 70 to 100 seconds


As shown above, the results are not very encouraging and I find that in many cases, indexOf() performed atleast 25% faster. Also another thing I noticed with the approach here is that the time taken varies widely depending on the String that is used to search, whereas it was more or less consistent when using indexOf() method.

Hence I have doubt if using Regex patterns is the best way to search for plain strings in a large input. Please let me know your comments.

-John.
18 years ago
Jim,

I am very thankful to your help on this.

I think this program still loads the whole file into memory. I am facing OOM exceptions when trying with large files.

Is there anyway I can make this program work on files of any size?
Can I control the extend of file loaded into memory at any time?
Does using MemoryMappedBuffer help?

John.
[ July 01, 2006: Message edited by: John Calabasas ]
18 years ago
Thanks Jim for your suggestions. I tried the same thing and it seems to be much faster now. Exception handling was to be changed anyway.

I could not find much advantage for using the NIO though...
[ June 30, 2006: Message edited by: John Calabasas ]
18 years ago
Joe,

Thanks for the input. Yes my code works. But its slower than using String.indexOf() in all cases I have tested. Can you please help me optimize this code?

John
18 years ago
Thank you Joe. I am aware of regex patterns. My problem was trying to get the program run using the FileChannel and findWithinHorizon methods. I could not find any sample code on the usage of these APIs either.

Please see my sample code below. Not sure if this is the best way to do it.



John
[ June 29, 2006: Message edited by: John Calabasas ]
18 years ago
Jim,

Thanks a lot for the hints. I have tried by using FileChannel with Scanner. findWithinHorizon(pattern, horizon) method. However I could not get it right yet. I am also not sure of what the horizon parameter means. Its not seen documented in the Javadocs properly.

Could you please post a sampler code of the same?

Thanks
John
18 years ago