Comment by user1944408 on Java Class.cast() vs. cast operator
I also use the second variant when I need Class<T> cls to be dynamic, for example if I use reflection but in all other cases I prefer the first one. Well I guess that's just a personal taste.
View ArticleComment by user1944408 on Do a IN in stored procedure with variable
That is risky because of SQL Injection.
View ArticleComment by user1944408 on Why shouldn't Java enum literals be able to have...
But then you could not do assignment like this MyEnum<Int> blabla = valueOf("some double property"); because the types are not compatible. Also you want in that case to get null because you want...
View ArticleComment by user1944408 on Why C# implements methods as non-virtual by default?
You said: "Having methods virtual by default means that every function in the class can be plugged out and replaced by another, which is not really a good thing." Why?
View ArticleComment by user1944408 on Thread-safe setting of a variable (Java)?
@Stephen: Check the source for String hashCode(). You will find hash=h which is considered thread safe without hash being volatile.
View ArticleComment by user1944408 on Should we @Override an interface's method...
This is not an answer to the question. Object is not an interface.
View ArticleComment by user1944408 on How to clean up ThreadLocals
Even if you use static ThreadLocal you can have a class loader leak when you redeploy your webapp if your value refer to some class loaded by the same class loader. It can happen if you use double...
View ArticleComment by user1944408 on ThreadLocal & Memory Leak
Sometimes people use a custom class in threadLocal value without even realizing that. For example it can happen when you use double brace initialization for your thread local value because double brace...
View ArticleComment by user1944408 on When and how should I use a ThreadLocal variable?
Just be careful not to use double brace initialization for your SimpleDateFormat because that would create an anonymous class so your class loader could not be garbage collected. memory leak: return...
View ArticleComment by user1944408 on How to identify and remove Threads/ThreadLocals...
If you use static ThreadLocal you will not have memory leak overtime but you will have a memory leak on stop/redeploy.
View ArticleComment by user1944408 on Why is Collections.unmodifiableList not defined to...
@khelwood Of course it would not prevent runtime exceptions in all cases but it will catch more bugs in compile time.
View ArticleAnswer by user1944408 for Eventualy consistent distributed database with...
Ok, I see that problem 2 has been resolved in cassandra https://issues.apache.org/jira/browse/CASSANDRA-1072Distributed counters will combine increase operations so everything will be consistent at the...
View ArticleEventualy consistent distributed database with idempotent increase operator?
Is there a distributed high availability, eventually consistent db that supports idempotent operation on scalar values?If we use normal updates then there is a possibility that we will have 2 different...
View ArticleCan I have rows ordered by key and partitioned randomly?
For example if I process a lot of transactions [timestamp (key), value, trader,..] I would like to have random partitioning for the sake of load balancing. But for the sake of queries I would like...
View ArticleWill cassandra support secondary indices which contain additional attributes...
Is there a possibility for a secondary index to contain another attributes beside key values? For example transaction key and transaction amount. In that way I could calculate everything I need by just...
View ArticleImpact of consistency level on performance
Is there a benchmark which shows the difference in write throughput when consistency level is ONE vs LOCAL_QUORUM? In both cases RF should be the same (e.g. RF=3)?P.S. I'm not interested in latency,...
View ArticleGet list of keys where column equals some value?
If I have secondary index on column STATUS I would like to get all keys (within some range) that have STATUS='processed'. How can I do that without reading any columns? I just need the list of keys so...
View ArticleConsistency strategy for two datacenters
What is the best write/read strategy that is fault tolerant and fast for reads when all nodes are up?I have 2 replicas in each datacenter and at first I was considering using QUORUM for writes and...
View ArticleAnswer by user1944408 for Atomically updating shared state in Cassandra
As Richard pointed out the best way at the moment is to use atomic batches where you update many deltas. If something goes wrong just replay the batch.The other possible solution is to use ZooKeeper as...
View ArticleAnswer by user1944408 for Oracle stored procedure using array as parameter...
insert into mytable(Name, phone)select name, phonefrom TABLE(v_my_data);
View ArticleAnswer by user1944408 for Relational vs Columnar and Document Databases -...
In no schema db you don't have fixed columns and types. For example product 'Jeans' can have attributes 'price', 'length' and 'model' (M/W) but for product book you have attributes 'price', 'authors'...
View ArticleAnswer by user1944408 for Non virtual methods in Java
Make it static.If you call a non-virtual method then you want to know from your code which class method you are calling. The flaw of .net is that you cannot know that from your code.ExampleIn Java if...
View ArticleAnswer by user1944408 for Why are methods virtual by default in Java, but...
There are 2 major reasons why virtual by default is so much better than non-virtual.The main principles about usefulness of OOP is Liskov substitution principle, polymorphism and late binding . I use...
View ArticleAnswer by user1944408 for Do a IN in stored procedure with variable
First you need to convert comma separated values into an varray and then use stmt := stmt || ' AND Risk.Code IN (select column_valuefrom TABLE(v_my_data))';One technique:...
View ArticleAnswer by user1944408 for How to identify and remove Threads/ThreadLocals...
If you use ThreadLocal in your code you could replace that ThreadLocal with ImrpovedThreadLocal that I made and you will not have a memory leak on stop/redeploy. You can use that threadLocal in the...
View ArticleAnswer by user1944408 for ThreadLocal garbage collection
Object b will not be subject for garbage collection if it somehow refers to your Test class. It can happen without your intention. For example if you have a code like this:public class Test { private...
View Article