0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 package org.apache.hive.service.cli;
0019
0020 import org.apache.hive.service.rpc.thrift.TOperationHandle;
0021 import org.apache.hive.service.rpc.thrift.TProtocolVersion;
0022
0023 public class OperationHandle extends Handle {
0024
0025 private final OperationType opType;
0026 private final TProtocolVersion protocol;
0027 private boolean hasResultSet = false;
0028
0029 public OperationHandle(OperationType opType, TProtocolVersion protocol) {
0030 super();
0031 this.opType = opType;
0032 this.protocol = protocol;
0033 }
0034
0035
0036 public OperationHandle(TOperationHandle tOperationHandle) {
0037 this(tOperationHandle, TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V1);
0038 }
0039
0040 public OperationHandle(TOperationHandle tOperationHandle, TProtocolVersion protocol) {
0041 super(tOperationHandle.getOperationId());
0042 this.opType = OperationType.getOperationType(tOperationHandle.getOperationType());
0043 this.hasResultSet = tOperationHandle.isHasResultSet();
0044 this.protocol = protocol;
0045 }
0046
0047 public OperationType getOperationType() {
0048 return opType;
0049 }
0050
0051 public void setHasResultSet(boolean hasResultSet) {
0052 this.hasResultSet = hasResultSet;
0053 }
0054
0055 public boolean hasResultSet() {
0056 return hasResultSet;
0057 }
0058
0059 public TOperationHandle toTOperationHandle() {
0060 TOperationHandle tOperationHandle = new TOperationHandle();
0061 tOperationHandle.setOperationId(getHandleIdentifier().toTHandleIdentifier());
0062 tOperationHandle.setOperationType(opType.toTOperationType());
0063 tOperationHandle.setHasResultSet(hasResultSet);
0064 return tOperationHandle;
0065 }
0066
0067 public TProtocolVersion getProtocolVersion() {
0068 return protocol;
0069 }
0070
0071 @Override
0072 public int hashCode() {
0073 final int prime = 31;
0074 int result = super.hashCode();
0075 result = prime * result + ((opType == null) ? 0 : opType.hashCode());
0076 return result;
0077 }
0078
0079 @Override
0080 public boolean equals(Object obj) {
0081 if (this == obj) {
0082 return true;
0083 }
0084 if (!super.equals(obj)) {
0085 return false;
0086 }
0087 if (!(obj instanceof OperationHandle)) {
0088 return false;
0089 }
0090 OperationHandle other = (OperationHandle) obj;
0091 if (opType != other.opType) {
0092 return false;
0093 }
0094 return true;
0095 }
0096
0097 @Override
0098 public String toString() {
0099 return "OperationHandle [opType=" + opType + ", getHandleIdentifier()=" + getHandleIdentifier()
0100 + "]";
0101 }
0102 }