/** * Autogenerated by Thrift Compiler (0.9.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated */ package com.datascience.utils.transformations.thrift.generated; import org.apache.thrift.scheme.IScheme; import org.apache.thrift.scheme.SchemeFactory; import org.apache.thrift.scheme.StandardScheme; import org.apache.thrift.scheme.TupleScheme; import org.apache.thrift.protocol.TTupleProtocol; import org.apache.thrift.protocol.TProtocolException; import org.apache.thrift.EncodingUtils; import org.apache.thrift.TException; import java.util.List; import java.util.ArrayList; import java.util.Map; import java.util.HashMap; import java.util.EnumMap; import java.util.Set; import java.util.HashSet; import java.util.EnumSet; import java.util.Collections; import java.util.BitSet; import java.nio.ByteBuffer; import java.util.Arrays; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class TConfusionMatrix implements org.apache.thrift.TBase<TConfusionMatrix, TConfusionMatrix._Fields>, java.io.Serializable, Cloneable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TConfusionMatrix"); private static final org.apache.thrift.protocol.TField CATEGORIES_FIELD_DESC = new org.apache.thrift.protocol.TField("categories", org.apache.thrift.protocol.TType.SET, (short)1); private static final org.apache.thrift.protocol.TField MATRIX_FIELD_DESC = new org.apache.thrift.protocol.TField("matrix", org.apache.thrift.protocol.TType.LIST, (short)2); private static final org.apache.thrift.protocol.TField ROW_DENOMINATOR_FIELD_DESC = new org.apache.thrift.protocol.TField("rowDenominator", org.apache.thrift.protocol.TType.MAP, (short)3); private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); static { schemes.put(StandardScheme.class, new TConfusionMatrixStandardSchemeFactory()); schemes.put(TupleScheme.class, new TConfusionMatrixTupleSchemeFactory()); } public Set<String> categories; // required public List<TCMEntry> matrix; // required public Map<String,Double> rowDenominator; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { CATEGORIES((short)1, "categories"), MATRIX((short)2, "matrix"), ROW_DENOMINATOR((short)3, "rowDenominator"); private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); static { for (_Fields field : EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 1: // CATEGORIES return CATEGORIES; case 2: // MATRIX return MATRIX; case 3: // ROW_DENOMINATOR return ROW_DENOMINATOR; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(String name) { return byName.get(name); } private final short _thriftId; private final String _fieldName; _Fields(short thriftId, String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public String getFieldName() { return _fieldName; } } // isset id assignments public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.CATEGORIES, new org.apache.thrift.meta_data.FieldMetaData("categories", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.SetMetaData(org.apache.thrift.protocol.TType.SET, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)))); tmpMap.put(_Fields.MATRIX, new org.apache.thrift.meta_data.FieldMetaData("matrix", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TCMEntry.class)))); tmpMap.put(_Fields.ROW_DENOMINATOR, new org.apache.thrift.meta_data.FieldMetaData("rowDenominator", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING), new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.DOUBLE)))); metaDataMap = Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TConfusionMatrix.class, metaDataMap); } public TConfusionMatrix() { } public TConfusionMatrix( Set<String> categories, List<TCMEntry> matrix, Map<String,Double> rowDenominator) { this(); this.categories = categories; this.matrix = matrix; this.rowDenominator = rowDenominator; } /** * Performs a deep copy on <i>other</i>. */ public TConfusionMatrix(TConfusionMatrix other) { if (other.isSetCategories()) { Set<String> __this__categories = new HashSet<String>(); for (String other_element : other.categories) { __this__categories.add(other_element); } this.categories = __this__categories; } if (other.isSetMatrix()) { List<TCMEntry> __this__matrix = new ArrayList<TCMEntry>(); for (TCMEntry other_element : other.matrix) { __this__matrix.add(new TCMEntry(other_element)); } this.matrix = __this__matrix; } if (other.isSetRowDenominator()) { Map<String,Double> __this__rowDenominator = new HashMap<String,Double>(); for (Map.Entry<String, Double> other_element : other.rowDenominator.entrySet()) { String other_element_key = other_element.getKey(); Double other_element_value = other_element.getValue(); String __this__rowDenominator_copy_key = other_element_key; Double __this__rowDenominator_copy_value = other_element_value; __this__rowDenominator.put(__this__rowDenominator_copy_key, __this__rowDenominator_copy_value); } this.rowDenominator = __this__rowDenominator; } } public TConfusionMatrix deepCopy() { return new TConfusionMatrix(this); } @Override public void clear() { this.categories = null; this.matrix = null; this.rowDenominator = null; } public int getCategoriesSize() { return (this.categories == null) ? 0 : this.categories.size(); } public java.util.Iterator<String> getCategoriesIterator() { return (this.categories == null) ? null : this.categories.iterator(); } public void addToCategories(String elem) { if (this.categories == null) { this.categories = new HashSet<String>(); } this.categories.add(elem); } public Set<String> getCategories() { return this.categories; } public TConfusionMatrix setCategories(Set<String> categories) { this.categories = categories; return this; } public void unsetCategories() { this.categories = null; } /** Returns true if field categories is set (has been assigned a value) and false otherwise */ public boolean isSetCategories() { return this.categories != null; } public void setCategoriesIsSet(boolean value) { if (!value) { this.categories = null; } } public int getMatrixSize() { return (this.matrix == null) ? 0 : this.matrix.size(); } public java.util.Iterator<TCMEntry> getMatrixIterator() { return (this.matrix == null) ? null : this.matrix.iterator(); } public void addToMatrix(TCMEntry elem) { if (this.matrix == null) { this.matrix = new ArrayList<TCMEntry>(); } this.matrix.add(elem); } public List<TCMEntry> getMatrix() { return this.matrix; } public TConfusionMatrix setMatrix(List<TCMEntry> matrix) { this.matrix = matrix; return this; } public void unsetMatrix() { this.matrix = null; } /** Returns true if field matrix is set (has been assigned a value) and false otherwise */ public boolean isSetMatrix() { return this.matrix != null; } public void setMatrixIsSet(boolean value) { if (!value) { this.matrix = null; } } public int getRowDenominatorSize() { return (this.rowDenominator == null) ? 0 : this.rowDenominator.size(); } public void putToRowDenominator(String key, double val) { if (this.rowDenominator == null) { this.rowDenominator = new HashMap<String,Double>(); } this.rowDenominator.put(key, val); } public Map<String,Double> getRowDenominator() { return this.rowDenominator; } public TConfusionMatrix setRowDenominator(Map<String,Double> rowDenominator) { this.rowDenominator = rowDenominator; return this; } public void unsetRowDenominator() { this.rowDenominator = null; } /** Returns true if field rowDenominator is set (has been assigned a value) and false otherwise */ public boolean isSetRowDenominator() { return this.rowDenominator != null; } public void setRowDenominatorIsSet(boolean value) { if (!value) { this.rowDenominator = null; } } public void setFieldValue(_Fields field, Object value) { switch (field) { case CATEGORIES: if (value == null) { unsetCategories(); } else { setCategories((Set<String>)value); } break; case MATRIX: if (value == null) { unsetMatrix(); } else { setMatrix((List<TCMEntry>)value); } break; case ROW_DENOMINATOR: if (value == null) { unsetRowDenominator(); } else { setRowDenominator((Map<String,Double>)value); } break; } } public Object getFieldValue(_Fields field) { switch (field) { case CATEGORIES: return getCategories(); case MATRIX: return getMatrix(); case ROW_DENOMINATOR: return getRowDenominator(); } throw new IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new IllegalArgumentException(); } switch (field) { case CATEGORIES: return isSetCategories(); case MATRIX: return isSetMatrix(); case ROW_DENOMINATOR: return isSetRowDenominator(); } throw new IllegalStateException(); } @Override public boolean equals(Object that) { if (that == null) return false; if (that instanceof TConfusionMatrix) return this.equals((TConfusionMatrix)that); return false; } public boolean equals(TConfusionMatrix that) { if (that == null) return false; boolean this_present_categories = true && this.isSetCategories(); boolean that_present_categories = true && that.isSetCategories(); if (this_present_categories || that_present_categories) { if (!(this_present_categories && that_present_categories)) return false; if (!this.categories.equals(that.categories)) return false; } boolean this_present_matrix = true && this.isSetMatrix(); boolean that_present_matrix = true && that.isSetMatrix(); if (this_present_matrix || that_present_matrix) { if (!(this_present_matrix && that_present_matrix)) return false; if (!this.matrix.equals(that.matrix)) return false; } boolean this_present_rowDenominator = true && this.isSetRowDenominator(); boolean that_present_rowDenominator = true && that.isSetRowDenominator(); if (this_present_rowDenominator || that_present_rowDenominator) { if (!(this_present_rowDenominator && that_present_rowDenominator)) return false; if (!this.rowDenominator.equals(that.rowDenominator)) return false; } return true; } @Override public int hashCode() { return 0; } public int compareTo(TConfusionMatrix other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; TConfusionMatrix typedOther = (TConfusionMatrix)other; lastComparison = Boolean.valueOf(isSetCategories()).compareTo(typedOther.isSetCategories()); if (lastComparison != 0) { return lastComparison; } if (isSetCategories()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.categories, typedOther.categories); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetMatrix()).compareTo(typedOther.isSetMatrix()); if (lastComparison != 0) { return lastComparison; } if (isSetMatrix()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.matrix, typedOther.matrix); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetRowDenominator()).compareTo(typedOther.isSetRowDenominator()); if (lastComparison != 0) { return lastComparison; } if (isSetRowDenominator()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.rowDenominator, typedOther.rowDenominator); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { schemes.get(iprot.getScheme()).getScheme().read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { schemes.get(oprot.getScheme()).getScheme().write(oprot, this); } @Override public String toString() { StringBuilder sb = new StringBuilder("TConfusionMatrix("); boolean first = true; sb.append("categories:"); if (this.categories == null) { sb.append("null"); } else { sb.append(this.categories); } first = false; if (!first) sb.append(", "); sb.append("matrix:"); if (this.matrix == null) { sb.append("null"); } else { sb.append(this.matrix); } first = false; if (!first) sb.append(", "); sb.append("rowDenominator:"); if (this.rowDenominator == null) { sb.append("null"); } else { sb.append(this.rowDenominator); } first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { try { read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class TConfusionMatrixStandardSchemeFactory implements SchemeFactory { public TConfusionMatrixStandardScheme getScheme() { return new TConfusionMatrixStandardScheme(); } } private static class TConfusionMatrixStandardScheme extends StandardScheme<TConfusionMatrix> { public void read(org.apache.thrift.protocol.TProtocol iprot, TConfusionMatrix struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 1: // CATEGORIES if (schemeField.type == org.apache.thrift.protocol.TType.SET) { { org.apache.thrift.protocol.TSet _set34 = iprot.readSetBegin(); struct.categories = new HashSet<String>(2*_set34.size); for (int _i35 = 0; _i35 < _set34.size; ++_i35) { String _elem36; // required _elem36 = iprot.readString(); struct.categories.add(_elem36); } iprot.readSetEnd(); } struct.setCategoriesIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 2: // MATRIX if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { org.apache.thrift.protocol.TList _list37 = iprot.readListBegin(); struct.matrix = new ArrayList<TCMEntry>(_list37.size); for (int _i38 = 0; _i38 < _list37.size; ++_i38) { TCMEntry _elem39; // required _elem39 = new TCMEntry(); _elem39.read(iprot); struct.matrix.add(_elem39); } iprot.readListEnd(); } struct.setMatrixIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 3: // ROW_DENOMINATOR if (schemeField.type == org.apache.thrift.protocol.TType.MAP) { { org.apache.thrift.protocol.TMap _map40 = iprot.readMapBegin(); struct.rowDenominator = new HashMap<String,Double>(2*_map40.size); for (int _i41 = 0; _i41 < _map40.size; ++_i41) { String _key42; // required double _val43; // required _key42 = iprot.readString(); _val43 = iprot.readDouble(); struct.rowDenominator.put(_key42, _val43); } iprot.readMapEnd(); } struct.setRowDenominatorIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, TConfusionMatrix struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.categories != null) { oprot.writeFieldBegin(CATEGORIES_FIELD_DESC); { oprot.writeSetBegin(new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRING, struct.categories.size())); for (String _iter44 : struct.categories) { oprot.writeString(_iter44); } oprot.writeSetEnd(); } oprot.writeFieldEnd(); } if (struct.matrix != null) { oprot.writeFieldBegin(MATRIX_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.matrix.size())); for (TCMEntry _iter45 : struct.matrix) { _iter45.write(oprot); } oprot.writeListEnd(); } oprot.writeFieldEnd(); } if (struct.rowDenominator != null) { oprot.writeFieldBegin(ROW_DENOMINATOR_FIELD_DESC); { oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.DOUBLE, struct.rowDenominator.size())); for (Map.Entry<String, Double> _iter46 : struct.rowDenominator.entrySet()) { oprot.writeString(_iter46.getKey()); oprot.writeDouble(_iter46.getValue()); } oprot.writeMapEnd(); } oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class TConfusionMatrixTupleSchemeFactory implements SchemeFactory { public TConfusionMatrixTupleScheme getScheme() { return new TConfusionMatrixTupleScheme(); } } private static class TConfusionMatrixTupleScheme extends TupleScheme<TConfusionMatrix> { @Override public void write(org.apache.thrift.protocol.TProtocol prot, TConfusionMatrix struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; BitSet optionals = new BitSet(); if (struct.isSetCategories()) { optionals.set(0); } if (struct.isSetMatrix()) { optionals.set(1); } if (struct.isSetRowDenominator()) { optionals.set(2); } oprot.writeBitSet(optionals, 3); if (struct.isSetCategories()) { { oprot.writeI32(struct.categories.size()); for (String _iter47 : struct.categories) { oprot.writeString(_iter47); } } } if (struct.isSetMatrix()) { { oprot.writeI32(struct.matrix.size()); for (TCMEntry _iter48 : struct.matrix) { _iter48.write(oprot); } } } if (struct.isSetRowDenominator()) { { oprot.writeI32(struct.rowDenominator.size()); for (Map.Entry<String, Double> _iter49 : struct.rowDenominator.entrySet()) { oprot.writeString(_iter49.getKey()); oprot.writeDouble(_iter49.getValue()); } } } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, TConfusionMatrix struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; BitSet incoming = iprot.readBitSet(3); if (incoming.get(0)) { { org.apache.thrift.protocol.TSet _set50 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); struct.categories = new HashSet<String>(2*_set50.size); for (int _i51 = 0; _i51 < _set50.size; ++_i51) { String _elem52; // required _elem52 = iprot.readString(); struct.categories.add(_elem52); } } struct.setCategoriesIsSet(true); } if (incoming.get(1)) { { org.apache.thrift.protocol.TList _list53 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); struct.matrix = new ArrayList<TCMEntry>(_list53.size); for (int _i54 = 0; _i54 < _list53.size; ++_i54) { TCMEntry _elem55; // required _elem55 = new TCMEntry(); _elem55.read(iprot); struct.matrix.add(_elem55); } } struct.setMatrixIsSet(true); } if (incoming.get(2)) { { org.apache.thrift.protocol.TMap _map56 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.DOUBLE, iprot.readI32()); struct.rowDenominator = new HashMap<String,Double>(2*_map56.size); for (int _i57 = 0; _i57 < _map56.size; ++_i57) { String _key58; // required double _val59; // required _key58 = iprot.readString(); _val59 = iprot.readDouble(); struct.rowDenominator.put(_key58, _val59); } } struct.setRowDenominatorIsSet(true); } } } }