private static DoubleWritable covertToDistance(DoubleWritable value){
  if (Math.abs(value.get()) > 0) {
    value.set((1.0 / value.get()) - 1.0);
  }
 else {
    value.set(Double.MAX_VALUE);
  }
  return value;
}

private static DoubleWritable covertToDistance ( DoubleWritable value ) { if ( Math . abs ( value . get ( ) ) > 0 ) { value . set ( ( 1.0 / value . get ( ) ) - 1.0 ) ; } else { value . set ( Double . MAX_VALUE ) ; } return value ; }
converts the [ 0 , 1 ] similarity value to a distance which takes values in [ 0 , inf ] .
