Package co.nubetech.hiho.mapreduce.lib.db

Examples of co.nubetech.hiho.mapreduce.lib.db.GenericDBWritable


        values.add(s);
      if (i == 3)
        values.add(Float.valueOf(s));
    }

    GenericDBWritable gdw = new GenericDBWritable(columnInfo, values);

    context.write(gdw, gdw);

  }
View Full Code Here


      }
    } else {
      throw new IOException(
          "Number of columns specified in table is not equal to the columns contains in the file.");
    }
    GenericDBWritable gdw = new GenericDBWritable(tableInfo, values);
    context.write(gdw, null);

  }
View Full Code Here

    values.add(new Float(1.0f));
    values.add('a');
    values.add(new Time(new Date().getTime()));
    values.add(new Time(new Date().getTime()));

    GenericDBWritable val = new GenericDBWritable(columns, values);
    LongWritable key = new LongWritable(1);

    Schema pairSchema = DBMapper.getPairSchema(val.getColumns());
    Schema keySchema = Pair.getKeySchema(pairSchema);
    Schema valueSchema = Pair.getValueSchema(pairSchema);
    Pair pair = new Pair<GenericRecord, GenericRecord>(pairSchema);

    GenericRecord keyRecord = new GenericData.Record(keySchema);
    keyRecord.put(0, key.get());
    GenericRecord valueRecord = new GenericData.Record(valueSchema);
    List<Schema.Field> fieldSchemas = valueSchema.getFields();
    for (int i = 0; i < val.getValues().size(); ++i) {
      Schema.Type type = fieldSchemas.get(i).schema().getType();
      if (type.equals(Schema.Type.STRING)) {
        Utf8 utf8 = new Utf8((String) val.getValues().get(i).toString());
        valueRecord.put(i, utf8);
      } else {
        valueRecord.put(i, val.getValues().get(i));
      }
    }
    pair.key(keyRecord);
    pair.value(valueRecord);
View Full Code Here

    // values.add(new Float(1.0f));
    values.add('a');
    values.add(new Time(new Date().getTime()));
    values.add(new Time(new Date().getTime()));

    GenericDBWritable val = new GenericDBWritable(columns, values);
    LongWritable key = new LongWritable(1);

    Schema pairSchema = DBMapper.getPairSchema(val.getColumns());
    Schema keySchema = Pair.getKeySchema(pairSchema);

    GenericRecord keyRecord = new GenericData.Record(keySchema);
    keyRecord.put(0, key.get());
    assertEquals(keyRecord,mapper.getKeyRecord(keySchema, key));
View Full Code Here

    // values.add(new Float(1.0f));
    values.add('a');
    values.add(new Time(new Date().getTime()));
    values.add(new Time(new Date().getTime()));

    GenericDBWritable val = new GenericDBWritable(columns, values);
    LongWritable key = new LongWritable(1);

    Schema pairSchema = DBMapper.getPairSchema(val.getColumns());
    Schema keySchema = Pair.getKeySchema(pairSchema);
    Schema valueSchema = Pair.getValueSchema(pairSchema);
   
    GenericRecord valueRecord = new GenericData.Record(valueSchema);
    List<Schema.Field> fieldSchemas = valueSchema.getFields();
    for (int i = 0; i < val.getValues().size(); ++i) {
      Schema.Type type = fieldSchemas.get(i).schema().getType();
      if (type.equals(Schema.Type.STRING)) {
        Utf8 utf8 = new Utf8((String) val.getValues().get(i).toString());
        valueRecord.put(i, utf8);
      } else {
        valueRecord.put(i, val.getValues().get(i));
      }
    }
   
    assertEquals(valueRecord,mapper.getValueRecord(valueSchema, val));
  }
View Full Code Here

    ColumnInfo stringColumn = new ColumnInfo(1, Types.VARCHAR,
        "stringColumn");
    ArrayList<ColumnInfo> columns = new ArrayList<ColumnInfo>();
    columns.add(intColumn);
    columns.add(stringColumn);
    GenericDBWritable writable = new GenericDBWritable(columns, null);
    assertEquals("intColumn:int,stringColumn:chararray",
        PigUtility.getColumns(writable));
  }
View Full Code Here

    ColumnInfo stringColumn = new ColumnInfo(1, Types.VARCHAR,
        "stringColumn");
    ArrayList<ColumnInfo> columns = new ArrayList<ColumnInfo>();
    columns.add(intColumn);
    columns.add(stringColumn);
    GenericDBWritable writable = new GenericDBWritable(columns, null);
    assertEquals(
        "A = LOAD '/home/sgoyal/output' USING PigStorage(',') AS (intColumn:int,stringColumn:chararray);",
        PigUtility.getLoadScript("/home/sgoyal/output", writable));
  }
View Full Code Here

    ArrayList values = new ArrayList();
    values.add(1l);
    values.add("Sam");
    values.add(true);
    values.add(84.0);
    GenericDBWritable gdw = new GenericDBWritable(tableInfo, values);
    verify(context).write(gdw, null);

  }
View Full Code Here

    ArrayList values = new ArrayList();
    values.add(1l);
    values.add(null);
    values.add(true);
    values.add(84.0);
    GenericDBWritable gdw = new GenericDBWritable(tableInfo, values);
    verify(context).write(gdw, null);

  }
View Full Code Here

TOP

Related Classes of co.nubetech.hiho.mapreduce.lib.db.GenericDBWritable

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.