// Find the record identifier column (if there) and return a possibly new ObjectInspector that // will strain out the record id for the underlying writer. private ObjectInspector findRecId(ObjectInspector inspector, int rowIdColNum) { if (!(inspector is StructObjectInspector)) { throw new InvalidOperationException("Serious problem, expected a StructObjectInspector, but got a " + inspector.GetType().FullName); } if (rowIdColNum < 0) { return(inspector); } else { RecIdStrippingObjectInspector newInspector = new RecIdStrippingObjectInspector(inspector, rowIdColNum); recIdField = newInspector.getRecId(); List <StructField> fields = ((StructObjectInspector)recIdField.getFieldObjectInspector()).getAllStructFieldRefs(); // Go by position, not field name, as field names aren't guaranteed. The order of fields // in RecordIdentifier is transactionId, bucketId, rowId originalTxnField = fields[0]; origTxnInspector = (LongObjectInspector)originalTxnField.getFieldObjectInspector(); rowIdField = fields[2]; rowIdInspector = (LongObjectInspector)rowIdField.getFieldObjectInspector(); recIdInspector = (StructObjectInspector)recIdField.getFieldObjectInspector(); return(newInspector); } }
public override bool Equals(object o) { if (o == null || o.GetType() != GetType()) { return(false); } else if (o == this) { return(true); } else { IList <StructField> other = ((OrcStructInspector)o).fields; if (other.Count != fields.Count) { return(false); } for (int i = 0; i < fields.Count; ++i) { StructField left = other[i]; StructField right = fields[i]; if (!string.Equals(left.getFieldName(), right.getFieldName(), StringComparison.OrdinalIgnoreCase) && left.getFieldObjectInspector().Equals(right.getFieldObjectInspector())) { return(false); } } return(true); } }
public override string getTypeName() { StringBuilder buffer = new StringBuilder(); buffer.Append("struct<"); for (int i = 0; i < fields.Count; ++i) { StructField field = fields[i]; if (i != 0) { buffer.Append(","); } buffer.Append(field.getFieldName()); buffer.Append(":"); buffer.Append(field.getFieldObjectInspector().getTypeName()); } buffer.Append(">"); return(buffer.ToString()); }