Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* 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;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hive.ql.exec.persistence.RowContainer;
import org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat;
import org.apache.hadoop.hive.ql.metadata.HiveException;
import org.apache.hadoop.hive.ql.plan.ExprNodeDesc;
import org.apache.hadoop.hive.ql.plan.JoinDesc;
import org.apache.hadoop.hive.ql.plan.TableDesc;
import org.apache.hadoop.hive.serde.serdeConstants;
import org.apache.hadoop.hive.serde2.SerDe;
import org.apache.hadoop.hive.serde2.SerDeException;
import org.apache.hadoop.hive.serde2.SerDeUtils;
import org.apache.hadoop.hive.serde2.io.ShortWritable;
import org.apache.hadoop.hive.serde2.lazybinary.LazyBinarySerDe;
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorFactory;
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorUtils;
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorUtils.ObjectInspectorCopyOption;
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector;
import org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector;
import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
import org.apache.hadoop.mapred.Reporter;
import org.apache.hadoop.mapred.SequenceFileInputFormat;
import org.apache.hadoop.util.ReflectionUtils;
public class JoinUtil {
public static List[] getObjectInspectorsFromEvaluators(
List[] exprEntries,
ObjectInspector[] inputObjInspector,
int posBigTableAlias, int tagLen) throws HiveException {
List[] result = new List[tagLen];
int iterate = Math.min(exprEntries.length, inputObjInspector.length);
for (byte alias = 0; alias < iterate; alias++) {
if (alias == (byte) posBigTableAlias ||
exprEntries[alias] == null || inputObjInspector[alias] == null) {
// skip the driver and directly loadable tables
continue;
}
List exprList = exprEntries[alias];
List fieldOIList = new ArrayList();
for (int i = 0; i < exprList.size(); i++) {
fieldOIList.add(exprList.get(i).initialize(inputObjInspector[alias]));
}
result[alias] = fieldOIList;
}
return result;
}
public static List[] getStandardObjectInspectors(
List[] aliasToObjectInspectors,
int posBigTableAlias, int tagLen) {
List[] result = new List[tagLen];
for (byte alias = 0; alias < aliasToObjectInspectors.length; alias++) {
//get big table
if(alias == (byte) posBigTableAlias || aliasToObjectInspectors[alias] == null){
//skip the big tables
continue;
}
List oiList = aliasToObjectInspectors[alias];
ArrayList fieldOIList = new ArrayList(
oiList.size());
for (int i = 0; i < oiList.size(); i++) {
fieldOIList.add(ObjectInspectorUtils.getStandardObjectInspector(oiList
.get(i), ObjectInspectorCopyOption.WRITABLE));
}
result[alias] = fieldOIList;
}
return result;
}
public static int populateJoinKeyValue(List[] outMap,
Map> inputMap, int posBigTableAlias) throws HiveException {
return populateJoinKeyValue(outMap, inputMap, null, posBigTableAlias);
}
public static int populateJoinKeyValue(List[] outMap,
Map> inputMap,
Byte[] order,
int posBigTableAlias) throws HiveException {
int total = 0;
for (Entry> e : inputMap.entrySet()) {
if (e.getValue() == null) {
continue;
}
Byte key = order == null ? e.getKey() : order[e.getKey()];
List valueFields = new ArrayList();
for (ExprNodeDesc expr : e.getValue()) {
if (key == (byte) posBigTableAlias) {
valueFields.add(null);
} else {
valueFields.add(ExprNodeEvaluatorFactory.get(expr));
}
}
outMap[key] = valueFields;
total += valueFields.size();
}
return total;
}
/**
* Return the key as a standard object. StandardObject can be inspected by a
* standard ObjectInspector.
*/
public static ArrayList