Examples of DefaultHCatRecord


Examples of org.apache.hcatalog.data.DefaultHCatRecord

      objList.add(i);
      objList.add("co strvalue" + i);
      objList.add("co str2value" + i);

      writeRecords.add(new DefaultHCatRecord(objList));
    }

    Map<String, String> partitionMap = new HashMap<String, String>();
    partitionMap.put("part1", "p1value8");


    Exception exc = null;
    try {
      runMRCreate(partitionMap, partitionColumns, writeRecords, 10,true);
    } catch(IOException e) {
      exc = e;
    }

    assertTrue(exc != null);
    assertTrue(exc instanceof HCatException);
    assertEquals(ErrorType.ERROR_SCHEMA_COLUMN_MISMATCH, ((HCatException) exc).getErrorType());


    partitionColumns = new ArrayList<HCatFieldSchema>();
    partitionColumns.add(HCatSchemaUtils.getHCatFieldSchema(new FieldSchema("c1", Constants.INT_TYPE_NAME, "")));
    partitionColumns.add(HCatSchemaUtils.getHCatFieldSchema(new FieldSchema("c2", Constants.STRING_TYPE_NAME, "")));

    writeRecords = new ArrayList<HCatRecord>();

    for(int i = 0;i < 10;i++) {
      List<Object> objList = new ArrayList<Object>();

      objList.add(i);
      objList.add("co strvalue" + i);

      writeRecords.add(new DefaultHCatRecord(objList));
    }

    runMRCreate(partitionMap, partitionColumns, writeRecords, 10,true);

    //Read should get 10 + 20 + 10 + 10 + 20 rows
View Full Code Here

Examples of org.apache.hcatalog.data.DefaultHCatRecord

      List<Object> objList = new ArrayList<Object>();

      objList.add(i);
      objList.add("strvalue" + i);
      objList.add(String.valueOf((i % mod)+offset));
      writeRecords.add(new DefaultHCatRecord(objList));
    }
  }
View Full Code Here

Examples of org.apache.hcatalog.data.DefaultHCatRecord

    for(int i = 0;i < 20;i++) {
      List<Object> objList = new ArrayList<Object>();

      objList.add(i);
      objList.add("strvalue" + i);
      writeRecords.add(new DefaultHCatRecord(objList));
    }

    partitionColumns = new ArrayList<HCatFieldSchema>();
    partitionColumns.add(HCatSchemaUtils.getHCatFieldSchema(new FieldSchema("c1", Constants.INT_TYPE_NAME, "")));
    partitionColumns.add(HCatSchemaUtils.getHCatFieldSchema(new FieldSchema("c2", Constants.STRING_TYPE_NAME, "")));
View Full Code Here

Examples of org.apache.hcatalog.data.DefaultHCatRecord

     */
    for(String colName : desiredColNames){
      Integer idx = dataSchema.getPosition(colName);
      hcatRecord.add( idx != null ? data.get(idx) : partVals.get(colName));
    }
    return new DefaultHCatRecord(hcatRecord);
  }
View Full Code Here

Examples of org.apache.hcatalog.data.DefaultHCatRecord

    @Override
    public void map(LongWritable key, Text value, Context context)
        throws IOException, InterruptedException {
      String[] cols = value.toString().split(",");
      HCatRecord record = new DefaultHCatRecord(recordSchema.size());
      System.out.println("TestMap/map called. Cols[0]:" + cols[0]);
      System.out.println("TestMap/map called. Cols[1]:" + cols[1]);
      System.out.println("TestMap/map called. Cols[2]:" + cols[2]);
      System.out.println("TestMap/map called. Cols[3]:" + cols[3]);
      record.setInteger("emp_id", recordSchema, Integer.parseInt(cols[0]));
      record.setString("emp_name", recordSchema, cols[1]);
      record.setString("emp_dob", recordSchema, cols[2]);
      record.setString("emp_sex", recordSchema, cols[3]);
      context.write(key, record);
    }
View Full Code Here

Examples of org.apache.hcatalog.data.DefaultHCatRecord

    int i = 0;
    for(HCatFieldSchema fSchema : computedSchema.getFields()){
      outgoing.add(getJavaObj(tuple.get(i++), fSchema));
    }
    try {
      writer.write(null, new DefaultHCatRecord(outgoing));
    } catch (InterruptedException e) {
      throw new BackendException("Error while writing tuple: "+tuple, PigHCatUtil.PIG_EXCEPTION_CODE, e);
    }
  }
