Java tutorial
/* Copyright (C) 2013-2014 Computer Sciences Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Autogenerated by Thrift Compiler (0.9.1) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated */ package ezbake.data.elastic.thrift; import org.apache.commons.lang3.builder.HashCodeBuilder; 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 org.apache.thrift.async.AsyncMethodCallback; import org.apache.thrift.server.AbstractNonblockingServer.*; 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; /** * Results of a search */ public class SearchResult implements org.apache.thrift.TBase<SearchResult, SearchResult._Fields>, java.io.Serializable, Cloneable, Comparable<SearchResult> { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct( "SearchResult"); private static final org.apache.thrift.protocol.TField MATCHING_DOCUMENTS_FIELD_DESC = new org.apache.thrift.protocol.TField( "matchingDocuments", org.apache.thrift.protocol.TType.LIST, (short) 1); private static final org.apache.thrift.protocol.TField TOTAL_HITS_FIELD_DESC = new org.apache.thrift.protocol.TField( "totalHits", org.apache.thrift.protocol.TType.I64, (short) 2); private static final org.apache.thrift.protocol.TField OFFSET_FIELD_DESC = new org.apache.thrift.protocol.TField( "offset", org.apache.thrift.protocol.TType.I32, (short) 3); private static final org.apache.thrift.protocol.TField PAGESIZE_FIELD_DESC = new org.apache.thrift.protocol.TField( "pagesize", org.apache.thrift.protocol.TType.I16, (short) 4); private static final org.apache.thrift.protocol.TField ACTUAL_QUERY_FIELD_DESC = new org.apache.thrift.protocol.TField( "actualQuery", org.apache.thrift.protocol.TType.STRING, (short) 5); private static final org.apache.thrift.protocol.TField FACETS_FIELD_DESC = new org.apache.thrift.protocol.TField( "facets", org.apache.thrift.protocol.TType.MAP, (short) 6); private static final org.apache.thrift.protocol.TField HIGHLIGHTS_FIELD_DESC = new org.apache.thrift.protocol.TField( "highlights", org.apache.thrift.protocol.TType.MAP, (short) 7); private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); static { schemes.put(StandardScheme.class, new SearchResultStandardSchemeFactory()); schemes.put(TupleScheme.class, new SearchResultTupleSchemeFactory()); } /** * Documents matching the search */ public List<Document> matchingDocuments; // required /** * Total number of results across all pages */ public long totalHits; // required /** * Paging offset */ public int offset; // required /** * Page size */ public short pagesize; // required /** * JSON query that created these results */ public String actualQuery; // required /** * Map of facet name (from ImageSearch) to its results */ public Map<String, ezbake.data.elastic.thrift.FacetResult> facets; // optional /** * Maps from doc id => highlight result */ public Map<String, HighlightResult> highlights; // optional /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { /** * Documents matching the search */ MATCHING_DOCUMENTS((short) 1, "matchingDocuments"), /** * Total number of results across all pages */ TOTAL_HITS((short) 2, "totalHits"), /** * Paging offset */ OFFSET((short) 3, "offset"), /** * Page size */ PAGESIZE((short) 4, "pagesize"), /** * JSON query that created these results */ ACTUAL_QUERY((short) 5, "actualQuery"), /** * Map of facet name (from ImageSearch) to its results */ FACETS((short) 6, "facets"), /** * Maps from doc id => highlight result */ HIGHLIGHTS((short) 7, "highlights"); 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: // MATCHING_DOCUMENTS return MATCHING_DOCUMENTS; case 2: // TOTAL_HITS return TOTAL_HITS; case 3: // OFFSET return OFFSET; case 4: // PAGESIZE return PAGESIZE; case 5: // ACTUAL_QUERY return ACTUAL_QUERY; case 6: // FACETS return FACETS; case 7: // HIGHLIGHTS return HIGHLIGHTS; 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 private static final int __TOTALHITS_ISSET_ID = 0; private static final int __OFFSET_ISSET_ID = 1; private static final int __PAGESIZE_ISSET_ID = 2; private byte __isset_bitfield = 0; private _Fields optionals[] = { _Fields.FACETS, _Fields.HIGHLIGHTS }; 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.MATCHING_DOCUMENTS, new org.apache.thrift.meta_data.FieldMetaData("matchingDocuments", org.apache.thrift.TFieldRequirementType.REQUIRED, 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, Document.class)))); tmpMap.put(_Fields.TOTAL_HITS, new org.apache.thrift.meta_data.FieldMetaData("totalHits", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); tmpMap.put(_Fields.OFFSET, new org.apache.thrift.meta_data.FieldMetaData("offset", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); tmpMap.put(_Fields.PAGESIZE, new org.apache.thrift.meta_data.FieldMetaData("pagesize", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I16))); tmpMap.put(_Fields.ACTUAL_QUERY, new org.apache.thrift.meta_data.FieldMetaData("actualQuery", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.FACETS, new org.apache.thrift.meta_data.FieldMetaData("facets", org.apache.thrift.TFieldRequirementType.OPTIONAL, 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.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, ezbake.data.elastic.thrift.FacetResult.class)))); tmpMap.put(_Fields.HIGHLIGHTS, new org.apache.thrift.meta_data.FieldMetaData("highlights", org.apache.thrift.TFieldRequirementType.OPTIONAL, 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.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, HighlightResult.class)))); metaDataMap = Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(SearchResult.class, metaDataMap); } public SearchResult() { } public SearchResult(List<Document> matchingDocuments, long totalHits, int offset, short pagesize, String actualQuery) { this(); this.matchingDocuments = matchingDocuments; this.totalHits = totalHits; setTotalHitsIsSet(true); this.offset = offset; setOffsetIsSet(true); this.pagesize = pagesize; setPagesizeIsSet(true); this.actualQuery = actualQuery; } /** * Performs a deep copy on <i>other</i>. */ public SearchResult(SearchResult other) { __isset_bitfield = other.__isset_bitfield; if (other.isSetMatchingDocuments()) { List<Document> __this__matchingDocuments = new ArrayList<Document>(other.matchingDocuments.size()); for (Document other_element : other.matchingDocuments) { __this__matchingDocuments.add(new Document(other_element)); } this.matchingDocuments = __this__matchingDocuments; } this.totalHits = other.totalHits; this.offset = other.offset; this.pagesize = other.pagesize; if (other.isSetActualQuery()) { this.actualQuery = other.actualQuery; } if (other.isSetFacets()) { Map<String, ezbake.data.elastic.thrift.FacetResult> __this__facets = new HashMap<String, ezbake.data.elastic.thrift.FacetResult>( other.facets.size()); for (Map.Entry<String, ezbake.data.elastic.thrift.FacetResult> other_element : other.facets .entrySet()) { String other_element_key = other_element.getKey(); ezbake.data.elastic.thrift.FacetResult other_element_value = other_element.getValue(); String __this__facets_copy_key = other_element_key; ezbake.data.elastic.thrift.FacetResult __this__facets_copy_value = new ezbake.data.elastic.thrift.FacetResult( other_element_value); __this__facets.put(__this__facets_copy_key, __this__facets_copy_value); } this.facets = __this__facets; } if (other.isSetHighlights()) { Map<String, HighlightResult> __this__highlights = new HashMap<String, HighlightResult>( other.highlights.size()); for (Map.Entry<String, HighlightResult> other_element : other.highlights.entrySet()) { String other_element_key = other_element.getKey(); HighlightResult other_element_value = other_element.getValue(); String __this__highlights_copy_key = other_element_key; HighlightResult __this__highlights_copy_value = new HighlightResult(other_element_value); __this__highlights.put(__this__highlights_copy_key, __this__highlights_copy_value); } this.highlights = __this__highlights; } } public SearchResult deepCopy() { return new SearchResult(this); } @Override public void clear() { this.matchingDocuments = null; setTotalHitsIsSet(false); this.totalHits = 0; setOffsetIsSet(false); this.offset = 0; setPagesizeIsSet(false); this.pagesize = 0; this.actualQuery = null; this.facets = null; this.highlights = null; } public int getMatchingDocumentsSize() { return (this.matchingDocuments == null) ? 0 : this.matchingDocuments.size(); } public java.util.Iterator<Document> getMatchingDocumentsIterator() { return (this.matchingDocuments == null) ? null : this.matchingDocuments.iterator(); } public void addToMatchingDocuments(Document elem) { if (this.matchingDocuments == null) { this.matchingDocuments = new ArrayList<Document>(); } this.matchingDocuments.add(elem); } /** * Documents matching the search */ public List<Document> getMatchingDocuments() { return this.matchingDocuments; } /** * Documents matching the search */ public SearchResult setMatchingDocuments(List<Document> matchingDocuments) { this.matchingDocuments = matchingDocuments; return this; } public void unsetMatchingDocuments() { this.matchingDocuments = null; } /** Returns true if field matchingDocuments is set (has been assigned a value) and false otherwise */ public boolean isSetMatchingDocuments() { return this.matchingDocuments != null; } public void setMatchingDocumentsIsSet(boolean value) { if (!value) { this.matchingDocuments = null; } } /** * Total number of results across all pages */ public long getTotalHits() { return this.totalHits; } /** * Total number of results across all pages */ public SearchResult setTotalHits(long totalHits) { this.totalHits = totalHits; setTotalHitsIsSet(true); return this; } public void unsetTotalHits() { __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __TOTALHITS_ISSET_ID); } /** Returns true if field totalHits is set (has been assigned a value) and false otherwise */ public boolean isSetTotalHits() { return EncodingUtils.testBit(__isset_bitfield, __TOTALHITS_ISSET_ID); } public void setTotalHitsIsSet(boolean value) { __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __TOTALHITS_ISSET_ID, value); } /** * Paging offset */ public int getOffset() { return this.offset; } /** * Paging offset */ public SearchResult setOffset(int offset) { this.offset = offset; setOffsetIsSet(true); return this; } public void unsetOffset() { __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __OFFSET_ISSET_ID); } /** Returns true if field offset is set (has been assigned a value) and false otherwise */ public boolean isSetOffset() { return EncodingUtils.testBit(__isset_bitfield, __OFFSET_ISSET_ID); } public void setOffsetIsSet(boolean value) { __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __OFFSET_ISSET_ID, value); } /** * Page size */ public short getPagesize() { return this.pagesize; } /** * Page size */ public SearchResult setPagesize(short pagesize) { this.pagesize = pagesize; setPagesizeIsSet(true); return this; } public void unsetPagesize() { __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __PAGESIZE_ISSET_ID); } /** Returns true if field pagesize is set (has been assigned a value) and false otherwise */ public boolean isSetPagesize() { return EncodingUtils.testBit(__isset_bitfield, __PAGESIZE_ISSET_ID); } public void setPagesizeIsSet(boolean value) { __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __PAGESIZE_ISSET_ID, value); } /** * JSON query that created these results */ public String getActualQuery() { return this.actualQuery; } /** * JSON query that created these results */ public SearchResult setActualQuery(String actualQuery) { this.actualQuery = actualQuery; return this; } public void unsetActualQuery() { this.actualQuery = null; } /** Returns true if field actualQuery is set (has been assigned a value) and false otherwise */ public boolean isSetActualQuery() { return this.actualQuery != null; } public void setActualQueryIsSet(boolean value) { if (!value) { this.actualQuery = null; } } public int getFacetsSize() { return (this.facets == null) ? 0 : this.facets.size(); } public void putToFacets(String key, ezbake.data.elastic.thrift.FacetResult val) { if (this.facets == null) { this.facets = new HashMap<String, ezbake.data.elastic.thrift.FacetResult>(); } this.facets.put(key, val); } /** * Map of facet name (from ImageSearch) to its results */ public Map<String, ezbake.data.elastic.thrift.FacetResult> getFacets() { return this.facets; } /** * Map of facet name (from ImageSearch) to its results */ public SearchResult setFacets(Map<String, ezbake.data.elastic.thrift.FacetResult> facets) { this.facets = facets; return this; } public void unsetFacets() { this.facets = null; } /** Returns true if field facets is set (has been assigned a value) and false otherwise */ public boolean isSetFacets() { return this.facets != null; } public void setFacetsIsSet(boolean value) { if (!value) { this.facets = null; } } public int getHighlightsSize() { return (this.highlights == null) ? 0 : this.highlights.size(); } public void putToHighlights(String key, HighlightResult val) { if (this.highlights == null) { this.highlights = new HashMap<String, HighlightResult>(); } this.highlights.put(key, val); } /** * Maps from doc id => highlight result */ public Map<String, HighlightResult> getHighlights() { return this.highlights; } /** * Maps from doc id => highlight result */ public SearchResult setHighlights(Map<String, HighlightResult> highlights) { this.highlights = highlights; return this; } public void unsetHighlights() { this.highlights = null; } /** Returns true if field highlights is set (has been assigned a value) and false otherwise */ public boolean isSetHighlights() { return this.highlights != null; } public void setHighlightsIsSet(boolean value) { if (!value) { this.highlights = null; } } public void setFieldValue(_Fields field, Object value) { switch (field) { case MATCHING_DOCUMENTS: if (value == null) { unsetMatchingDocuments(); } else { setMatchingDocuments((List<Document>) value); } break; case TOTAL_HITS: if (value == null) { unsetTotalHits(); } else { setTotalHits((Long) value); } break; case OFFSET: if (value == null) { unsetOffset(); } else { setOffset((Integer) value); } break; case PAGESIZE: if (value == null) { unsetPagesize(); } else { setPagesize((Short) value); } break; case ACTUAL_QUERY: if (value == null) { unsetActualQuery(); } else { setActualQuery((String) value); } break; case FACETS: if (value == null) { unsetFacets(); } else { setFacets((Map<String, ezbake.data.elastic.thrift.FacetResult>) value); } break; case HIGHLIGHTS: if (value == null) { unsetHighlights(); } else { setHighlights((Map<String, HighlightResult>) value); } break; } } public Object getFieldValue(_Fields field) { switch (field) { case MATCHING_DOCUMENTS: return getMatchingDocuments(); case TOTAL_HITS: return Long.valueOf(getTotalHits()); case OFFSET: return Integer.valueOf(getOffset()); case PAGESIZE: return Short.valueOf(getPagesize()); case ACTUAL_QUERY: return getActualQuery(); case FACETS: return getFacets(); case HIGHLIGHTS: return getHighlights(); } 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 MATCHING_DOCUMENTS: return isSetMatchingDocuments(); case TOTAL_HITS: return isSetTotalHits(); case OFFSET: return isSetOffset(); case PAGESIZE: return isSetPagesize(); case ACTUAL_QUERY: return isSetActualQuery(); case FACETS: return isSetFacets(); case HIGHLIGHTS: return isSetHighlights(); } throw new IllegalStateException(); } @Override public boolean equals(Object that) { if (that == null) return false; if (that instanceof SearchResult) return this.equals((SearchResult) that); return false; } public boolean equals(SearchResult that) { if (that == null) return false; boolean this_present_matchingDocuments = true && this.isSetMatchingDocuments(); boolean that_present_matchingDocuments = true && that.isSetMatchingDocuments(); if (this_present_matchingDocuments || that_present_matchingDocuments) { if (!(this_present_matchingDocuments && that_present_matchingDocuments)) return false; if (!this.matchingDocuments.equals(that.matchingDocuments)) return false; } boolean this_present_totalHits = true; boolean that_present_totalHits = true; if (this_present_totalHits || that_present_totalHits) { if (!(this_present_totalHits && that_present_totalHits)) return false; if (this.totalHits != that.totalHits) return false; } boolean this_present_offset = true; boolean that_present_offset = true; if (this_present_offset || that_present_offset) { if (!(this_present_offset && that_present_offset)) return false; if (this.offset != that.offset) return false; } boolean this_present_pagesize = true; boolean that_present_pagesize = true; if (this_present_pagesize || that_present_pagesize) { if (!(this_present_pagesize && that_present_pagesize)) return false; if (this.pagesize != that.pagesize) return false; } boolean this_present_actualQuery = true && this.isSetActualQuery(); boolean that_present_actualQuery = true && that.isSetActualQuery(); if (this_present_actualQuery || that_present_actualQuery) { if (!(this_present_actualQuery && that_present_actualQuery)) return false; if (!this.actualQuery.equals(that.actualQuery)) return false; } boolean this_present_facets = true && this.isSetFacets(); boolean that_present_facets = true && that.isSetFacets(); if (this_present_facets || that_present_facets) { if (!(this_present_facets && that_present_facets)) return false; if (!this.facets.equals(that.facets)) return false; } boolean this_present_highlights = true && this.isSetHighlights(); boolean that_present_highlights = true && that.isSetHighlights(); if (this_present_highlights || that_present_highlights) { if (!(this_present_highlights && that_present_highlights)) return false; if (!this.highlights.equals(that.highlights)) return false; } return true; } @Override public int hashCode() { HashCodeBuilder builder = new HashCodeBuilder(); boolean present_matchingDocuments = true && (isSetMatchingDocuments()); builder.append(present_matchingDocuments); if (present_matchingDocuments) builder.append(matchingDocuments); boolean present_totalHits = true; builder.append(present_totalHits); if (present_totalHits) builder.append(totalHits); boolean present_offset = true; builder.append(present_offset); if (present_offset) builder.append(offset); boolean present_pagesize = true; builder.append(present_pagesize); if (present_pagesize) builder.append(pagesize); boolean present_actualQuery = true && (isSetActualQuery()); builder.append(present_actualQuery); if (present_actualQuery) builder.append(actualQuery); boolean present_facets = true && (isSetFacets()); builder.append(present_facets); if (present_facets) builder.append(facets); boolean present_highlights = true && (isSetHighlights()); builder.append(present_highlights); if (present_highlights) builder.append(highlights); return builder.toHashCode(); } @Override public int compareTo(SearchResult other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = Boolean.valueOf(isSetMatchingDocuments()).compareTo(other.isSetMatchingDocuments()); if (lastComparison != 0) { return lastComparison; } if (isSetMatchingDocuments()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.matchingDocuments, other.matchingDocuments); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetTotalHits()).compareTo(other.isSetTotalHits()); if (lastComparison != 0) { return lastComparison; } if (isSetTotalHits()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.totalHits, other.totalHits); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetOffset()).compareTo(other.isSetOffset()); if (lastComparison != 0) { return lastComparison; } if (isSetOffset()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.offset, other.offset); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetPagesize()).compareTo(other.isSetPagesize()); if (lastComparison != 0) { return lastComparison; } if (isSetPagesize()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.pagesize, other.pagesize); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetActualQuery()).compareTo(other.isSetActualQuery()); if (lastComparison != 0) { return lastComparison; } if (isSetActualQuery()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.actualQuery, other.actualQuery); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetFacets()).compareTo(other.isSetFacets()); if (lastComparison != 0) { return lastComparison; } if (isSetFacets()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.facets, other.facets); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetHighlights()).compareTo(other.isSetHighlights()); if (lastComparison != 0) { return lastComparison; } if (isSetHighlights()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.highlights, other.highlights); 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("SearchResult("); boolean first = true; sb.append("matchingDocuments:"); if (this.matchingDocuments == null) { sb.append("null"); } else { sb.append(this.matchingDocuments); } first = false; if (!first) sb.append(", "); sb.append("totalHits:"); sb.append(this.totalHits); first = false; if (!first) sb.append(", "); sb.append("offset:"); sb.append(this.offset); first = false; if (!first) sb.append(", "); sb.append("pagesize:"); sb.append(this.pagesize); first = false; if (!first) sb.append(", "); sb.append("actualQuery:"); if (this.actualQuery == null) { sb.append("null"); } else { sb.append(this.actualQuery); } first = false; if (isSetFacets()) { if (!first) sb.append(", "); sb.append("facets:"); if (this.facets == null) { sb.append("null"); } else { sb.append(this.facets); } first = false; } if (isSetHighlights()) { if (!first) sb.append(", "); sb.append("highlights:"); if (this.highlights == null) { sb.append("null"); } else { sb.append(this.highlights); } first = false; } sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields if (matchingDocuments == null) { throw new org.apache.thrift.protocol.TProtocolException( "Required field 'matchingDocuments' was not present! Struct: " + toString()); } // alas, we cannot check 'totalHits' because it's a primitive and you chose the non-beans generator. // alas, we cannot check 'offset' because it's a primitive and you chose the non-beans generator. // alas, we cannot check 'pagesize' because it's a primitive and you chose the non-beans generator. if (actualQuery == null) { throw new org.apache.thrift.protocol.TProtocolException( "Required field 'actualQuery' was not present! Struct: " + toString()); } // 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 { // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. __isset_bitfield = 0; 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 SearchResultStandardSchemeFactory implements SchemeFactory { public SearchResultStandardScheme getScheme() { return new SearchResultStandardScheme(); } } private static class SearchResultStandardScheme extends StandardScheme<SearchResult> { public void read(org.apache.thrift.protocol.TProtocol iprot, SearchResult 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: // MATCHING_DOCUMENTS if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { org.apache.thrift.protocol.TList _list84 = iprot.readListBegin(); struct.matchingDocuments = new ArrayList<Document>(_list84.size); for (int _i85 = 0; _i85 < _list84.size; ++_i85) { Document _elem86; _elem86 = new Document(); _elem86.read(iprot); struct.matchingDocuments.add(_elem86); } iprot.readListEnd(); } struct.setMatchingDocumentsIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 2: // TOTAL_HITS if (schemeField.type == org.apache.thrift.protocol.TType.I64) { struct.totalHits = iprot.readI64(); struct.setTotalHitsIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 3: // OFFSET if (schemeField.type == org.apache.thrift.protocol.TType.I32) { struct.offset = iprot.readI32(); struct.setOffsetIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 4: // PAGESIZE if (schemeField.type == org.apache.thrift.protocol.TType.I16) { struct.pagesize = iprot.readI16(); struct.setPagesizeIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 5: // ACTUAL_QUERY if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.actualQuery = iprot.readString(); struct.setActualQueryIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 6: // FACETS if (schemeField.type == org.apache.thrift.protocol.TType.MAP) { { org.apache.thrift.protocol.TMap _map87 = iprot.readMapBegin(); struct.facets = new HashMap<String, ezbake.data.elastic.thrift.FacetResult>( 2 * _map87.size); for (int _i88 = 0; _i88 < _map87.size; ++_i88) { String _key89; ezbake.data.elastic.thrift.FacetResult _val90; _key89 = iprot.readString(); _val90 = new ezbake.data.elastic.thrift.FacetResult(); _val90.read(iprot); struct.facets.put(_key89, _val90); } iprot.readMapEnd(); } struct.setFacetsIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 7: // HIGHLIGHTS if (schemeField.type == org.apache.thrift.protocol.TType.MAP) { { org.apache.thrift.protocol.TMap _map91 = iprot.readMapBegin(); struct.highlights = new HashMap<String, HighlightResult>(2 * _map91.size); for (int _i92 = 0; _i92 < _map91.size; ++_i92) { String _key93; HighlightResult _val94; _key93 = iprot.readString(); _val94 = new HighlightResult(); _val94.read(iprot); struct.highlights.put(_key93, _val94); } iprot.readMapEnd(); } struct.setHighlightsIsSet(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 if (!struct.isSetTotalHits()) { throw new org.apache.thrift.protocol.TProtocolException( "Required field 'totalHits' was not found in serialized data! Struct: " + toString()); } if (!struct.isSetOffset()) { throw new org.apache.thrift.protocol.TProtocolException( "Required field 'offset' was not found in serialized data! Struct: " + toString()); } if (!struct.isSetPagesize()) { throw new org.apache.thrift.protocol.TProtocolException( "Required field 'pagesize' was not found in serialized data! Struct: " + toString()); } struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, SearchResult struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.matchingDocuments != null) { oprot.writeFieldBegin(MATCHING_DOCUMENTS_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList( org.apache.thrift.protocol.TType.STRUCT, struct.matchingDocuments.size())); for (Document _iter95 : struct.matchingDocuments) { _iter95.write(oprot); } oprot.writeListEnd(); } oprot.writeFieldEnd(); } oprot.writeFieldBegin(TOTAL_HITS_FIELD_DESC); oprot.writeI64(struct.totalHits); oprot.writeFieldEnd(); oprot.writeFieldBegin(OFFSET_FIELD_DESC); oprot.writeI32(struct.offset); oprot.writeFieldEnd(); oprot.writeFieldBegin(PAGESIZE_FIELD_DESC); oprot.writeI16(struct.pagesize); oprot.writeFieldEnd(); if (struct.actualQuery != null) { oprot.writeFieldBegin(ACTUAL_QUERY_FIELD_DESC); oprot.writeString(struct.actualQuery); oprot.writeFieldEnd(); } if (struct.facets != null) { if (struct.isSetFacets()) { oprot.writeFieldBegin(FACETS_FIELD_DESC); { oprot.writeMapBegin( new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRUCT, struct.facets.size())); for (Map.Entry<String, ezbake.data.elastic.thrift.FacetResult> _iter96 : struct.facets .entrySet()) { oprot.writeString(_iter96.getKey()); _iter96.getValue().write(oprot); } oprot.writeMapEnd(); } oprot.writeFieldEnd(); } } if (struct.highlights != null) { if (struct.isSetHighlights()) { oprot.writeFieldBegin(HIGHLIGHTS_FIELD_DESC); { oprot.writeMapBegin( new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRUCT, struct.highlights.size())); for (Map.Entry<String, HighlightResult> _iter97 : struct.highlights.entrySet()) { oprot.writeString(_iter97.getKey()); _iter97.getValue().write(oprot); } oprot.writeMapEnd(); } oprot.writeFieldEnd(); } } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class SearchResultTupleSchemeFactory implements SchemeFactory { public SearchResultTupleScheme getScheme() { return new SearchResultTupleScheme(); } } private static class SearchResultTupleScheme extends TupleScheme<SearchResult> { @Override public void write(org.apache.thrift.protocol.TProtocol prot, SearchResult struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; { oprot.writeI32(struct.matchingDocuments.size()); for (Document _iter98 : struct.matchingDocuments) { _iter98.write(oprot); } } oprot.writeI64(struct.totalHits); oprot.writeI32(struct.offset); oprot.writeI16(struct.pagesize); oprot.writeString(struct.actualQuery); BitSet optionals = new BitSet(); if (struct.isSetFacets()) { optionals.set(0); } if (struct.isSetHighlights()) { optionals.set(1); } oprot.writeBitSet(optionals, 2); if (struct.isSetFacets()) { { oprot.writeI32(struct.facets.size()); for (Map.Entry<String, ezbake.data.elastic.thrift.FacetResult> _iter99 : struct.facets .entrySet()) { oprot.writeString(_iter99.getKey()); _iter99.getValue().write(oprot); } } } if (struct.isSetHighlights()) { { oprot.writeI32(struct.highlights.size()); for (Map.Entry<String, HighlightResult> _iter100 : struct.highlights.entrySet()) { oprot.writeString(_iter100.getKey()); _iter100.getValue().write(oprot); } } } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, SearchResult struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; { org.apache.thrift.protocol.TList _list101 = new org.apache.thrift.protocol.TList( org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); struct.matchingDocuments = new ArrayList<Document>(_list101.size); for (int _i102 = 0; _i102 < _list101.size; ++_i102) { Document _elem103; _elem103 = new Document(); _elem103.read(iprot); struct.matchingDocuments.add(_elem103); } } struct.setMatchingDocumentsIsSet(true); struct.totalHits = iprot.readI64(); struct.setTotalHitsIsSet(true); struct.offset = iprot.readI32(); struct.setOffsetIsSet(true); struct.pagesize = iprot.readI16(); struct.setPagesizeIsSet(true); struct.actualQuery = iprot.readString(); struct.setActualQueryIsSet(true); BitSet incoming = iprot.readBitSet(2); if (incoming.get(0)) { { org.apache.thrift.protocol.TMap _map104 = new org.apache.thrift.protocol.TMap( org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); struct.facets = new HashMap<String, ezbake.data.elastic.thrift.FacetResult>(2 * _map104.size); for (int _i105 = 0; _i105 < _map104.size; ++_i105) { String _key106; ezbake.data.elastic.thrift.FacetResult _val107; _key106 = iprot.readString(); _val107 = new ezbake.data.elastic.thrift.FacetResult(); _val107.read(iprot); struct.facets.put(_key106, _val107); } } struct.setFacetsIsSet(true); } if (incoming.get(1)) { { org.apache.thrift.protocol.TMap _map108 = new org.apache.thrift.protocol.TMap( org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); struct.highlights = new HashMap<String, HighlightResult>(2 * _map108.size); for (int _i109 = 0; _i109 < _map108.size; ++_i109) { String _key110; HighlightResult _val111; _key110 = iprot.readString(); _val111 = new HighlightResult(); _val111.read(iprot); struct.highlights.put(_key110, _val111); } } struct.setHighlightsIsSet(true); } } } }