Example #1
0
  private void initializeInstance(
      String delimiter,
      String multilineTreatmentStr,
      String eolTreatmentStr,
      String headerTreatmentStr) {
    fieldDelimiter = StorageUtil.parseFieldDel(delimiter);

    multilineTreatment = canonicalizeMultilineTreatmentRequest(multilineTreatmentStr);
    eolTreatment = canonicalizeEOLTreatmentRequest(eolTreatmentStr);
    headerTreatment = canonicalizeHeaderTreatmentRequest(headerTreatmentStr);
  }
Example #2
0
  @Override
  public byte[] serialize(Tuple t) throws IOException {
    out.reset();
    int sz = t.size();
    for (int i = 0; i < sz; i++) {
      Object field = t.get(i);

      StorageUtil.putField(out, field);

      if (i == sz - 1) {
        // last field in tuple.
        out.write(recordDel);
      } else {
        out.write(fieldDel);
      }
    }
    return out.toByteArray();
  }
Example #3
0
 @Override
 public Tuple deserialize(byte[] bytes) throws IOException {
   Text val = new Text(bytes);
   return StorageUtil.textToTuple(val, fieldDel);
 }
Example #4
0
 /**
  * The constructor that accepts a user-specified field delimiter.
  *
  * @param delimiter a <code>String</code> specifying the field delimiter.
  */
 public PigStreaming(String delimiter) {
   this();
   fieldDel = StorageUtil.parseFieldDel(delimiter);
 }