private void sanityCheckKeyForTag() throws SerDeException {
      if (hasTag != null) return;
      BinaryComparable b = (BinaryComparable)key;
      Object o = keySerDe.deserialize(key);
      StructObjectInspector soi = (StructObjectInspector)keySerDe.getObjectInspector();
      List<? extends StructField> fields = soi.getAllStructFieldRefs();
      Object[] data = new Object[fields.size()];
      List<ObjectInspector> fois = new ArrayList<ObjectInspector>(fields.size());
      for (int i = 0; i < fields.size(); i++) {
        data[i] = soi.getStructFieldData(o, fields.get(i));
        fois.add(fields.get(i).getFieldObjectInspector());
      }
      Output output = new Output();
      boolean[] sortableSortOrders = new boolean[fields.size()];
      Arrays.fill(sortableSortOrders, false);
      byte[] columnNullMarker = new byte[fields.size()];
      Arrays.fill(columnNullMarker, BinarySortableSerDe.ZERO);
      byte[] columnNotNullMarker = new byte[fields.size()];
      Arrays.fill(columnNotNullMarker, BinarySortableSerDe.ONE);
      BinarySortableSerDe.serializeStruct(output, data, fois, sortableSortOrders,
              columnNullMarker, columnNotNullMarker);
      hasTag = (output.getLength() != b.getLength());
      if (hasTag) {
        LOG.error("Tag found in keys and will be removed. This should not happen.");
        if (output.getLength() != (b.getLength() - 1)) {
          throw new SerDeException(
              "Unexpected tag: " + b.getLength() + " reserialized to " + output.getLength());
        }
      }
    }
If we received data with tags from ReduceSinkOperators, no keys will match. This should
not happen, but is important enough that we want to find out and work around it if some
optimized change causes RSO to pass on tags.
ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/MapJoinBytesTableContainer.java