Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
Take twissandra as an example, when a new tweet is received, not only the column family for the tweet need to be updated, but a few other (super) column families need to be updated. Definitely we can do this in sequential, on receiving the new tweet, to update each family one by one. But what if there are a dozen column families out there need to be updated? This doesn't seem to be an efficient approach to me. Is any other way, either relying on the programming framework (Java eg), or relying on other "utilities" like Message Queue, or a better programming model/design pattern to make this more scalable and maintainable?
Yes, you can use batch mutations to group together a set of updates. For example, in Hector, you can do something like:
mutator.addInsertion("jsmith", "Standard1",
HFactory.createStringColumn("first", "John"))
.addInsertion("jsmith", "Standard1", HFactory.createStringColumn("last", "Smith"))
.addInsertion("jsmith", "Standard1", HFactory.createStringColumn("middle", "Q"));
mutator.execute();
See https://github.com/rantav/hector/wiki/User-Guide under "Inserting Multiple Columns with Mutator".
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
While working on a Java web application I was wondering if my model layer was written as it should be. For instance, let's say we have a table USER in our SQL database which consists of 15 columns. Now, when we SELECT all of the columns with SQL we map it to a Java class, serialize via JSON and send it via network to some View and show it on screen.
In a second scenario, we want to select only 2 columns on screen so we do SELECT c1,c2 FROM USER. Thats where my question comes in... am I supposed to map those columns to a same Java model class? Or should i create a new mapper and class to fit it? Both of the approaches seem to have drawbacks, separate class for each query is more work, but it makes sure you always know what data it contains, rather than checking for nulls or working with optionals, also it prevents you from mapping columns you actually don't need.
What is your opinion? Thanks a lot!
Technically you could reuse the same User class for full 15-attribute as well as partial 2-attribute entity. But that will come with a price. Every time you'll see an instance of User class in the code your will have to think if it's the full entity or the partial? Which fields may or may not be null? This will make it much harder to reason about code.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
Hey guys, I'm having a doubt about the implementation of class diagram above, confused between the Single_table strategy and the joined_table strategy, any help, any suggestion about the patterns followed in this case that are used to enhance the response time of the login process.
Any help will be appreciated.
Thank you guys in advance :).
If I got you right your concern is whether to us a table User with a flag of different Professor etc. tables. Well, I'd go for the single table. Actually there is not much difference in performance. In order to retrieve the professors from the user table you would need a WHERE clause while a native table has the records ready. The time difference in any case would be near to null as a RDBMS will handle WHERE clauses very effectively granted the DBA has set good indices. A single table is easier to maintain with respect to maintaining all the columns you need (but which your class diagram currently does not show).
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have many records in to fetch and it could be in millions, I want to use hashmap, but I am not sure if that is ok or what would be the memory implications.
Please suggest
Thanks
VIvek
Welcome to StackExchange. A good place to start would be taking a look at this question:
Difference between HashMap, LinkedHashMap, and SortedMap in Java
HashMap is generally discouraged if you need to grab items in a specific order.
If you need to store 1,000,000+ records, you may want to look into an external database to store the information, as it will be memory consuming to hold all of the records.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I have near about 1 million entries in my database table and
I need to use some logic by which I can search within minimum time,
is there any algorithms or logic by which i can get result within less time.
I tried sorting table alphabetically but till it is taking much more time.
If you have any algorithm or logic then please suggest code in Java.
Looks like you need to ad in index to your database table.
If you tell what database you are using, people can give more specific help.
It dosent matter how much records you have as long as your databse is properly normalised and is having proper index. Having said that, the only difference that will make is how you are using indexes. You cannot do much in java, but your db and its design will play a significant role.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
The question is not too dificult: How do I best implement a table in Java.
I wish to have something like a table in a database. Named columns and numbered rows. My values are Integer.
My inital idea: LinkedHashMap<String, ArrayList<Integer>>
But is there a better way of doing it?
What do you mean by "better"? It depends on what do you need to do with that.
You may build
a 2-dimensional array and a map of column names (C++ way)
a list of objects, where each object is a row (the most Java way)
a Guava Table