All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.twitter.flockdb.thrift.Results Maven / Gradle / Ivy

/**
 * Autogenerated by Thrift Compiler (0.8.0)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
package com.twitter.flockdb.thrift;

import org.apache.commons.lang.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 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 Results implements org.apache.thrift.TBase, java.io.Serializable, Cloneable {
  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Results");

  private static final org.apache.thrift.protocol.TField IDS_FIELD_DESC = new org.apache.thrift.protocol.TField("ids", org.apache.thrift.protocol.TType.STRING, (short)1);
  private static final org.apache.thrift.protocol.TField NEXT_CURSOR_FIELD_DESC = new org.apache.thrift.protocol.TField("next_cursor", org.apache.thrift.protocol.TType.I64, (short)2);
  private static final org.apache.thrift.protocol.TField PREV_CURSOR_FIELD_DESC = new org.apache.thrift.protocol.TField("prev_cursor", org.apache.thrift.protocol.TType.I64, (short)3);

  private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>();
  static {
    schemes.put(StandardScheme.class, new ResultsStandardSchemeFactory());
    schemes.put(TupleScheme.class, new ResultsTupleSchemeFactory());
  }

  public ByteBuffer ids; // required
  public long next_cursor; // required
  public long prev_cursor; // 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 {
    IDS((short)1, "ids"),
    NEXT_CURSOR((short)2, "next_cursor"),
    PREV_CURSOR((short)3, "prev_cursor");

    private static final Map byName = new HashMap();

    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: // IDS
          return IDS;
        case 2: // NEXT_CURSOR
          return NEXT_CURSOR;
        case 3: // PREV_CURSOR
          return PREV_CURSOR;
        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 __NEXT_CURSOR_ISSET_ID = 0;
  private static final int __PREV_CURSOR_ISSET_ID = 1;
  private BitSet __isset_bit_vector = new BitSet(2);
  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.IDS, new org.apache.thrift.meta_data.FieldMetaData("ids", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING        , true)));
    tmpMap.put(_Fields.NEXT_CURSOR, new org.apache.thrift.meta_data.FieldMetaData("next_cursor", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
    tmpMap.put(_Fields.PREV_CURSOR, new org.apache.thrift.meta_data.FieldMetaData("prev_cursor", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
    metaDataMap = Collections.unmodifiableMap(tmpMap);
    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Results.class, metaDataMap);
  }

  public Results() {
  }

  public Results(
    ByteBuffer ids,
    long next_cursor,
    long prev_cursor)
  {
    this();
    this.ids = ids;
    this.next_cursor = next_cursor;
    setNext_cursorIsSet(true);
    this.prev_cursor = prev_cursor;
    setPrev_cursorIsSet(true);
  }

  /**
   * Performs a deep copy on other.
   */
  public Results(Results other) {
    __isset_bit_vector.clear();
    __isset_bit_vector.or(other.__isset_bit_vector);
    if (other.isSetIds()) {
      this.ids = org.apache.thrift.TBaseHelper.copyBinary(other.ids);
;
    }
    this.next_cursor = other.next_cursor;
    this.prev_cursor = other.prev_cursor;
  }

  public Results deepCopy() {
    return new Results(this);
  }

  @Override
  public void clear() {
    this.ids = null;
    setNext_cursorIsSet(false);
    this.next_cursor = 0;
    setPrev_cursorIsSet(false);
    this.prev_cursor = 0;
  }

  public byte[] getIds() {
    setIds(org.apache.thrift.TBaseHelper.rightSize(ids));
    return ids == null ? null : ids.array();
  }

  public ByteBuffer bufferForIds() {
    return ids;
  }

  public Results setIds(byte[] ids) {
    setIds(ids == null ? (ByteBuffer)null : ByteBuffer.wrap(ids));
    return this;
  }

  public Results setIds(ByteBuffer ids) {
    this.ids = ids;
    return this;
  }

  public void unsetIds() {
    this.ids = null;
  }

  /** Returns true if field ids is set (has been assigned a value) and false otherwise */
  public boolean isSetIds() {
    return this.ids != null;
  }

  public void setIdsIsSet(boolean value) {
    if (!value) {
      this.ids = null;
    }
  }

  public long getNext_cursor() {
    return this.next_cursor;
  }

  public Results setNext_cursor(long next_cursor) {
    this.next_cursor = next_cursor;
    setNext_cursorIsSet(true);
    return this;
  }

  public void unsetNext_cursor() {
    __isset_bit_vector.clear(__NEXT_CURSOR_ISSET_ID);
  }

  /** Returns true if field next_cursor is set (has been assigned a value) and false otherwise */
  public boolean isSetNext_cursor() {
    return __isset_bit_vector.get(__NEXT_CURSOR_ISSET_ID);
  }

  public void setNext_cursorIsSet(boolean value) {
    __isset_bit_vector.set(__NEXT_CURSOR_ISSET_ID, value);
  }

  public long getPrev_cursor() {
    return this.prev_cursor;
  }

  public Results setPrev_cursor(long prev_cursor) {
    this.prev_cursor = prev_cursor;
    setPrev_cursorIsSet(true);
    return this;
  }

  public void unsetPrev_cursor() {
    __isset_bit_vector.clear(__PREV_CURSOR_ISSET_ID);
  }

  /** Returns true if field prev_cursor is set (has been assigned a value) and false otherwise */
  public boolean isSetPrev_cursor() {
    return __isset_bit_vector.get(__PREV_CURSOR_ISSET_ID);
  }

  public void setPrev_cursorIsSet(boolean value) {
    __isset_bit_vector.set(__PREV_CURSOR_ISSET_ID, value);
  }

  public void setFieldValue(_Fields field, Object value) {
    switch (field) {
    case IDS:
      if (value == null) {
        unsetIds();
      } else {
        setIds((ByteBuffer)value);
      }
      break;

    case NEXT_CURSOR:
      if (value == null) {
        unsetNext_cursor();
      } else {
        setNext_cursor((Long)value);
      }
      break;

    case PREV_CURSOR:
      if (value == null) {
        unsetPrev_cursor();
      } else {
        setPrev_cursor((Long)value);
      }
      break;

    }
  }

  public Object getFieldValue(_Fields field) {
    switch (field) {
    case IDS:
      return getIds();

    case NEXT_CURSOR:
      return Long.valueOf(getNext_cursor());

    case PREV_CURSOR:
      return Long.valueOf(getPrev_cursor());

    }
    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 IDS:
      return isSetIds();
    case NEXT_CURSOR:
      return isSetNext_cursor();
    case PREV_CURSOR:
      return isSetPrev_cursor();
    }
    throw new IllegalStateException();
  }

  @Override
  public boolean equals(Object that) {
    if (that == null)
      return false;
    if (that instanceof Results)
      return this.equals((Results)that);
    return false;
  }

  public boolean equals(Results that) {
    if (that == null)
      return false;

    boolean this_present_ids = true && this.isSetIds();
    boolean that_present_ids = true && that.isSetIds();
    if (this_present_ids || that_present_ids) {
      if (!(this_present_ids && that_present_ids))
        return false;
      if (!this.ids.equals(that.ids))
        return false;
    }

    boolean this_present_next_cursor = true;
    boolean that_present_next_cursor = true;
    if (this_present_next_cursor || that_present_next_cursor) {
      if (!(this_present_next_cursor && that_present_next_cursor))
        return false;
      if (this.next_cursor != that.next_cursor)
        return false;
    }

    boolean this_present_prev_cursor = true;
    boolean that_present_prev_cursor = true;
    if (this_present_prev_cursor || that_present_prev_cursor) {
      if (!(this_present_prev_cursor && that_present_prev_cursor))
        return false;
      if (this.prev_cursor != that.prev_cursor)
        return false;
    }

    return true;
  }

  @Override
  public int hashCode() {
    HashCodeBuilder builder = new HashCodeBuilder();

    boolean present_ids = true && (isSetIds());
    builder.append(present_ids);
    if (present_ids)
      builder.append(ids);

    boolean present_next_cursor = true;
    builder.append(present_next_cursor);
    if (present_next_cursor)
      builder.append(next_cursor);

    boolean present_prev_cursor = true;
    builder.append(present_prev_cursor);
    if (present_prev_cursor)
      builder.append(prev_cursor);

    return builder.toHashCode();
  }

  public int compareTo(Results other) {
    if (!getClass().equals(other.getClass())) {
      return getClass().getName().compareTo(other.getClass().getName());
    }

    int lastComparison = 0;
    Results typedOther = (Results)other;

    lastComparison = Boolean.valueOf(isSetIds()).compareTo(typedOther.isSetIds());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetIds()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.ids, typedOther.ids);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetNext_cursor()).compareTo(typedOther.isSetNext_cursor());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetNext_cursor()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.next_cursor, typedOther.next_cursor);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetPrev_cursor()).compareTo(typedOther.isSetPrev_cursor());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetPrev_cursor()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.prev_cursor, typedOther.prev_cursor);
      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("Results(");
    boolean first = true;

    sb.append("ids:");
    if (this.ids == null) {
      sb.append("null");
    } else {
      org.apache.thrift.TBaseHelper.toString(this.ids, sb);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("next_cursor:");
    sb.append(this.next_cursor);
    first = false;
    if (!first) sb.append(", ");
    sb.append("prev_cursor:");
    sb.append(this.prev_cursor);
    first = false;
    sb.append(")");
    return sb.toString();
  }

  public void validate() throws org.apache.thrift.TException {
    // check for required fields
  }

  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_bit_vector = new BitSet(1);
      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 ResultsStandardSchemeFactory implements SchemeFactory {
    public ResultsStandardScheme getScheme() {
      return new ResultsStandardScheme();
    }
  }

  private static class ResultsStandardScheme extends StandardScheme {

    public void read(org.apache.thrift.protocol.TProtocol iprot, Results 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: // IDS
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.ids = iprot.readBinary();
              struct.setIdsIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 2: // NEXT_CURSOR
            if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
              struct.next_cursor = iprot.readI64();
              struct.setNext_cursorIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 3: // PREV_CURSOR
            if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
              struct.prev_cursor = iprot.readI64();
              struct.setPrev_cursorIsSet(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, Results struct) throws org.apache.thrift.TException {
      struct.validate();

      oprot.writeStructBegin(STRUCT_DESC);
      if (struct.ids != null) {
        oprot.writeFieldBegin(IDS_FIELD_DESC);
        oprot.writeBinary(struct.ids);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldBegin(NEXT_CURSOR_FIELD_DESC);
      oprot.writeI64(struct.next_cursor);
      oprot.writeFieldEnd();
      oprot.writeFieldBegin(PREV_CURSOR_FIELD_DESC);
      oprot.writeI64(struct.prev_cursor);
      oprot.writeFieldEnd();
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

  }

  private static class ResultsTupleSchemeFactory implements SchemeFactory {
    public ResultsTupleScheme getScheme() {
      return new ResultsTupleScheme();
    }
  }

  private static class ResultsTupleScheme extends TupleScheme {

    @Override
    public void write(org.apache.thrift.protocol.TProtocol prot, Results struct) throws org.apache.thrift.TException {
      TTupleProtocol oprot = (TTupleProtocol) prot;
      BitSet optionals = new BitSet();
      if (struct.isSetIds()) {
        optionals.set(0);
      }
      if (struct.isSetNext_cursor()) {
        optionals.set(1);
      }
      if (struct.isSetPrev_cursor()) {
        optionals.set(2);
      }
      oprot.writeBitSet(optionals, 3);
      if (struct.isSetIds()) {
        oprot.writeBinary(struct.ids);
      }
      if (struct.isSetNext_cursor()) {
        oprot.writeI64(struct.next_cursor);
      }
      if (struct.isSetPrev_cursor()) {
        oprot.writeI64(struct.prev_cursor);
      }
    }

    @Override
    public void read(org.apache.thrift.protocol.TProtocol prot, Results struct) throws org.apache.thrift.TException {
      TTupleProtocol iprot = (TTupleProtocol) prot;
      BitSet incoming = iprot.readBitSet(3);
      if (incoming.get(0)) {
        struct.ids = iprot.readBinary();
        struct.setIdsIsSet(true);
      }
      if (incoming.get(1)) {
        struct.next_cursor = iprot.readI64();
        struct.setNext_cursorIsSet(true);
      }
      if (incoming.get(2)) {
        struct.prev_cursor = iprot.readI64();
        struct.setPrev_cursorIsSet(true);
      }
    }
  }

}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy