Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Does in AP of the CAP theorm, is there a possibility (like in cassandra), that if i write/update to cassandra and immediately try to fetch it, can there a chance the data is not found or should my read o/p be paused before being fetched (hence allowing replications to settle in).
Can someone direct me to any link where people have addressed the consistency issue in cassandra.
Cassandra can be used to give the consistency that you describe. If the number of nodes you read from (R) plus the number of nodes you write to (W) is greater than the replication factor (N), you will read back a value immediately after it was written (assuming there are no concurrent writers who may write a later value in the small window since you wrote). So as long as R+W>N you will get this behaviour.
A common way to do this is to read and write at CL.QUORUM, since this gives you good availability. You could also e.g. read at CL.ONE and write at CL.ALL, but then writes will fail if a single node is down.
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
I am writing a report generation program in Java, with oracle DB. I have a stored procedure, that will retrieve one value at a time. From my Java Program I am calling the procedure repeatedly. In extreme case, I have to call the procedure 60,000 times. But it shows problems like, wrong value is returned after a specified calls (like 300 calls). kindly tell me how to sort out this.
Thanks.
Its not a good practice to call DB with such high frequency. You can use cursor in your stored procedure and fetch the required records at once. Check the link for reference Cursors in Oracle Stored Procedure
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
Improve this question
I have a xml reader which reads the title and the name of a person in java from a rss feed. I accomplish this by using document builder in java. When I read the element title and element name, I put them into a concurrent hashmap. This is fine, I can get the values from the map. However I want this information to be stored there for some time limit and not call the document builder until this time limit has passed. But the problem is when I do not call the document builder and refresh the webpage my hashmap values seem not to be stored. Code is in java and wicket.
Thoughts ?
It may be that every time you're refreshing the page a new hashmap is built and the old one is simply discarded. You should make sure your data stays persistent.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
Is there a similar syntax to Java's .hasNext() method in Ruby? I've been trying to get inputs in one line and then making it as integers and getting the absolute value.
It sounds like you want to see if there are more elements left in an iteration. Ruby's equivalent to that is peek:
From the docs:
Returns the next object in the enumerator, but doesn’t move the internal position forward. If the position is already at the end, StopIteration is raised.
But, in Ruby we usually rely on each or map to walk an iterable collection. There's no "figuring out" whether there's another element remaining, because Ruby does that for us.
ansh0l is right, gets is the most likely equivalent to hasNext() assuming that you're reading from the keyboard or any other I/O stream.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I want to print a lot of data to Stdout in the fastest possible way. One way is that I use a StringBuilder and keep appending the output to it and then print the stringbuffer. But sometimes this fails when the data to be printed is more than the maximum allowable size and gives Memory Limited Exceeded error. (for example in online judges). Is there some other better and faster way to print data?
You may try this:
try {
BufferedWriter log = new BufferedWriter(new OutputStreamWriter(System.out));
//.....
log.flush();
}
Although writing to a file directly will be more efficient
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
For a game I am writing, the world is saved as chunks. Each chunk (when saved) is just under 200kb (they are very large chunks). Whenever a world is loaded 121 chunks need to be loaded. Each one only takes a fraction of a second, but all those fractions add up and lead to taking several seconds.
This would be ok, but saving is even more important. When a player walks into new chunks, all the chunks out of range will be saved and unloaded. As each save takes a fraction of a second, I would get a lag spike of over a second every time the player moves chunks. For this reason, I hope to use Threads to save and load chunks so that a chunk can be saved/loaded while the game is still running.
I have no idea how I would implement such a thing though. So, if anyone could share a link to a tutorial or give some source code I could play with, that would be great!
Thanks!
I would use memory mapped files and I would load as much as possible in as few files as possible (each files adds an overhead)
If you do this you can load/save GB in a fraction of a second.