/** * Autogenerated by Thrift * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING */ package org.apache.cassandra.service; /* * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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. * */ import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.thrift.TBase; import org.apache.thrift.TBaseHelper; import org.apache.thrift.TException; import org.apache.thrift.TFieldRequirementType; import org.apache.thrift.meta_data.FieldMetaData; import org.apache.thrift.meta_data.FieldValueMetaData; import org.apache.thrift.meta_data.ListMetaData; import org.apache.thrift.meta_data.StructMetaData; import org.apache.thrift.protocol.TField; import org.apache.thrift.protocol.TList; import org.apache.thrift.protocol.TProtocol; import org.apache.thrift.protocol.TProtocolUtil; import org.apache.thrift.protocol.TStruct; import org.apache.thrift.protocol.TType; /** * A SlicePredicate is similar to a mathematic predicate (see * http://en.wikipedia.org/wiki/Predicate_(mathematical_logic)), which is * described as "a property that the elements of a set have in common." * * SlicePredicate's in Cassandra are described with either a list of * column_names or a SliceRange. If column_names is specified, slice_range is * ignored. * * @param column_name * . A list of column names to retrieve. This can be used similar to * Memcached's "multi-get" feature to fetch N known column names. For * instance, if you know you wish to fetch columns 'Joe', 'Jack', and * 'Jim' you can pass those column names as a list to fetch all three * at once. * @param slice_range * . A SliceRange describing how to range, order, and/or limit the * slice. */ public class SlicePredicate implements TBase, java.io.Serializable, Cloneable, Comparable<SlicePredicate> { /** * */ private static final long serialVersionUID = 1L; private static final TStruct STRUCT_DESC = new TStruct("SlicePredicate"); private static final TField COLUMN_NAMES_FIELD_DESC = new TField("column_names", TType.LIST, (short) 1); private static final TField SLICE_RANGE_FIELD_DESC = new TField("slice_range", TType.STRUCT, (short) 2); public List<byte[]> column_names; public SliceRange slice_range; public static final int COLUMN_NAMES = 1; public static final int SLICE_RANGE = 2; // isset id assignments public static final Map<Integer, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new HashMap<Integer, FieldMetaData>() { /** * */ private static final long serialVersionUID = 1L; { put(COLUMN_NAMES, new FieldMetaData("column_names", TFieldRequirementType.OPTIONAL, new ListMetaData(TType.LIST, new FieldValueMetaData(TType.STRING)))); put(SLICE_RANGE, new FieldMetaData("slice_range", TFieldRequirementType.OPTIONAL, new StructMetaData(TType.STRUCT, SliceRange.class))); } }); static { FieldMetaData.addStructMetaDataMap(SlicePredicate.class, metaDataMap); } public SlicePredicate() { } public SlicePredicate(List<byte[]> column_names, SliceRange slice_range) { this(); this.column_names = column_names; this.slice_range = slice_range; } /** * Performs a deep copy on <i>other</i>. */ public SlicePredicate(SlicePredicate other) { if (other.isSetColumn_names()) { List<byte[]> __this__column_names = new ArrayList<byte[]>(); for (byte[] other_element : other.column_names) { byte[] temp_binary_element = new byte[other_element.length]; System.arraycopy(other_element, 0, temp_binary_element, 0, other_element.length); __this__column_names.add(temp_binary_element); } this.column_names = __this__column_names; } if (other.isSetSlice_range()) { this.slice_range = new SliceRange(other.slice_range); } } public SlicePredicate deepCopy() { return new SlicePredicate(this); } @Override @Deprecated public SlicePredicate clone() { return new SlicePredicate(this); } public int getColumn_namesSize() { return (this.column_names == null) ? 0 : this.column_names.size(); } public java.util.Iterator<byte[]> getColumn_namesIterator() { return (this.column_names == null) ? null : this.column_names.iterator(); } public void addToColumn_names(byte[] elem) { if (this.column_names == null) { this.column_names = new ArrayList<byte[]>(); } this.column_names.add(elem); } public List<byte[]> getColumn_names() { return this.column_names; } public SlicePredicate setColumn_names(List<byte[]> column_names) { this.column_names = column_names; return this; } public void unsetColumn_names() { this.column_names = null; } // Returns true if field column_names is set (has been asigned a value) and // false otherwise public boolean isSetColumn_names() { return this.column_names != null; } public void setColumn_namesIsSet(boolean value) { if (!value) { this.column_names = null; } } public SliceRange getSlice_range() { return this.slice_range; } public SlicePredicate setSlice_range(SliceRange slice_range) { this.slice_range = slice_range; return this; } public void unsetSlice_range() { this.slice_range = null; } // Returns true if field slice_range is set (has been asigned a value) and // false otherwise public boolean isSetSlice_range() { return this.slice_range != null; } public void setSlice_rangeIsSet(boolean value) { if (!value) { this.slice_range = null; } } @SuppressWarnings("unchecked") public void setFieldValue(int fieldID, Object value) { switch (fieldID) { case COLUMN_NAMES: if (value == null) { unsetColumn_names(); } else { setColumn_names((List<byte[]>) value); } break; case SLICE_RANGE: if (value == null) { unsetSlice_range(); } else { setSlice_range((SliceRange) value); } break; default: throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!"); } } public Object getFieldValue(int fieldID) { switch (fieldID) { case COLUMN_NAMES: return getColumn_names(); case SLICE_RANGE: return getSlice_range(); default: throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!"); } } // Returns true if field corresponding to fieldID is set (has been asigned a // value) and false otherwise public boolean isSet(int fieldID) { switch (fieldID) { case COLUMN_NAMES: return isSetColumn_names(); case SLICE_RANGE: return isSetSlice_range(); default: throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!"); } } @Override public boolean equals(Object that) { if (that == null) return false; if (that instanceof SlicePredicate) return this.equals((SlicePredicate) that); return false; } public boolean equals(SlicePredicate that) { if (that == null) return false; boolean this_present_column_names = true && this.isSetColumn_names(); boolean that_present_column_names = true && that.isSetColumn_names(); if (this_present_column_names || that_present_column_names) { if (!(this_present_column_names && that_present_column_names)) return false; if (!this.column_names.equals(that.column_names)) return false; } boolean this_present_slice_range = true && this.isSetSlice_range(); boolean that_present_slice_range = true && that.isSetSlice_range(); if (this_present_slice_range || that_present_slice_range) { if (!(this_present_slice_range && that_present_slice_range)) return false; if (!this.slice_range.equals(that.slice_range)) return false; } return true; } @Override public int hashCode() { return 0; } public int compareTo(SlicePredicate other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; SlicePredicate typedOther = other; lastComparison = Boolean.valueOf(isSetColumn_names()).compareTo(isSetColumn_names()); if (lastComparison != 0) { return lastComparison; } lastComparison = TBaseHelper.compareTo(column_names, typedOther.column_names); if (lastComparison != 0) { return lastComparison; } lastComparison = Boolean.valueOf(isSetSlice_range()).compareTo(isSetSlice_range()); if (lastComparison != 0) { return lastComparison; } lastComparison = TBaseHelper.compareTo(slice_range, typedOther.slice_range); if (lastComparison != 0) { return lastComparison; } return 0; } public void read(TProtocol iprot) throws TException { TField field; iprot.readStructBegin(); while (true) { field = iprot.readFieldBegin(); if (field.type == TType.STOP) { break; } switch (field.id) { case COLUMN_NAMES: if (field.type == TType.LIST) { { TList _list4 = iprot.readListBegin(); this.column_names = new ArrayList<byte[]>(_list4.size); for (int _i5 = 0; _i5 < _list4.size; ++_i5) { byte[] _elem6; _elem6 = iprot.readBinary(); this.column_names.add(_elem6); } iprot.readListEnd(); } } else { TProtocolUtil.skip(iprot, field.type); } break; case SLICE_RANGE: if (field.type == TType.STRUCT) { this.slice_range = new SliceRange(); this.slice_range.read(iprot); } else { TProtocolUtil.skip(iprot, field.type); } break; default: TProtocolUtil.skip(iprot, field.type); break; } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked // in the validate method validate(); } public void write(TProtocol oprot) throws TException { validate(); oprot.writeStructBegin(STRUCT_DESC); if (this.column_names != null) { if (isSetColumn_names()) { oprot.writeFieldBegin(COLUMN_NAMES_FIELD_DESC); { oprot.writeListBegin(new TList(TType.STRING, this.column_names.size())); for (byte[] _iter7 : this.column_names) { oprot.writeBinary(_iter7); } oprot.writeListEnd(); } oprot.writeFieldEnd(); } } if (this.slice_range != null) { if (isSetSlice_range()) { oprot.writeFieldBegin(SLICE_RANGE_FIELD_DESC); this.slice_range.write(oprot); oprot.writeFieldEnd(); } } oprot.writeFieldStop(); oprot.writeStructEnd(); } @Override public String toString() { StringBuilder sb = new StringBuilder("SlicePredicate("); boolean first = true; if (isSetColumn_names()) { sb.append("column_names:"); if (this.column_names == null) { sb.append("null"); } else { sb.append(this.column_names); } first = false; } if (isSetSlice_range()) { if (!first) sb.append(", "); sb.append("slice_range:"); if (this.slice_range == null) { sb.append("null"); } else { sb.append(this.slice_range); } first = false; } sb.append(")"); return sb.toString(); } public void validate() throws TException { // check for required fields // check that fields of type enum have valid values } }