Package org.apache.hadoop.vertica

Examples of org.apache.hadoop.vertica.VerticaRecord


  }

  private String recordTest(List<Integer> types, List<Object> values,
      DataOutputBuffer out, DataInputBuffer in, boolean date_string)
      throws IOException {
    VerticaRecord record = new VerticaRecord(null, types, values, date_string);

    // TODO: test values as hashmap of column names

    // write values into an output buffer
    record.write(out);

    // copy to an input buffer
    in.reset(out.getData(), out.getLength());

    // create a new record with new values
    List<Object> new_values = new ArrayList<Object>();
    record = new VerticaRecord(null, types, new_values, date_string);

    // read back into values
    record.readFields(in);

    // compare values
    for(int i = 0; i < values.size(); i++)
      if(values.get(i) == null) assertSame("Vertica Record serialized value " + i + " is null", values.get(i), new_values.get(i));
      else if(values.get(i).getClass().isArray()) {
        Object a = values.get(i);
        Object b = new_values.get(i);
        for(int j = 0; j < Array.getLength(a); j++)
          assertEquals("Vertica Record serialized value " + i + "[" + j + "] does not match", Array.get(a, j), Array.get(b, j));
      }
      else {
        assertEquals("Vertica Record serialized value " + i + " does not match", values.get(i), new_values.get(i));
      }

    // data in sql form
    return record.toSQLString();
  }
View Full Code Here


    boolean hasValue = reader.nextKeyValue();
    assertEquals("There should be a record in the database", hasValue, true);
   
    LongWritable key = reader.getCurrentKey();
    VerticaRecord value = reader.getCurrentValue();

    assertEquals("Key should be 1 for first record", key.get(), 1);
    assertEquals("Result type should be VARCHAR", ((Integer)value.getTypes().get(0)).intValue(), Types.VARCHAR);
    assertEquals("Result value should be three", value.getValues().get(0), "three");
    reader.close();
  }
View Full Code Here

        .getRecordWriter(context);

    Text table = new Text();
    table.set("mrtarget");

    VerticaRecord record = VerticaOutputFormat.getValue(job.getConfiguration());
    record.set(0, 125, true);
    record.set(1, true, true);
    record.set(2, 'c', true);
    record.set(3, Calendar.getInstance().getTime(), true);
    record.set(4, 234.526, true);
    record.set(5, Calendar.getInstance().getTime(), true);
    record.set(6, "foobar string", true);
    record.set(7, new byte[10], true);

    writer.write(table, record);
    writer.close(null);
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.vertica.VerticaRecord

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.