@Override public Object copyObject(Object o) { return o == null ? null : new LazyDouble((LazyDouble) o); }
/** * Calculates the hash code for array of Objects that contains writables. This is used * to work around the buggy Hadoop DoubleWritable hashCode implementation. This should * only be used for process-local hash codes; don't replace stored hash codes like bucketing. */ public static int writableArrayHashCode(Object[] keys) { if (keys == null) return 0; int hashcode = 1; for (Object element : keys) { hashcode = 31 * hashcode; if (element == null) { // nothing } else if (element instanceof LazyDouble) { long v = Double.doubleToLongBits(((LazyDouble) element).getWritableObject().get()); hashcode = hashcode + (int) (v ^ (v >>> 32)); } else if (element instanceof DoubleWritable) { long v = Double.doubleToLongBits(((DoubleWritable) element).get()); hashcode = hashcode + (int) (v ^ (v >>> 32)); } else if (element instanceof Object[]) { // use deep hashcode for arrays hashcode = hashcode + Arrays.deepHashCode((Object[]) element); } else { hashcode = hashcode + element.hashCode(); } } return hashcode; }
return new LazyFloat((LazyFloatObjectInspector) oi); case DOUBLE: return new LazyDouble((LazyDoubleObjectInspector) oi); case STRING: return new LazyString((LazyStringObjectInspector) oi);
throw new RuntimeException("Expected LazyDouble"); double value = ((LazyDouble) primitiveObject).getWritableObject().get(); double expected = ((DoubleWritable) expectedObject).get(); if (value != expected) {
@Override public Object copyObject(Object o) { return o == null ? null : new LazyDouble((LazyDouble) o); }
public static double asJavaDouble(@Nullable final Object o) { if (o == null) { throw new IllegalArgumentException(); } if (o instanceof Double) { return ((Double) o).doubleValue(); } if (o instanceof LazyDouble) { DoubleWritable d = ((LazyDouble) o).getWritableObject(); return d.get(); } if (o instanceof DoubleWritable) { return ((DoubleWritable) o).get(); } String s = o.toString(); return Double.parseDouble(s); }
@Override public Object copyObject(Object o) { return o == null ? null : new LazyDouble((LazyDouble) o); }
/** * Calculates the hash code for array of Objects that contains writables. This is used * to work around the buggy Hadoop DoubleWritable hashCode implementation. This should * only be used for process-local hash codes; don't replace stored hash codes like bucketing. */ public static int writableArrayHashCode(Object[] keys) { if (keys == null) return 0; int hashcode = 1; for (Object element : keys) { hashcode = 31 * hashcode; if (element == null) { // nothing } else if (element instanceof LazyDouble) { long v = Double.doubleToLongBits(((LazyDouble) element).getWritableObject().get()); hashcode = hashcode + (int) (v ^ (v >>> 32)); } else if (element instanceof DoubleWritable) { long v = Double.doubleToLongBits(((DoubleWritable) element).get()); hashcode = hashcode + (int) (v ^ (v >>> 32)); } else if (element instanceof Object[]) { // use deep hashcode for arrays hashcode = hashcode + Arrays.deepHashCode((Object[]) element); } else { hashcode = hashcode + element.hashCode(); } } return hashcode; }
@Override public Object copyObject(Object o) { return o == null ? null : new LazyDouble((LazyDouble) o); }
throw new RuntimeException("Expected LazyDouble"); double value = ((LazyDouble) primitiveObject).getWritableObject().get(); double expected = ((DoubleWritable) expectedObject).get(); if (value != expected) {
@Override public Object copyObject(Object o) { return o == null ? null : new LazyDouble((LazyDouble) o); }
@Override public Object copyObject(Object o) { return o == null ? null : new LazyDouble((LazyDouble) o); }
/** * Create a lazy primitive class given the type name. */ public static LazyPrimitive<?, ?> createLazyPrimitiveClass( PrimitiveObjectInspector oi) { PrimitiveCategory p = oi.getPrimitiveCategory(); switch (p) { case BOOLEAN: return new LazyBoolean((LazyBooleanObjectInspector) oi); case BYTE: return new LazyByte((LazyByteObjectInspector) oi); case SHORT: return new LazyShort((LazyShortObjectInspector) oi); case INT: return new LazyInteger((LazyIntObjectInspector) oi); case LONG: return new LazyLong((LazyLongObjectInspector) oi); case FLOAT: return new LazyFloat((LazyFloatObjectInspector) oi); case DOUBLE: return new LazyDouble((LazyDoubleObjectInspector) oi); case STRING: return new LazyString((LazyStringObjectInspector) oi); default: throw new RuntimeException("Internal error: no LazyObject for " + p); } }
return new LazyFloat((LazyFloatObjectInspector) oi); case DOUBLE: return new LazyDouble((LazyDoubleObjectInspector) oi); case STRING: return new LazyString((LazyStringObjectInspector) oi);
return new LazyFloat((LazyFloatObjectInspector) oi); case DOUBLE: return new LazyDouble((LazyDoubleObjectInspector) oi); case STRING: return new LazyString((LazyStringObjectInspector) oi);
return new LazyFloat((LazyFloatObjectInspector) oi); case DOUBLE: return new LazyDouble((LazyDoubleObjectInspector) oi); case STRING: return new LazyString((LazyStringObjectInspector) oi);
return new LazyFloat((LazyFloatObjectInspector) oi); case DOUBLE: return new LazyDouble((LazyDoubleObjectInspector) oi); case STRING: return new LazyString((LazyStringObjectInspector) oi);