Package org.apache.hadoop.hive.serde2.io

Examples of org.apache.hadoop.hive.serde2.io.DoubleWritable


        ArrayList<String> fname = new ArrayList<String>();
        fname.add("count");
        fname.add("sum");
        partialResult = new Object[2];
        partialResult[0] = new LongWritable(0);
        partialResult[1] = new DoubleWritable(0);
        return ObjectInspectorFactory.getStandardStructObjectInspector(
            fname, foi);
       
      } else {
        result = new DoubleWritable(0);
        return PrimitiveObjectInspectorFactory.writableDoubleObjectInspector;
      }
    }
View Full Code Here


    super(PrimitiveObjectInspectorUtils.doubleTypeEntry);
  }
 
  @Override
  public Object getPrimitiveWritableObject(Object o) {
    return o == null ? null : new DoubleWritable(((Double)o).doubleValue());
  }
View Full Code Here

        fname.add("sum");
        fname.add("variance");
       
        partialResult = new Object[3];
        partialResult[0] = new LongWritable(0);
        partialResult[1] = new DoubleWritable(0);
        partialResult[2] = new DoubleWritable(0);
       
        return ObjectInspectorFactory.getStandardStructObjectInspector(
            fname, foi);
       
      } else {
        result = new DoubleWritable(0);
        return PrimitiveObjectInspectorFactory.writableDoubleObjectInspector;
      }
    }
View Full Code Here

      // Data
      Text t = new Text("123\t456\t789\t1000\t5.3\thive and hadoop\t1.\ta\tb\t");
      String s = "123\t456\t789\t1000\t5.3\thive and hadoop\tNULL\ta";
      Object[] expectedFieldsData = { new ByteWritable((byte)123),
          new ShortWritable((short)456), new IntWritable(789),
          new LongWritable(1000), new DoubleWritable(5.3), new Text("hive and hadoop"), null,
          new Text("a")
      };
     
      // Test
      deserializeAndSerialize(serDe, t, s, expectedFieldsData);
View Full Code Here

      // Data
      Text t = new Text("123\t456\t789\t1000\t5.3\t");
      String s = "123\t456\t789\t1000\t5.3\t\tNULL\tNULL";
      Object[] expectedFieldsData = { new ByteWritable((byte)123),
          new ShortWritable((short)456), new IntWritable(789),
          new LongWritable(1000), new DoubleWritable(5.3), new Text(""), null,
          null
      };
     
      // Test
      deserializeAndSerialize(serDe, t, s, expectedFieldsData);
