org.apache.hadoop.hive.ql.exec.persistence.MapJoinDoubleKeys Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hive-exec Show documentation
Show all versions of hive-exec Show documentation
Hive is a data warehouse infrastructure built on top of Hadoop see
http://wiki.apache.org/hadoop/Hive
/**
* 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.
*/
package org.apache.hadoop.hive.ql.exec.persistence;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.ArrayList;
import org.apache.hadoop.hive.ql.exec.HashTableSinkOperator;
import org.apache.hadoop.hive.ql.exec.HashTableSinkOperator.HashTableSinkObjectCtx;
import org.apache.hadoop.hive.ql.exec.MapJoinMetaData;
import org.apache.hadoop.hive.ql.exec.MapJoinOperator;
import org.apache.hadoop.hive.serde2.SerDeException;
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorUtils;
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorUtils.ObjectInspectorCopyOption;
import org.apache.hadoop.io.Writable;
public class MapJoinDoubleKeys extends AbstractMapJoinKey {
protected transient Object obj1;
protected transient Object obj2;
public MapJoinDoubleKeys() {
}
/**
* @param obj1
* @param obj2
*/
public MapJoinDoubleKeys(Object obj1, Object obj2) {
this.obj1 = obj1;
this.obj2 = obj2;
}
@Override
public boolean equals(Object o) {
if (o instanceof MapJoinDoubleKeys) {
MapJoinDoubleKeys mObj = (MapJoinDoubleKeys) o;
Object key1 = mObj.getObj1();
Object key2 = mObj.getObj2();
if ((obj1 == null) && (key1 == null)) {
if ((obj2 == null) && (key2 == null)) {
return true;
}
}
if ((obj1 != null) && (key1 != null)) {
if (obj1.equals(key1)) {
if ((obj2 != null) && (key2 != null)) {
if (obj2.equals(key2)) {
return true;
}
}
}
}
}
return false;
}
@Override
public int hashCode() {
int hashCode = 1;
if (obj1 == null) {
hashCode = metadataTag;
} else {
hashCode += (31 + obj1.hashCode());
}
if (obj2 == null) {
hashCode += metadataTag;
} else {
hashCode += (31 + obj2.hashCode());
}
return hashCode;
}
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
try {
// get the tableDesc from the map stored in the mapjoin operator
HashTableSinkObjectCtx ctx = MapJoinOperator.getMetadata().get(Integer.valueOf(metadataTag));
Writable val = ctx.getSerDe().getSerializedClass().newInstance();
val.readFields(in);
ArrayList
© 2015 - 2025 Weber Informatics LLC | Privacy Policy