View Full Code Here

Examples of org.apache.hcatalog.data.DefaultHCatRecord

    InputStream fInStream = new FileInputStream(f);
    DataInput inpStream = new DataInputStream(fInStream);

    for(int i =0; i < recs.length; i++){
      HCatRecord rec = new DefaultHCatRecord();
      rec.readFields(inpStream);
      Assert.assertEquals(recs[i],rec);
    }

    Assert.assertEquals(fInStream.available(), 0);
    fInStream.close();
View Full Code Here

Examples of org.apache.hcatalog.data.DefaultHCatRecord

    rec_1.add( new Double(5.3D));
    rec_1.add( new String("hcat and hadoop"));
    rec_1.add( null);
    rec_1.add( "null");

    HCatRecord tup_1 = new DefaultHCatRecord(rec_1);

    List<Object> rec_2 = new ArrayList<Object>(8);
    rec_2.add( new Byte("123"));
    rec_2.add( new Short("456"));
    rec_2.add( new Integer(789));
    rec_2.add( new Long(1000L));
    rec_2.add( new Double(5.3D));
    rec_2.add( new String("hcat and hadoop"));
    rec_2.add( null);
    rec_2.add( "null");
    HCatRecord tup_2 = new DefaultHCatRecord(rec_2);

    List<Object> rec_3 = new ArrayList<Object>(10);
    rec_3.add(new Byte("123"));
    rec_3.add(new Short("456"));
    rec_3.add( new Integer(789));
    rec_3.add( new Long(1000L));
    rec_3.add( new Double(5.3D));
    rec_3.add( new String("hcat and hadoop"));
    rec_3.add( null);
    List<Integer> innerList = new ArrayList<Integer>();
    innerList.add(314);
    innerList.add(007);
    rec_3.add( innerList);
    Map<Short, String> map = new HashMap<Short, String>(3);
    map.put(new Short("2"), "hcat is cool");
    map.put(new Short("3"), "is it?");
    map.put(new Short("4"), "or is it not?");
    rec_3.add(map);

    HCatRecord tup_3 = new DefaultHCatRecord(rec_3);

    List<Object> rec_4 = new ArrayList<Object>(8);
    rec_4.add( new Byte("123"));
    rec_4.add( new Short("456"));
    rec_4.add( new Integer(789));
    rec_4.add( new Long(1000L));
    rec_4.add( new Double(5.3D));
    rec_4.add( new String("hcat and hadoop"));
    rec_4.add( null);
    rec_4.add( "null");

    Map<Short, String> map2 = new HashMap<Short, String>(3);
    map2.put(new Short("2"), "hcat is cool");
    map2.put(new Short("3"), "is it?");
    map2.put(new Short("4"), "or is it not?");
    rec_4.add(map2);
    List<Integer> innerList2 = new ArrayList<Integer>();
    innerList2.add(314);
    innerList2.add(007);
    rec_4.add( innerList2);
    HCatRecord tup_4 = new DefaultHCatRecord(rec_4);

    return  new HCatRecord[]{tup_1,tup_2,tup_3,tup_4};

  }
View Full Code Here

Examples of org.apache.hcatalog.data.DefaultHCatRecord

      else {
        outList.add(partValues.get(colName));
      }

    }
    return new DefaultHCatRecord(outList);
  }
View Full Code Here

Examples of org.apache.hcatalog.data.DefaultHCatRecord

                              new Double(5.3D),
                              new String("hcatalog and hadoop"),
                              null,
                              null);

    HCatRecord tup_1 = new DefaultHCatRecord(rec_1);

    List<Object> rec_2 = new ArrayList<Object>(8);
    Collections.addAll(rec_2, new Byte("100"),
                              new Short("200"),
                              new Integer(123),
                              new Long(1000L),
                              new Double(5.3D),
                              new String("hcatalog and hadoop"),
                              null,
                              null);
    HCatRecord tup_2 = new DefaultHCatRecord(rec_2);

    return  new HCatRecord[]{tup_1,tup_2};
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.