View Full Code Here

    try {
      LazyDouble b = new LazyDouble(LazyPrimitiveObjectInspectorFactory.lazyDoubleObjectInspector);
      initLazyObject(b,new byte[]{'0'}, 0, 0);
      assertNull(b.getWritableObject());
      initLazyObject(b,new byte[]{'0'}, 0, 1);
      assertEquals(new DoubleWritable((double)0), b.getWritableObject());
      initLazyObject(b,new byte[]{'+', '0'}, 0, 2);
      assertEquals(new DoubleWritable((double)0), b.getWritableObject());
      initLazyObject(b,new byte[]{'-', '0'}, 0, 2);
      assertEquals(new DoubleWritable((double)-0.0), b.getWritableObject());
      initLazyObject(b,new byte[]{'a', '1', 'b'}, 1, 1);
      assertEquals(new DoubleWritable((double)1), b.getWritableObject());
      initLazyObject(b,new byte[]{'a', '-', '1'}, 1, 2);
      assertEquals(new DoubleWritable((double)-1), b.getWritableObject());
      initLazyObject(b,new byte[]{'a', '+', '1'}, 1, 2);
      assertEquals(new DoubleWritable((double)1), b.getWritableObject());
      initLazyObject(b,new byte[]{'-', '1', '2', '8'}, 0, 4);
      assertEquals(new DoubleWritable((double)-128), b.getWritableObject());
      initLazyObject(b,new byte[]{'+', '1', '2', '7'}, 0, 4);
      assertEquals(new DoubleWritable((double)127), b.getWritableObject());
      initLazyObject(b,new byte[]{'-', '3', '2', '7', '6', '8'}, 0, 6);
      assertEquals(new DoubleWritable((double)-32768), b.getWritableObject());
      initLazyObject(b,new byte[]{'+', '3', '2', '7', '6', '7'}, 0, 6);
      assertEquals(new DoubleWritable((double)32767), b.getWritableObject());
      initLazyObject(b,new byte[]{'-', '2', '1', '4', '7', '4', '8', '3', '6', '4', '8'}, 0, 11);
      assertEquals(new DoubleWritable((double)-2147483648), b.getWritableObject());
      initLazyObject(b,new byte[]{'+', '2', '1', '4', '7', '4', '8', '3', '6', '4', '7'}, 0, 11);
      assertEquals(new DoubleWritable((double)2147483647), b.getWritableObject());
      initLazyObject(b,new byte[]{'-', '9', '2', '2', '3', '3', '7', '2', '0', '3', '6', '8', '5',
          '4', '7', '7', '5', '8', '0', '8'}, 0, 20);
      assertEquals(new DoubleWritable((double)-9223372036854775808L), b.getWritableObject());
      initLazyObject(b,new byte[]{'+', '9', '2', '2', '3', '3', '7', '2', '0', '3', '6', '8', '5',
          '4', '7', '7', '5', '8', '0', '7'}, 0, 20);
      assertEquals(new DoubleWritable((long)9223372036854775807L), b.getWritableObject());

      initLazyObject(b,new byte[]{'-', '3', '.', '7', '6', '8'}, 0, 6);
      assertEquals(new DoubleWritable((double)-3.768), b.getWritableObject());
      initLazyObject(b,new byte[]{'+', '3', '.', '7', '6', '7'}, 0, 6);
      assertEquals(new DoubleWritable((double)3.767), b.getWritableObject());
      initLazyObject(b,new byte[]{'-', '2', '.', '4', '7', '4', '8', '3', '6', 'e', '8'}, 0, 11);
      assertEquals(new DoubleWritable((double)-2.474836e8), b.getWritableObject());
      initLazyObject(b,new byte[]{'+', '2', '.', '4', '7', '4', '8', '3', 'E', '-', '7'}, 0, 11);
      assertEquals(new DoubleWritable((double)2.47483E-7), b.getWritableObject());
      initLazyObject(b,new byte[]{'-', '.', '4', '7', '4', '8', '3', '6', 'e', '8'}, 0, 10);
      assertEquals(new DoubleWritable((double)-.474836e8), b.getWritableObject());
      initLazyObject(b,new byte[]{'+', '.', '4', '7', '4', '8', '3', 'E', '-', '7'}, 0, 10);
      assertEquals(new DoubleWritable((double).47483E-7), b.getWritableObject());
      initLazyObject(b,new byte[]{'-', '2', '1', '4', '7', '4', '8', '3', '6', '4', '.'}, 0, 11);
      assertEquals(new DoubleWritable((double)-214748364.), b.getWritableObject());
      initLazyObject(b,new byte[]{'+', '2', '1', '4', '7', '4', '8', '3', '6', '4', '.'}, 0, 11);
      assertEquals(new DoubleWritable((double)+214748364.), b.getWritableObject());

      initLazyObject(b,new byte[]{'.', '0'}, 0, 2);
      assertEquals(new DoubleWritable((double).0), b.getWritableObject());
      initLazyObject(b,new byte[]{'0', '.'}, 0, 2);
      assertEquals(new DoubleWritable((double)0.), b.getWritableObject());
     
      initLazyObject(b,new byte[]{'a', '1', 'b'}, 1, 2);
      assertNull(b.getWritableObject());
      assertNull(b.getWritableObject());
      initLazyObject(b,new byte[]{'.', '1', '2', '3'}, 0, 1);
      assertNull(b.getWritableObject());
      initLazyObject(b,new byte[]{'-', '1', '2', '3'}, 0, 1);
      assertNull(b.getWritableObject());
      initLazyObject(b,new byte[]{'+', '1', '2', '3'}, 0, 1);
      assertNull(b.getWritableObject());
     
      initLazyObject(b,new byte[]{'-', '1', 'e', '3', '3', '3', '3', '3', '3'}, 0, 9);
      assertEquals(new DoubleWritable(Double.NEGATIVE_INFINITY), b.getWritableObject());
      initLazyObject(b,new byte[]{'+', '1', 'e', '3', '3', '3', '3', '3', '3'}, 0, 9);
      assertEquals(new DoubleWritable(Double.POSITIVE_INFINITY), b.getWritableObject());

      initLazyObject(b,new byte[]{'+', '1', 'e', '-', '3', '3', '3', '3', '3'}, 0, 8);
      assertEquals(new DoubleWritable((double)0), b.getWritableObject());
      initLazyObject(b,new byte[]{'-', '1', 'e', '-', '3', '3', '3', '3', '3'}, 0, 8);
      assertEquals(new DoubleWritable((double)-0.0), b.getWritableObject());
     
    } catch (Throwable e) {
      e.printStackTrace();
      throw e;
    }
View Full Code Here

      // Double
      Converter doubleConverter = ObjectInspectorConverters.getConverter(
          PrimitiveObjectInspectorFactory.javaIntObjectInspector,
          PrimitiveObjectInspectorFactory.writableDoubleObjectInspector);
      assertEquals("DoubleConverter",
          new DoubleWritable((double)0),
          doubleConverter.convert(Integer.valueOf(0))
          );
      assertEquals("DoubleConverter",
          new DoubleWritable((double)1),
          doubleConverter.convert(Integer.valueOf(1))
          );
     
      // Text
      Converter textConverter = ObjectInspectorConverters.getConverter(
View Full Code Here

    return ((DoubleWritable)o).get();
  }

  @Override
  public Object copyObject(Object o) {
    return o == null ? null : new DoubleWritable(((DoubleWritable)o).get());
  }
View Full Code Here

    return o == null ? null : Double.valueOf(((DoubleWritable)o).get());
  }

  @Override
  public Object create(double value) {
    return new DoubleWritable(value);
  }
View Full Code Here

    @Override
    public ObjectInspector init(Mode m, ObjectInspector[] parameters)
        throws HiveException {
      assert(parameters.length == 1);
      super.init(m, parameters);
      result = new DoubleWritable(0);
      inputOI = (PrimitiveObjectInspector)parameters[0];
      return PrimitiveObjectInspectorFactory.writableDoubleObjectInspector;
    }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hive.serde2.io.DoubleWritable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.