Examples of ListObjectInspector


Examples of org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector

            throw new RuntimeException("Unrecognized type: " + poi.getPrimitiveCategory());
          }
        }
      }
      case LIST: {
        ListObjectInspector loi = (ListObjectInspector)objInspector;
        ObjectInspector eoi = loi.getListElementObjectInspector();
       
        // 1/ reserve spaces for the byte size of the list
        //    which is a integer and takes four bytes
        int byteSizeStart = byteStream.getCount();
        byteStream.write((byte) 0);
        byteStream.write((byte) 0);
        byteStream.write((byte) 0);
        byteStream.write((byte) 0);       
        int listStart = byteStream.getCount();
       
        // 2/ write the size of the list as a VInt
        int size = loi.getListLength(obj);
        LazyBinaryUtils.writeVInt(byteStream, size);
       
        // 3/ write the null bytes
        byte nullByte = 0;
        for (int eid = 0; eid < size; eid++) {
          // set the bit to 1 if an element is not null
          if (null != loi.getListElement(obj, eid)) {
            nullByte |= 1 << (eid%8);
          }
          // store the byte every eight elements or 
          // if this is the last element
          if (7 == eid%8 || eid == size-1) {
            byteStream.write(nullByte);
            nullByte = 0;
          }
        }
       
        // 4/ write element by element from the list
        for (int eid = 0; eid < size; eid++) {
          serialize(byteStream, loi.getListElement(obj, eid), eoi);
        }
       
        // 5/ update the list byte size
        int listEnd  = byteStream.getCount();
        int listSize = listEnd - listStart;
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.