mayank gupta

Ranch Hand
+ Follow
since Dec 21, 2008
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by mayank gupta


My job is to get details like the mac address of the android phone and other configuration details. I dont know where to get started.
How can I fetch the details?
Do I have to download the Eclipse IDE and write code to fetch the data?

Write now I dont have an android phone, but will get it soon.

Please help for getting started.
12 years ago
Can anybody please suggest? I am not able to run my code beyond 3 million.
No matter how much I increase the heap size, I keep getting the error.
What is the significance of the minimum heap size? How much should that be?

Thank you for the input. I am running my program on a machine with 8 cores and 12GB RAM. When i increase the number of entries in the hashtable to more than 1 million, I get a
java.lang.OutOfMemoryError Exception. I am using <Integers, Integer> in the Hashtable and the size of each row/entry is 58 Bytes. With 5 million entries the size of the hashtable will be 290MB. I increased the heap size as: -Xms300m -Xmx500m but I still get the OutOfMemory Error. What could the problem be and how can I resolve it?
I got the solution, Had not closed the socket in the first acsess,
12 years ago
I also get sock.isConnected() true and sock.isClosed() also as true.
12 years ago

I get an IOException when I run my program. I am first opening a socket connection and then trying to do a . The exception occurs at this point.
It is twice that the executes this piece of code which creates a connection and calls the getOutputStream. The first time it executes fine, the second time i get an exception.
Before getting the output stream i check whether the socket is not null and it is connected. And even though the sock is not null and is connected but when it reaches the line getOutputStream, it throws an exception.

Can you please help me with the reasons why an IO excepton would occur when trying to get the output stream?
12 years ago
Do you actually think having a hastable is better than having a DB?
The hashtable will have 17 digits in a row, that means 17*100 million approx 1.7GB of RAM.
I do have a larger RAM size on my machine.

Why do you say that

If it has to page to disk, you might as well not be caching.

I want to minimize the disk i/o that is why I want the hashtable in cache. When an update happens (which is very infrequent), I update the table on the disk and then cache it.

Also, how do I cache the Properties/Hashtable? By running the program once? Is there any way to make sure that the table remains cached?

I will also look at the nosql databases.
I want to create a table in a database. The table should have a key and a value. The table should have entries around 100million but each row is just a 10 digit key and a 7 digit value corresponding to it. I want to load the database in memory.

Instead of using a database table, I have been asked to create a hashtable from the table in the db, on server start up. And load the hashtable in the memory.
I wanted to just use mysql for it but then I was told that no matter how much i optimize it, each query will still have to go through a query processor.
And becuase my query will be just a look up and nothing more complex so
if I create a hashtable in java and load it in memory that overhead could be avoided.

Do you think having a hastable in memory is a better idea than using a database table in mysql?
Also how can i make sure that the hashtable remains cached at all instances?

Otherwise the only control you would have when waiting would be killing the entire process.

Could you please explain this in a little more detail. Maybe with an example.
I have to write an application for an entity where a state machine is maintained, so essentially, I can go from one state to the other only if the previous one is completed.
If the state is 1 a request is sent to the server. the client wait for the reply to come, only then does the client transitions to state 2. Is there any point in implementing the client using threads?

Thank you.
I finally did use MultiKey from the commons collections.
12 years ago
If I store them in a ArrayList, i will have to retrieve it using an index. I want to retrieve 'message' using the combination of 'type' and 'code'
12 years ago

I want to know what data structure to use in this case:
I have three values Type, Code and message. The combination of type, code is unique. I cannot use maps here, i realised.
The values of Type, Code and Message can be as follows <0200, 011, M1><0210, 011, M2> <0200, 033, M3> <0210, 033, M4>
Each time I want to retrieve the Messages using the values of both Type and Code.
Please suggest.
12 years ago
Thank you for the suggestion. I will try it and get back with the results.