[ 
https://issues.apache.org/jira/browse/CASSANDRA-19426?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ling Mao updated CASSANDRA-19426:
---------------------------------
    Description: 
_*issue-1:*_

if liveEndpoints.size()=unreachableEndpoints.size()=0; probability will be 
{_}Infinity{_}.
randDbl <= probability will always be true, then sendGossip

_*issue-2:*_ 

comparing two double is safe by using < or >. However missing accuracy will 
happen if we compare the equlity of two double by intuition(=). For example:

 
{code:java}
double probability = 0.1;
double randDbl = 0.10000000000000001; // Slightly greater than probability
if (randDbl <= probability)
{
    System.out.println("randDbl <= probability(always here)");
}
else
{
    System.out.println("randDbl > probability");
}
{code}
 

A good example from: _*Gossiper#maybeGossipToUnreachableMember*_
{code:java}
if (randDbl < prob)
{
sendGossip(message, Sets.filter(unreachableEndpoints.keySet(),
                                ep -> 
!isDeadState(getEndpointStateMap().get(ep))));
}{code}

  was:I'll write a PR tonight


> Fix Double Type issues in the Gossiper#maybeGossipToCMS
> -------------------------------------------------------
>
>                 Key: CASSANDRA-19426
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-19426
>             Project: Cassandra
>          Issue Type: Improvement
>            Reporter: Ling Mao
>            Assignee: Ling Mao
>            Priority: Low
>
> _*issue-1:*_
> if liveEndpoints.size()=unreachableEndpoints.size()=0; probability will be 
> {_}Infinity{_}.
> randDbl <= probability will always be true, then sendGossip
> _*issue-2:*_ 
> comparing two double is safe by using < or >. However missing accuracy will 
> happen if we compare the equlity of two double by intuition(=). For example:
>  
> {code:java}
> double probability = 0.1;
> double randDbl = 0.10000000000000001; // Slightly greater than probability
> if (randDbl <= probability)
> {
>     System.out.println("randDbl <= probability(always here)");
> }
> else
> {
>     System.out.println("randDbl > probability");
> }
> {code}
>  
> A good example from: _*Gossiper#maybeGossipToUnreachableMember*_
> {code:java}
> if (randDbl < prob)
> {
> sendGossip(message, Sets.filter(unreachableEndpoints.keySet(),
>                                 ep -> 
> !isDeadState(getEndpointStateMap().get(ep))));
> }{code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to