@Override public <T> T accept(ExpressionVisitor<T> visitor) { List<T> l = acceptChildren(visitor, null); if (l.isEmpty()) { return visitor.defaultReturn(this, l); } return l.get(0); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; CoerceExpression other = (CoerceExpression)obj; if (maxLength == null) { if (other.maxLength != null) return false; } else if (!maxLength.equals(other.maxLength)) return false; if (toSortOrder != other.toSortOrder) return false; if (toType == null) { if (other.toType != null) return false; } else if (!toType.equals(other.toType)) return false; return rowKeyOrderOptimizable == other.rowKeyOrderOptimizable; }
@Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + ((maxLength == null) ? 0 : maxLength.hashCode()); result = prime * result + ((toSortOrder == null) ? 0 : toSortOrder.hashCode()); result = prime * result + ((toType == null) ? 0 : toType.hashCode()); return result; }
@Override public void readFields(DataInput input) throws IOException { super.readFields(input); isNegate = input.readBoolean(); }
@Override public void write(DataOutput output) throws IOException { super.write(output); output.writeBoolean(isNegate); }
@Override public boolean requiresFinalEvaluation() { return super.requiresFinalEvaluation() || !this.isNegate(); } }
@Override public void readFields(DataInput input) throws IOException { super.readFields(input); int ordinal = WritableUtils.readVInt(input); rowKeyOrderOptimizable = false; if (ordinal < 0) { rowKeyOrderOptimizable = true; ordinal = -(ordinal+1); } toType = PDataType.values()[ordinal]; toSortOrder = SortOrder.fromSystemValue(WritableUtils.readVInt(input)); int byteSize = WritableUtils.readVInt(input); this.maxLength = byteSize == -1 ? null : byteSize; }
@Override public void write(DataOutput output) throws IOException { super.write(output); output.writeBoolean(false); // Unused, but left for b/w compat. TODO: remove in next major release WritableUtils.writeVInt(output, fixedWidth); WritableUtils.writeVInt(output, valuesByteLength); for (ImmutableBytesPtr ptr : values) { output.write(ptr.get(), ptr.getOffset(), ptr.getLength()); } if (fixedWidth == -1) { WritableUtils.writeVInt(output, values.size()); for (ImmutableBytesPtr ptr : values) { WritableUtils.writeVInt(output, ptr.getLength()); } } }
@Override public boolean requiresFinalEvaluation() { return super.requiresFinalEvaluation() || !this.isNegate(); } }
@Override public void readFields(DataInput input) throws IOException { super.readFields(input); input.readBoolean(); // Unused, but left for b/w compat. TODO: remove in next major release fixedWidth = WritableUtils.readVInt(input); byte[] valuesBytes = Bytes.readByteArray(input); valuesByteLength = valuesBytes.length; int len = fixedWidth == -1 ? WritableUtils.readVInt(input) : valuesByteLength / fixedWidth; // TODO: consider using a regular HashSet as we never serialize from the server-side values = Sets.newLinkedHashSetWithExpectedSize(len); int offset = 0; int i = 0; if (i < len) { offset = readValue(input, valuesBytes, offset, minValue = new ImmutableBytesPtr()); while (++i < len-1) { offset = readValue(input, valuesBytes, offset, new ImmutableBytesPtr()); } if (i < len) { offset = readValue(input, valuesBytes, offset, maxValue = new ImmutableBytesPtr()); } else { maxValue = minValue; } } else { minValue = maxValue = new ImmutableBytesPtr(ByteUtil.EMPTY_BYTE_ARRAY); } }
@Override public void write(DataOutput output) throws IOException { super.write(output); if (rowKeyOrderOptimizable) { WritableUtils.writeVInt(output, -(toType.ordinal()+1)); } else { WritableUtils.writeVInt(output, toType.ordinal()); } WritableUtils.writeVInt(output, toSortOrder.getSystemValue()); WritableUtils.writeVInt(output, maxLength == null ? -1 : maxLength); }
@Override public <T> T accept(ExpressionVisitor<T> visitor) { List<T> l = acceptChildren(visitor, null); if (l.isEmpty()) { return visitor.defaultReturn(this, l); } return l.get(0); }
@Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + ((maxLength == null) ? 0 : maxLength.hashCode()); result = prime * result + ((toSortOrder == null) ? 0 : toSortOrder.hashCode()); result = prime * result + ((toType == null) ? 0 : toType.hashCode()); return result; }
@Override public boolean requiresFinalEvaluation() { return super.requiresFinalEvaluation() || !this.isNegate(); } }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; CoerceExpression other = (CoerceExpression)obj; if (maxLength == null) { if (other.maxLength != null) return false; } else if (!maxLength.equals(other.maxLength)) return false; if (toSortOrder != other.toSortOrder) return false; if (toType == null) { if (other.toType != null) return false; } else if (!toType.equals(other.toType)) return false; return rowKeyOrderOptimizable == other.rowKeyOrderOptimizable; }
@Override public void readFields(DataInput input) throws IOException { super.readFields(input); isNegate = input.readBoolean(); }
@Override public void write(DataOutput output) throws IOException { super.write(output); output.writeBoolean(isNegate); }
@Override public <T> T accept(ExpressionVisitor<T> visitor) { List<T> l = acceptChildren(visitor, null); if (l.isEmpty()) { return visitor.defaultReturn(this, l); } return l.get(0); }
@Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + ((maxLength == null) ? 0 : maxLength.hashCode()); result = prime * result + ((toSortOrder == null) ? 0 : toSortOrder.hashCode()); result = prime * result + ((toType == null) ? 0 : toType.hashCode()); return result; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; CoerceExpression other = (CoerceExpression)obj; if (maxLength == null) { if (other.maxLength != null) return false; } else if (!maxLength.equals(other.maxLength)) return false; if (toSortOrder != other.toSortOrder) return false; if (toType == null) { if (other.toType != null) return false; } else if (!toType.equals(other.toType)) return false; return rowKeyOrderOptimizable == other.rowKeyOrderOptimizable; }