@Override public Object doDeserialize(Writable blob) throws SerDeException { if (byteArrayRef == null) { byteArrayRef = new ByteArrayRef(); } // we use the default field delimiter('\1') to replace the multiple-char field delimiter // but we cannot use it to parse the row since column data can contain '\1' as well String rowStr; if (blob instanceof BytesWritable) { BytesWritable b = (BytesWritable) blob; rowStr = new String(b.getBytes()); } else if (blob instanceof Text) { Text rowText = (Text) blob; rowStr = rowText.toString(); } else { throw new SerDeException(getClass() + ": expects either BytesWritable or Text object!"); } byteArrayRef.setData(rowStr.replaceAll(Pattern.quote(fieldDelimited), "\1").getBytes()); cachedLazyStruct.init(byteArrayRef, 0, byteArrayRef.getData().length); // use the multi-char delimiter to parse the lazy struct cachedLazyStruct.parseMultiDelimit(rowStr.getBytes(), fieldDelimited.getBytes()); return cachedLazyStruct; }
@Override public Object deserialize(Writable blob) throws SerDeException { if (byteArrayRef == null) { byteArrayRef = new ByteArrayRef(); } // we use the default field delimiter('\1') to replace the multiple-char field delimiter // but we cannot use it to parse the row since column data can contain '\1' as well String rowStr; if (blob instanceof BytesWritable) { BytesWritable b = (BytesWritable) blob; rowStr = new String(b.getBytes()); } else if (blob instanceof Text) { Text rowText = (Text) blob; rowStr = rowText.toString(); } else { throw new SerDeException(getClass() + ": expects either BytesWritable or Text object!"); } byteArrayRef.setData(rowStr.replaceAll(Pattern.quote(fieldDelimited), "\1").getBytes()); cachedLazyStruct.init(byteArrayRef, 0, byteArrayRef.getData().length); // use the multi-char delimiter to parse the lazy struct cachedLazyStruct.parseMultiDelimit(rowStr.getBytes(), fieldDelimited.getBytes()); return cachedLazyStruct; }
@Override public Object deserialize(Writable blob) throws SerDeException { if (byteArrayRef == null) { byteArrayRef = new ByteArrayRef(); } // we use the default field delimiter('\1') to replace the multiple-char field delimiter // but we cannot use it to parse the row since column data can contain '\1' as well String rowStr; if (blob instanceof BytesWritable) { BytesWritable b = (BytesWritable) blob; rowStr = new String(b.getBytes()); } else if (blob instanceof Text) { Text rowText = (Text) blob; rowStr = rowText.toString(); } else { throw new SerDeException(getClass() + ": expects either BytesWritable or Text object!"); } byteArrayRef.setData(rowStr.replaceAll(Pattern.quote(fieldDelimited), "\1").getBytes()); cachedLazyStruct.init(byteArrayRef, 0, byteArrayRef.getData().length); // use the multi-char delimiter to parse the lazy struct cachedLazyStruct.parseMultiDelimit(rowStr.getBytes(), fieldDelimited.getBytes()); return cachedLazyStruct; }