Examples of HCatRecord


Examples of org.apache.hcatalog.data.HCatRecord


  @Override
  public Tuple getNext() throws IOException {
    try {
      HCatRecord hr =  (HCatRecord) (reader.nextKeyValue() ? reader.getCurrentValue() : null);
      Tuple t = PigHCatUtil.transformToTuple(hr,outputSchema);
      // TODO : we were discussing an iter interface, and also a LazyTuple
      // change this when plans for that solidifies.
      return t;
    } catch (ExecException e) {
View Full Code Here

Examples of org.apache.hcatalog.data.HCatRecord

    HCatRecord[] tuples = getExpectedRecords();
    for(int j=0; j < 2; j++){
      Assert.assertTrue(rr.nextKeyValue());
      BytesRefArrayWritable w = (BytesRefArrayWritable)rr.getCurrentValue();
      Assert.assertEquals(bytesArr[j], w);
      HCatRecord t = sd.convertToHCatRecord(null,w);
      Assert.assertEquals(8, t.size());
      Assert.assertEquals(t,tuples[j]);
    }
  }
View Full Code Here

Examples of org.apache.hcatalog.data.HCatRecord

    for(int j=0; j < 2; j++){
      Assert.assertTrue(rr.nextKeyValue());
      BytesRefArrayWritable w = (BytesRefArrayWritable)rr.getCurrentValue();
      Assert.assertFalse(bytesArr[j].equals(w));
      Assert.assertEquals(w.size(), 8);
      HCatRecord t = sd.convertToHCatRecord(null,w);
      Assert.assertEquals(5, t.size());
      Assert.assertEquals(t,tuples[j]);
    }
    assertFalse(rr.nextKeyValue());
  }
View Full Code Here

Examples of org.apache.hcatalog.data.HCatRecord

    for(int j=0; j < 2; j++){
      Assert.assertTrue(rr.nextKeyValue());
      BytesRefArrayWritable w = (BytesRefArrayWritable)rr.getCurrentValue();
      Assert.assertFalse(bytesArr[j].equals(w));
      Assert.assertEquals(w.size(), 8);
      HCatRecord t = sd.convertToHCatRecord(null,w);
      Assert.assertEquals(7, t.size());
      Assert.assertEquals(t,tuples[j]);
    }
    assertFalse(rr.nextKeyValue());
  }
View Full Code Here

Examples of org.apache.hcatalog.data.HCatRecord

                              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

Examples of org.apache.hcatalog.data.HCatRecord

    Collections.addAll(rec_1, new Byte("123"),
        new Integer(789),
        new Double(5.3D),
        new String("hcatalog and hadoop"),
        null);
    HCatRecord tup_1 = new DefaultHCatRecord(rec_1);

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

    return  new HCatRecord[]{tup_1,tup_2};
  }
View Full Code Here

Examples of org.apache.hcatalog.data.HCatRecord

                               new Double(5.3D),
                               null, // new column
                               new String("hcatalog and hadoop"),
                               new Byte("123"),
                               null);
    HCatRecord tup_1 = new DefaultHCatRecord(rec_1);

    List<Object> rec_2 = new ArrayList<Object>(7);
    Collections.addAll(rec_2, new Integer(123),
        new String("first-part"),
        new Double(5.3D),
        null,
        new String("hcatalog and hadoop"),
        new Byte("100"),
        null);
    HCatRecord tup_2 = new DefaultHCatRecord(rec_2);

    return  new HCatRecord[]{tup_1,tup_2};

  }
View Full Code Here

Examples of org.apache.hcatalog.data.HCatRecord

      bytesWritable.set(i, cu);
    }

    //Convert byte array to HCatRecord using isd, convert hcatrecord back to byte array
    //using osd, compare the two arrays
    HCatRecord record = isd.convertToHCatRecord(null, bytesWritable);

    HCatOutputStorageDriver osd = new RCFileOutputDriver();

    osd.setSchema(jc, schema);
    osd.initialize(jc, new Properties());
View Full Code Here

Examples of org.apache.hcatalog.data.HCatRecord

  }

  private HCatRecord convertToHCatRecord(SqoopRecord sqr)
    throws IOException {
    Map<String, Object> fieldMap = sqr.getFieldMap();
    HCatRecord result = new DefaultHCatRecord(fieldCount);

    for (Map.Entry<String, Object> entry : fieldMap.entrySet()) {
      String key = entry.getKey();
      Object val = entry.getValue();
      String hfn = key.toLowerCase();
      if (staticPartitionKey != null && staticPartitionKey.equals(hfn)) {
        continue;
      }
      HCatFieldSchema hfs = hCatFullTableSchema.get(hfn);
      if (debugHCatImportMapper) {
        LOG.debug("SqoopRecordVal: field = " + key + " Val " + val
          + " of type " + (val == null ? null : val.getClass().getName())
          + ", hcattype " + hfs.getTypeString());
      }
      Object hCatVal = toHCat(val, hfs.getType(), hfs.getTypeString());

      result.set(hfn, hCatFullTableSchema, hCatVal);
    }

    return result;
  }
View Full Code Here

Examples of org.apache.hcatalog.data.HCatRecord

    public static class MapHCatWrite extends Mapper<LongWritable, Text, BytesWritable, HCatRecord> {

        @Override
        public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
            OutputJobInfo jobInfo = (OutputJobInfo) HCatUtil.deserialize(context.getConfiguration().get(HCatConstants.HCAT_KEY_OUTPUT_INFO));
            HCatRecord record = new DefaultHCatRecord(3);
            HCatSchema schema = jobInfo.getOutputSchema();
            String vals[] = value.toString().split(",");
            record.setInteger("key", schema, Integer.parseInt(vals[0]));
            for (int i = 1; i < vals.length; i++) {
                String pair[] = vals[i].split(":");
                record.set(pair[0], schema, pair[1]);
            }
            context.write(null, record);
        }
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.