Exemplo n.º 1
0
  @SuppressWarnings("serial")
  public void testExample() throws Exception {
    if (!AllTests.isSetup()) {
      return;
    }

    Job job = getJob();
    VerticaInputFormat.setInput(job, "select * from mrsource");
    job.waitForCompletion(true);

    job = getJob();
    VerticaInputFormat.setInput(
        job, "select * from mrsource where key = ?", "select distinct key from mrsource");
    job.waitForCompletion(true);

    job = getJob();
    Collection<List<Object>> params = new HashSet<List<Object>>() {};
    List<Object> param = new ArrayList<Object>();
    param.add(new Integer(0));
    params.add(param);
    VerticaInputFormat.setInput(job, "select * from mrsource where key = ?", params);
    job.waitForCompletion(true);

    job = getJob();
    VerticaInputFormat.setInput(job, "select * from mrsource where key = ?", "0", "1", "2");
    job.waitForCompletion(true);

    VerticaOutputFormat.optimize(job.getConfiguration());
  }
Exemplo n.º 2
0
 public void setup(Context context) throws IOException, InterruptedException {
   super.setup(context);
   try {
     record = VerticaOutputFormat.getValue(context.getConfiguration());
   } catch (Exception e) {
     throw new IOException(e);
   }
 }
Exemplo n.º 3
0
  public Job getJob() throws IOException {
    Configuration conf = new Configuration(true);
    Cluster cluster = new Cluster(conf);
    Job job = Job.getInstance(cluster);

    conf = job.getConfiguration();
    conf.set("mapreduce.job.tracker", "local");

    job.setJarByClass(TestExample.class);
    job.setJobName("vertica test");

    job.setOutputKeyClass(Text.class);
    job.setOutputValueClass(VerticaRecord.class);
    job.setInputFormatClass(VerticaInputFormat.class);
    job.setOutputFormatClass(VerticaOutputFormat.class);
    job.setMapOutputKeyClass(Text.class);
    job.setMapOutputValueClass(DoubleWritable.class);
    job.setMapperClass(Map.class);
    job.setReducerClass(Reduce.class);
    VerticaOutputFormat.setOutput(
        job,
        "mrtarget",
        true,
        "a int",
        "b boolean",
        "c char(1)",
        "d date",
        "f float",
        "t timestamp",
        "v varchar",
        "z varbinary");
    VerticaConfiguration.configureVertica(
        conf,
        new String[] {AllTests.getHostname()},
        AllTests.getDatabase(),
        AllTests.getUsername(),
        AllTests.getPassword());
    return job;
  }