You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by he...@apache.org on 2010/11/12 07:12:47 UTC
svn commit: r1034276 [4/14] - in /hive/trunk: ./
ql/src/gen-javabean/org/apache/hadoop/hive/ql/plan/api/
ql/src/java/org/apache/hadoop/hive/ql/exec/
ql/src/java/org/apache/hadoop/hive/ql/exec/persistence/
ql/src/java/org/apache/hadoop/hive/ql/optimizer...
Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/JoinUtil.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/JoinUtil.java?rev=1034276&r1=1034275&r2=1034276&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/JoinUtil.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/JoinUtil.java Fri Nov 12 06:12:44 2010
@@ -1,305 +0,0 @@
-/**
- * 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.util;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-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.ExprNodeEvaluator;
-import org.apache.hadoop.hive.ql.exec.ExprNodeEvaluatorFactory;
-import org.apache.hadoop.hive.ql.exec.Utilities;
-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.serde2.SerDe;
-import org.apache.hadoop.hive.serde2.SerDeException;
-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.PrimitiveObjectInspector;
-import org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector;
-import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorUtils.ObjectInspectorCopyOption;
-import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
-import org.apache.hadoop.io.BooleanWritable;
-import org.apache.hadoop.mapred.SequenceFileInputFormat;
-import org.apache.hadoop.util.ReflectionUtils;
-
-public class JoinUtil {
-
- public static HashMap<Byte, List<ObjectInspector>> getObjectInspectorsFromEvaluators(
- Map<Byte, List<ExprNodeEvaluator>> exprEntries,
- ObjectInspector[] inputObjInspector,
- int posBigTableAlias) throws HiveException {
- HashMap<Byte, List<ObjectInspector>> result = new HashMap<Byte, List<ObjectInspector>>();
- for (Entry<Byte, List<ExprNodeEvaluator>> exprEntry : exprEntries
- .entrySet()) {
- Byte alias = exprEntry.getKey();
- //get big table
- if(alias == (byte) posBigTableAlias){
- //skip the big tables
- continue;
- }
-
- List<ExprNodeEvaluator> exprList = exprEntry.getValue();
- ArrayList<ObjectInspector> fieldOIList = new ArrayList<ObjectInspector>();
- for (int i = 0; i < exprList.size(); i++) {
- fieldOIList.add(exprList.get(i).initialize(inputObjInspector[alias]));
- }
- result.put(alias, fieldOIList);
- }
- return result;
- }
-
-
- public static HashMap<Byte, List<ObjectInspector>> getStandardObjectInspectors(
- Map<Byte, List<ObjectInspector>> aliasToObjectInspectors,
- int posBigTableAlias) {
- HashMap<Byte, List<ObjectInspector>> result = new HashMap<Byte, List<ObjectInspector>>();
- for (Entry<Byte, List<ObjectInspector>> oiEntry : aliasToObjectInspectors
- .entrySet()) {
- Byte alias = oiEntry.getKey();
-
- //get big table
- if(alias == (byte) posBigTableAlias ){
- //skip the big tables
- continue;
- }
-
- List<ObjectInspector> oiList = oiEntry.getValue();
- ArrayList<ObjectInspector> fieldOIList = new ArrayList<ObjectInspector>(
- oiList.size());
- for (int i = 0; i < oiList.size(); i++) {
- fieldOIList.add(ObjectInspectorUtils.getStandardObjectInspector(oiList
- .get(i), ObjectInspectorCopyOption.WRITABLE));
- }
- result.put(alias, fieldOIList);
- }
- return result;
-
- }
- public static int populateJoinKeyValue(Map<Byte, List<ExprNodeEvaluator>> outMap,
- Map<Byte, List<ExprNodeDesc>> inputMap,
- Byte[] order,
- int posBigTableAlias) {
-
- int total = 0;
-
- Iterator<Map.Entry<Byte, List<ExprNodeDesc>>> entryIter = inputMap
- .entrySet().iterator();
- while (entryIter.hasNext()) {
- Map.Entry<Byte, List<ExprNodeDesc>> e = entryIter.next();
- Byte key = order[e.getKey()];
-
- List<ExprNodeEvaluator> valueFields = new ArrayList<ExprNodeEvaluator>();
-
- List<ExprNodeDesc> expr = e.getValue();
- int sz = expr.size();
- total += sz;
-
- for (int j = 0; j < sz; j++) {
- if(key == (byte) posBigTableAlias){
- valueFields.add(null);
- }else{
- valueFields.add(ExprNodeEvaluatorFactory.get(expr.get(j)));
- }
- }
-
- outMap.put(key, valueFields);
- }
-
- return total;
- }
-
-
- /**
- * Return the key as a standard object. StandardObject can be inspected by a
- * standard ObjectInspector.
- */
- public static ArrayList<Object> computeKeys(Object row,
- List<ExprNodeEvaluator> keyFields, List<ObjectInspector> keyFieldsOI)
- throws HiveException {
-
- // Compute the keys
- ArrayList<Object> nr = new ArrayList<Object>(keyFields.size());
- for (int i = 0; i < keyFields.size(); i++) {
-
- nr.add(ObjectInspectorUtils.copyToStandardObject(keyFields.get(i)
- .evaluate(row), keyFieldsOI.get(i),
- ObjectInspectorCopyOption.WRITABLE));
- }
-
- return nr;
- }
-
- /**
- * Return the value as a standard object. StandardObject can be inspected by a
- * standard ObjectInspector.
- */
- public static ArrayList<Object> computeValues(Object row,
- List<ExprNodeEvaluator> valueFields, List<ObjectInspector> valueFieldsOI,
- List<ExprNodeEvaluator> filters, List<ObjectInspector> filtersOI,
- boolean noOuterJoin) throws HiveException {
-
- // Compute the values
- ArrayList<Object> nr = new ArrayList<Object>(valueFields.size());
- for (int i = 0; i < valueFields.size(); i++) {
- nr.add(ObjectInspectorUtils.copyToStandardObject(valueFields.get(i)
- .evaluate(row), valueFieldsOI.get(i),
- ObjectInspectorCopyOption.WRITABLE));
- }
- if (!noOuterJoin) {
- // add whether the row is filtered or not.
- nr.add(new BooleanWritable(isFiltered(row, filters, filtersOI)));
- }
-
- return nr;
- }
- /**
- * Returns true if the row does not pass through filters.
- */
- protected static Boolean isFiltered(Object row,
- List<ExprNodeEvaluator> filters, List<ObjectInspector> ois)
- throws HiveException {
- // apply join filters on the row.
- Boolean ret = false;
- for (int j = 0; j < filters.size(); j++) {
- Object condition = filters.get(j).evaluate(row);
- ret = (Boolean) ((PrimitiveObjectInspector)
- ois.get(j)).getPrimitiveJavaObject(condition);
- if (ret == null || !ret) {
- return true;
- }
- }
- return false;
- }
-
- public static TableDesc getSpillTableDesc(Byte alias,
- Map<Byte, TableDesc> spillTableDesc,JoinDesc conf,
- boolean noOuterJoin) {
- if (spillTableDesc == null || spillTableDesc.size() == 0) {
- spillTableDesc = initSpillTables(conf,noOuterJoin);
- }
- return spillTableDesc.get(alias);
- }
-
- public static Map<Byte, TableDesc> getSpillTableDesc(
- Map<Byte, TableDesc> spillTableDesc,JoinDesc conf,
- boolean noOuterJoin) {
- if (spillTableDesc == null) {
- spillTableDesc = initSpillTables(conf,noOuterJoin);
- }
- return spillTableDesc;
- }
-
- public static SerDe getSpillSerDe(byte alias,
- Map<Byte, TableDesc> spillTableDesc,JoinDesc conf,
- boolean noOuterJoin) {
- TableDesc desc = getSpillTableDesc(alias,spillTableDesc,conf, noOuterJoin);
- if (desc == null) {
- return null;
- }
- SerDe sd = (SerDe) ReflectionUtils.newInstance(desc.getDeserializerClass(),
- null);
- try {
- sd.initialize(null, desc.getProperties());
- } catch (SerDeException e) {
- e.printStackTrace();
- return null;
- }
- return sd;
- }
-
- public static Map<Byte, TableDesc> initSpillTables(JoinDesc conf,boolean noOuterJoin) {
- Map<Byte, List<ExprNodeDesc>> exprs = conf.getExprs();
- Map<Byte, TableDesc> spillTableDesc = new HashMap<Byte, TableDesc>(exprs.size());
- for (int tag = 0; tag < exprs.size(); tag++) {
- List<ExprNodeDesc> valueCols = exprs.get((byte) tag);
- int columnSize = valueCols.size();
- StringBuilder colNames = new StringBuilder();
- StringBuilder colTypes = new StringBuilder();
- if (columnSize <= 0) {
- continue;
- }
- for (int k = 0; k < columnSize; k++) {
- String newColName = tag + "_VALUE_" + k; // any name, it does not
- // matter.
- colNames.append(newColName);
- colNames.append(',');
- colTypes.append(valueCols.get(k).getTypeString());
- colTypes.append(',');
- }
- if (!noOuterJoin) {
- colNames.append("filtered");
- colNames.append(',');
- colTypes.append(TypeInfoFactory.booleanTypeInfo.getTypeName());
- colTypes.append(',');
- }
- // remove the last ','
- colNames.setLength(colNames.length() - 1);
- colTypes.setLength(colTypes.length() - 1);
- TableDesc tblDesc = new TableDesc(LazyBinarySerDe.class,
- SequenceFileInputFormat.class, HiveSequenceFileOutputFormat.class,
- Utilities.makeProperties(
- org.apache.hadoop.hive.serde.Constants.SERIALIZATION_FORMAT, ""
- + Utilities.ctrlaCode,
- org.apache.hadoop.hive.serde.Constants.LIST_COLUMNS, colNames
- .toString(),
- org.apache.hadoop.hive.serde.Constants.LIST_COLUMN_TYPES,
- colTypes.toString()));
- spillTableDesc.put((byte) tag, tblDesc);
- }
- return spillTableDesc;
- }
-
-
- public static RowContainer getRowContainer(Configuration hconf,
- List<ObjectInspector> structFieldObjectInspectors,
- Byte alias,int containerSize, Map<Byte, TableDesc> spillTableDesc,
- JoinDesc conf,boolean noOuterJoin) throws HiveException {
-
- TableDesc tblDesc = JoinUtil.getSpillTableDesc(alias,spillTableDesc,conf, noOuterJoin);
- SerDe serde = JoinUtil.getSpillSerDe(alias,spillTableDesc,conf,noOuterJoin);
-
- if (serde == null) {
- containerSize = 1;
- }
-
- RowContainer rc = new RowContainer(containerSize, hconf);
- StructObjectInspector rcOI = null;
- if (tblDesc != null) {
- // arbitrary column names used internally for serializing to spill table
- List<String> colNames = Utilities.getColumnNames(tblDesc.getProperties());
- // object inspector for serializing input tuples
- rcOI = ObjectInspectorFactory.getStandardStructObjectInspector(colNames,
- structFieldObjectInspectors);
- }
-
- rc.setSerDe(serde, rcOI);
- rc.setTableDesc(tblDesc);
- return rc;
- }
-}
Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/RecordManager.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/RecordManager.java?rev=1034276&r1=1034275&r2=1034276&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/RecordManager.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/RecordManager.java Fri Nov 12 06:12:44 2010
@@ -1,231 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * JDBM LICENSE v1.00
- *
- * Redistribution and use of this software and associated documentation
- * ("Software"), with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * 1. Redistributions of source code must retain copyright
- * statements and notices. Redistributions must also contain a
- * copy of this document.
- *
- * 2. Redistributions in binary form must reproduce the
- * above copyright notice, this list of conditions and the
- * following disclaimer in the documentation and/or other
- * materials provided with the distribution.
- *
- * 3. The name "JDBM" must not be used to endorse or promote
- * products derived from this Software without prior written
- * permission of Cees de Groot. For written permission,
- * please contact cg@cdegroot.com.
- *
- * 4. Products derived from this Software may not be called "JDBM"
- * nor may "JDBM" appear in their names without prior written
- * permission of Cees de Groot.
- *
- * 5. Due credit should be given to the JDBM Project
- * (http://jdbm.sourceforge.net/).
- *
- * THIS SOFTWARE IS PROVIDED BY THE JDBM PROJECT AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
- * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * CEES DE GROOT OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * Copyright 2000 (C) Cees de Groot. All Rights Reserved.
- * Copyright 2000-2001 (C) Alex Boisvert. All Rights Reserved.
- * Contributions are Copyright (C) 2000 by their associated contributors.
- *
- * $Id: RecordManager.java,v 1.3 2005/06/25 23:12:31 doomdark Exp $
- */
-
-package org.apache.hadoop.hive.ql.util.jdbm;
-
-import java.io.IOException;
-
-import org.apache.hadoop.hive.ql.util.jdbm.helper.Serializer;
-
-/**
- * An interface to manages records, which are uninterpreted blobs of data.
- * <p>
- * The set of record operations is simple: fetch, insert, update and delete.
- * Each record is identified using a "rowid" and contains a byte[] data block.
- * Rowids are returned on inserts and you can store them someplace safe to be
- * able to get back to them. Data blocks can be as long as you wish, and may
- * have lengths different from the original when updating.
- *
- * @author <a href="mailto:boisvert@intalio.com">Alex Boisvert</a>
- * @author <a href="cg@cdegroot.com">Cees de Groot</a>
- * @version $Id: RecordManager.java,v 1.3 2005/06/25 23:12:31 doomdark Exp $
- */
-public interface RecordManager {
-
- /**
- * Reserved slot for name directory.
- */
- public static final int NAME_DIRECTORY_ROOT = 0;
-
- /**
- * Inserts a new record using standard java object serialization.
- *
- * @param obj
- * the object for the new record.
- * @return the rowid for the new record.
- * @throws IOException
- * when one of the underlying I/O operations fails.
- */
- public abstract long insert(Object obj) throws IOException;
-
- /**
- * Inserts a new record using a custom serializer.
- *
- * @param obj
- * the object for the new record.
- * @param serializer
- * a custom serializer
- * @return the rowid for the new record.
- * @throws IOException
- * when one of the underlying I/O operations fails.
- */
- public abstract long insert(Object obj, Serializer serializer)
- throws IOException;
-
- /**
- * Deletes a record.
- *
- * @param recid
- * the rowid for the record that should be deleted.
- * @throws IOException
- * when one of the underlying I/O operations fails.
- */
- public abstract void delete(long recid) throws IOException;
-
- /**
- * Updates a record using standard java object serialization.
- *
- * @param recid
- * the recid for the record that is to be updated.
- * @param obj
- * the new object for the record.
- * @throws IOException
- * when one of the underlying I/O operations fails.
- */
- public abstract void update(long recid, Object obj) throws IOException;
-
- /**
- * Updates a record using a custom serializer.
- *
- * @param recid
- * the recid for the record that is to be updated.
- * @param obj
- * the new object for the record.
- * @param serializer
- * a custom serializer
- * @throws IOException
- * when one of the underlying I/O operations fails.
- */
- public abstract void update(long recid, Object obj, Serializer serializer)
- throws IOException;
-
- /**
- * Fetches a record using standard java object serialization.
- *
- * @param recid
- * the recid for the record that must be fetched.
- * @return the object contained in the record.
- * @throws IOException
- * when one of the underlying I/O operations fails.
- */
- public abstract Object fetch(long recid) throws IOException;
-
- /**
- * Fetches a record using a custom serializer.
- *
- * @param recid
- * the recid for the record that must be fetched.
- * @param serializer
- * a custom serializer
- * @return the object contained in the record.
- * @throws IOException
- * when one of the underlying I/O operations fails.
- */
- public abstract Object fetch(long recid, Serializer serializer)
- throws IOException;
-
- /**
- * Closes the record manager.
- *
- * @throws IOException
- * when one of the underlying I/O operations fails.
- */
- public abstract void close() throws IOException;
-
- /**
- * Returns the number of slots available for "root" rowids. These slots can be
- * used to store special rowids, like rowids that point to other rowids. Root
- * rowids are useful for bootstrapping access to a set of data.
- */
- public abstract int getRootCount();
-
- /**
- * Returns the indicated root rowid.
- *
- * @see #getRootCount
- */
- public abstract long getRoot(int id) throws IOException;
-
- /**
- * Sets the indicated root rowid.
- *
- * @see #getRootCount
- */
- public abstract void setRoot(int id, long rowid) throws IOException;
-
- /**
- * Commit (make persistent) all changes since beginning of transaction.
- */
- public abstract void commit() throws IOException;
-
- /**
- * Rollback (cancel) all changes since beginning of transaction.
- */
- public abstract void rollback() throws IOException;
-
- /**
- * Obtain the record id of a named object. Returns 0 if named object doesn't
- * exist.
- */
- public abstract long getNamedObject(String name) throws IOException;
-
- /**
- * Set the record id of a named object.
- */
- public abstract void setNamedObject(String name, long recid)
- throws IOException;
-
-}
Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/RecordManagerFactory.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/RecordManagerFactory.java?rev=1034276&r1=1034275&r2=1034276&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/RecordManagerFactory.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/RecordManagerFactory.java Fri Nov 12 06:12:44 2010
@@ -1,147 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * JDBM LICENSE v1.00
- *
- * Redistribution and use of this software and associated documentation
- * ("Software"), with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * 1. Redistributions of source code must retain copyright
- * statements and notices. Redistributions must also contain a
- * copy of this document.
- *
- * 2. Redistributions in binary form must reproduce the
- * above copyright notice, this list of conditions and the
- * following disclaimer in the documentation and/or other
- * materials provided with the distribution.
- *
- * 3. The name "JDBM" must not be used to endorse or promote
- * products derived from this Software without prior written
- * permission of Cees de Groot. For written permission,
- * please contact cg@cdegroot.com.
- *
- * 4. Products derived from this Software may not be called "JDBM"
- * nor may "JDBM" appear in their names without prior written
- * permission of Cees de Groot.
- *
- * 5. Due credit should be given to the JDBM Project
- * (http://jdbm.sourceforge.net/).
- *
- * THIS SOFTWARE IS PROVIDED BY THE JDBM PROJECT AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
- * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * CEES DE GROOT OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * Copyright 2000 (C) Cees de Groot. All Rights Reserved.
- * Copyright 2000-2001 (C) Alex Boisvert. All Rights Reserved.
- * Contributions are Copyright (C) 2000 by their associated contributors.
- *
- * $Id: RecordManagerFactory.java,v 1.2 2005/06/25 23:12:31 doomdark Exp $
- */
-
-package org.apache.hadoop.hive.ql.util.jdbm;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Properties;
-
-/**
- * This is the factory class to use for instantiating {@link RecordManager}
- * instances.
- *
- * @author <a href="mailto:boisvert@intalio.com">Alex Boisvert</a>
- * @author <a href="cg@cdegroot.com">Cees de Groot</a>
- * @version $Id: RecordManagerFactory.java,v 1.2 2005/06/25 23:12:31 doomdark
- * Exp $
- */
-public final class RecordManagerFactory {
-
- /**
- * Create a record manager.
- *
- * @param name
- * Name of the record file.
- * @throws IOException
- * if an I/O related exception occurs while creating or opening the
- * record manager.
- * @throws UnsupportedOperationException
- * if some options are not supported by the implementation.
- * @throws IllegalArgumentException
- * if some options are invalid.
- */
- public static RecordManager createRecordManager(String name)
- throws IOException {
- return createRecordManager(name, new Properties());
- }
-
- /**
- * Create a record manager.
- *
- * @param name
- * Name of the record file.
- * @param options
- * Record manager options.
- * @throws IOException
- * if an I/O related exception occurs while creating or opening the
- * record manager.
- * @throws UnsupportedOperationException
- * if some options are not supported by the implementation.
- * @throws IllegalArgumentException
- * if some options are invalid.
- */
- public static RecordManager createRecordManager(String name,
- Properties options) throws IOException {
- RecordManagerProvider factory = getFactory(options);
- return factory.createRecordManager(name, options);
- }
-
- public static RecordManager createRecordManager(File file, Properties options)
- throws IOException {
- RecordManagerProvider factory = getFactory(options);
- return factory.createRecordManager(file, options);
- }
-
- private static RecordManagerProvider getFactory(Properties options) {
- String provider;
- Class clazz;
- RecordManagerProvider factory;
-
- provider = options.getProperty(RecordManagerOptions.PROVIDER_FACTORY,
- "org.apache.hadoop.hive.ql.util.jdbm.recman.Provider");
-
- try {
- clazz = Class.forName(provider);
- factory = (RecordManagerProvider) clazz.newInstance();
- } catch (Exception except) {
- throw new IllegalArgumentException("Invalid record manager provider: "
- + provider + "\n[" + except.getClass().getName() + ": "
- + except.getMessage() + "]");
- }
- return factory;
- }
-}
Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/RecordManagerOptions.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/RecordManagerOptions.java?rev=1034276&r1=1034275&r2=1034276&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/RecordManagerOptions.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/RecordManagerOptions.java Fri Nov 12 06:12:44 2010
@@ -1,138 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * JDBM LICENSE v1.00
- *
- * Redistribution and use of this software and associated documentation
- * ("Software"), with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * 1. Redistributions of source code must retain copyright
- * statements and notices. Redistributions must also contain a
- * copy of this document.
- *
- * 2. Redistributions in binary form must reproduce the
- * above copyright notice, this list of conditions and the
- * following disclaimer in the documentation and/or other
- * materials provided with the distribution.
- *
- * 3. The name "JDBM" must not be used to endorse or promote
- * products derived from this Software without prior written
- * permission of Cees de Groot. For written permission,
- * please contact cg@cdegroot.com.
- *
- * 4. Products derived from this Software may not be called "JDBM"
- * nor may "JDBM" appear in their names without prior written
- * permission of Cees de Groot.
- *
- * 5. Due credit should be given to the JDBM Project
- * (http://jdbm.sourceforge.net/).
- *
- * THIS SOFTWARE IS PROVIDED BY THE JDBM PROJECT AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
- * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * CEES DE GROOT OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * Copyright 2000 (C) Cees de Groot. All Rights Reserved.
- * Copyright 2000-2001 (C) Alex Boisvert. All Rights Reserved.
- * Contributions are Copyright (C) 2000 by their associated contributors.
- *
- * $Id: RecordManagerOptions.java,v 1.1 2002/05/31 06:33:20 boisvert Exp $
- */
-
-package org.apache.hadoop.hive.ql.util.jdbm;
-
-/**
- * Standard options for RecordManager.
- *
- * @author <a href="mailto:boisvert@intalio.com">Alex Boisvert</a>
- * @author <a href="cg@cdegroot.com">Cees de Groot</a>
- * @version $Id: RecordManagerOptions.java,v 1.1 2002/05/31 06:33:20 boisvert
- * Exp $
- */
-public class RecordManagerOptions {
-
- /**
- * Option to create a thread-safe record manager.
- */
- public static final String PROVIDER_FACTORY = "jdbm.provider";
-
- /**
- * Option to create a thread-safe record manager.
- */
- public static final String THREAD_SAFE = "jdbm.threadSafe";
-
- /**
- * Option to automatically commit data after each operation.
- */
- public static final String AUTO_COMMIT = "jdbm.autoCommit";
-
- /**
- * Option to disable transaction (to increase performance at the cost of
- * potential data loss).
- */
- public static final String DISABLE_TRANSACTIONS = "jdbm.disableTransactions";
-
- /**
- * Cache type.
- */
- public static final String CACHE_TYPE = "jdbm.cache.type";
-
- /**
- * Cache size (when applicable)
- */
- public static final String CACHE_SIZE = "jdbm.cache.size";
-
- /**
- * Use normal (strong) object references for the record cache.
- */
- public static final String NORMAL_CACHE = "normal";
-
- /**
- * Use soft references {$link java.lang.ref.SoftReference} for the record
- * cache instead of the default normal object references.
- * <p>
- * Soft references are cleared at the discretion of the garbage collector in
- * response to memory demand.
- */
- public static final String SOFT_REF_CACHE = "soft";
-
- /**
- * Use weak references {$link java.lang.ref.WeakReference} for the record
- * cache instead of the default normal object references.
- * <p>
- * Weak references do not prevent their referents from being made finalizable,
- * finalized, and then reclaimed.
- */
- public static final String WEAK_REF_CACHE = "weak";
-
- /**
- * Disable cache.
- */
- public static final String NO_CACHE = "nocache";
-
-}
Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/RecordManagerProvider.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/RecordManagerProvider.java?rev=1034276&r1=1034275&r2=1034276&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/RecordManagerProvider.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/RecordManagerProvider.java Fri Nov 12 06:12:44 2010
@@ -1,103 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * JDBM LICENSE v1.00
- *
- * Redistribution and use of this software and associated documentation
- * ("Software"), with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * 1. Redistributions of source code must retain copyright
- * statements and notices. Redistributions must also contain a
- * copy of this document.
- *
- * 2. Redistributions in binary form must reproduce the
- * above copyright notice, this list of conditions and the
- * following disclaimer in the documentation and/or other
- * materials provided with the distribution.
- *
- * 3. The name "JDBM" must not be used to endorse or promote
- * products derived from this Software without prior written
- * permission of Cees de Groot. For written permission,
- * please contact cg@cdegroot.com.
- *
- * 4. Products derived from this Software may not be called "JDBM"
- * nor may "JDBM" appear in their names without prior written
- * permission of Cees de Groot.
- *
- * 5. Due credit should be given to the JDBM Project
- * (http://jdbm.sourceforge.net/).
- *
- * THIS SOFTWARE IS PROVIDED BY THE JDBM PROJECT AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
- * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * CEES DE GROOT OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * Copyright 2000 (C) Cees de Groot. All Rights Reserved.
- * Copyright 2000-2001 (C) Alex Boisvert. All Rights Reserved.
- * Contributions are Copyright (C) 2000 by their associated contributors.
- *
- * $Id: RecordManagerProvider.java,v 1.2 2005/06/25 23:12:31 doomdark Exp $
- */
-
-package org.apache.hadoop.hive.ql.util.jdbm;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Properties;
-
-/**
- * Provider of RecordManager implementation. Classes implementing this interface
- * act as a factory to provide implementations of RecordManager.
- *
- * @author <a href="mailto:boisvert@intalio.com">Alex Boisvert</a>
- * @version $Id: RecordManagerProvider.java,v 1.2 2005/06/25 23:12:31 doomdark
- * Exp $
- */
-public interface RecordManagerProvider {
-
- /**
- * Create a record manager.
- *
- * @param filename
- * Base filename of the record file.
- * @param options
- * Record manager options.
- * @throws IOException
- * if an I/O related exception occurs while creating or opening the
- * record manager.
- * @throws UnsupportedOperationException
- * if some options are not supported by the implementation.
- * @throws IllegalArgumentException
- * if some options are invalid.
- */
- public RecordManager createRecordManager(String filename, Properties options)
- throws IOException;
-
- public RecordManager createRecordManager(File file, Properties options)
- throws IOException;
-}
Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/helper/ByteArrayComparator.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/helper/ByteArrayComparator.java?rev=1034276&r1=1034275&r2=1034276&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/helper/ByteArrayComparator.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/helper/ByteArrayComparator.java Fri Nov 12 06:12:44 2010
@@ -1,149 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * JDBM LICENSE v1.00
- *
- * Redistribution and use of this software and associated documentation
- * ("Software"), with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * 1. Redistributions of source code must retain copyright
- * statements and notices. Redistributions must also contain a
- * copy of this document.
- *
- * 2. Redistributions in binary form must reproduce the
- * above copyright notice, this list of conditions and the
- * following disclaimer in the documentation and/or other
- * materials provided with the distribution.
- *
- * 3. The name "JDBM" must not be used to endorse or promote
- * products derived from this Software without prior written
- * permission of Cees de Groot. For written permission,
- * please contact cg@cdegroot.com.
- *
- * 4. Products derived from this Software may not be called "JDBM"
- * nor may "JDBM" appear in their names without prior written
- * permission of Cees de Groot.
- *
- * 5. Due credit should be given to the JDBM Project
- * (http://jdbm.sourceforge.net/).
- *
- * THIS SOFTWARE IS PROVIDED BY THE JDBM PROJECT AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
- * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * CEES DE GROOT OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * Copyright 2001 (C) Alex Boisvert. All Rights Reserved.
- * Contributions are Copyright (C) 2001 by their associated contributors.
- *
- */
-
-package org.apache.hadoop.hive.ql.util.jdbm.helper;
-
-import java.io.Serializable;
-import java.util.Comparator;
-
-/**
- * Comparator for byte arrays.
- *
- * @author <a href="mailto:boisvert@intalio.com">Alex Boisvert</a>
- * @version $Id: ByteArrayComparator.java,v 1.4 2002/05/31 06:33:20 boisvert Exp
- * $
- */
-public final class ByteArrayComparator implements Comparator, Serializable {
-
- /**
- * Version id for serialization.
- */
- final static long serialVersionUID = 1L;
-
- /**
- * Compare two objects.
- *
- * @param obj1
- * First object
- * @param obj2
- * Second object
- * @return a positive integer if obj1 > obj2, 0 if obj1 == obj2, and a
- * negative integer if obj1 < obj2
- */
- public int compare(Object obj1, Object obj2) {
- if (obj1 == null) {
- throw new IllegalArgumentException("Argument 'obj1' is null");
- }
-
- if (obj2 == null) {
- throw new IllegalArgumentException("Argument 'obj2' is null");
- }
-
- return compareByteArray((byte[]) obj1, (byte[]) obj2);
- }
-
- /**
- * Compare two byte arrays.
- */
- public static int compareByteArray(byte[] thisKey, byte[] otherKey) {
- int len = Math.min(thisKey.length, otherKey.length);
-
- // compare the byte arrays
- for (int i = 0; i < len; i++) {
- if (thisKey[i] >= 0) {
- if (otherKey[i] >= 0) {
- // both positive
- if (thisKey[i] < otherKey[i]) {
- return -1;
- } else if (thisKey[i] > otherKey[i]) {
- return 1;
- }
- } else {
- // otherKey is negative => greater (because MSB is 1)
- return -1;
- }
- } else {
- if (otherKey[i] >= 0) {
- // thisKey is negative => greater (because MSB is 1)
- return 1;
- } else {
- // both negative
- if (thisKey[i] < otherKey[i]) {
- return -1;
- } else if (thisKey[i] > otherKey[i]) {
- return 1;
- }
- }
- }
- }
- if (thisKey.length == otherKey.length) {
- return 0;
- }
- if (thisKey.length < otherKey.length) {
- return -1;
- }
- return 1;
- }
-
-}
Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/helper/ByteArraySerializer.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/helper/ByteArraySerializer.java?rev=1034276&r1=1034275&r2=1034276&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/helper/ByteArraySerializer.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/helper/ByteArraySerializer.java Fri Nov 12 06:12:44 2010
@@ -1,113 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * JDBM LICENSE v1.00
- *
- * Redistribution and use of this software and associated documentation
- * ("Software"), with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * 1. Redistributions of source code must retain copyright
- * statements and notices. Redistributions must also contain a
- * copy of this document.
- *
- * 2. Redistributions in binary form must reproduce the
- * above copyright notice, this list of conditions and the
- * following disclaimer in the documentation and/or other
- * materials provided with the distribution.
- *
- * 3. The name "JDBM" must not be used to endorse or promote
- * products derived from this Software without prior written
- * permission of Cees de Groot. For written permission,
- * please contact cg@cdegroot.com.
- *
- * 4. Products derived from this Software may not be called "JDBM"
- * nor may "JDBM" appear in their names without prior written
- * permission of Cees de Groot.
- *
- * 5. Due credit should be given to the JDBM Project
- * (http://jdbm.sourceforge.net/).
- *
- * THIS SOFTWARE IS PROVIDED BY THE JDBM PROJECT AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
- * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * CEES DE GROOT OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * Copyright 2001 (C) Alex Boisvert. All Rights Reserved.
- * Contributions are Copyright (C) 2001 by their associated contributors.
- *
- */
-
-package org.apache.hadoop.hive.ql.util.jdbm.helper;
-
-import java.io.IOException;
-
-/**
- * Serializer for byte arrays -- simple returns the byte array itself. No actual
- * serialization is performed.
- *
- * @author <a href="mailto:boisvert@intalio.com">Alex Boisvert</a>
- * @version $Id: ByteArraySerializer.java,v 1.1 2003/03/21 02:48:42 boisvert Exp
- * $
- */
-public final class ByteArraySerializer implements Serializer {
-
- /**
- * Version id for serialization.
- */
- final static long serialVersionUID = 1L;
-
- /**
- * Static instance.
- */
- public static final ByteArraySerializer INSTANCE = new ByteArraySerializer();
-
- /**
- * Serialize the content of an object into a byte array.
- *
- * @param obj
- * Object to serialize
- * @return a byte array representing the object's state
- *
- */
- public byte[] serialize(Object obj) throws IOException {
- return (byte[]) obj;
- }
-
- /**
- * Deserialize the content of an object from a byte array.
- *
- * @param serialized
- * Byte array representation of the object
- * @return deserialized object
- *
- */
- public Object deserialize(byte[] serialized) throws IOException {
- return serialized;
- }
-
-}
Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/helper/CacheEvictionException.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/helper/CacheEvictionException.java?rev=1034276&r1=1034275&r2=1034276&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/helper/CacheEvictionException.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/helper/CacheEvictionException.java Fri Nov 12 06:12:44 2010
@@ -1,89 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * JDBM LICENSE v1.00
- *
- * Redistribution and use of this software and associated documentation
- * ("Software"), with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * 1. Redistributions of source code must retain copyright
- * statements and notices. Redistributions must also contain a
- * copy of this document.
- *
- * 2. Redistributions in binary form must reproduce the
- * above copyright notice, this list of conditions and the
- * following disclaimer in the documentation and/or other
- * materials provided with the distribution.
- *
- * 3. The name "JDBM" must not be used to endorse or promote
- * products derived from this Software without prior written
- * permission of Cees de Groot. For written permission,
- * please contact cg@cdegroot.com.
- *
- * 4. Products derived from this Software may not be called "JDBM"
- * nor may "JDBM" appear in their names without prior written
- * permission of Cees de Groot.
- *
- * 5. Due credit should be given to the JDBM Project
- * (http://jdbm.sourceforge.net/).
- *
- * THIS SOFTWARE IS PROVIDED BY THE JDBM PROJECT AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
- * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * CEES DE GROOT OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * Copyright 2000 (C) Cees de Groot. All Rights Reserved.
- * Contributions are Copyright (C) 2000 by their associated contributors.
- *
- * $Id: CacheEvictionException.java,v 1.4 2003/10/21 15:43:20 boisvert Exp $
- */
-
-package org.apache.hadoop.hive.ql.util.jdbm.helper;
-
-/**
- * Exception that occurs during eviction of an object in the cache.
- *
- * @author <a href="mailto:boisvert@intalio.com">Alex Boisvert</a>
- * @version $Id: CacheEvictionException.java,v 1.4 2003/10/21 15:43:20 boisvert
- * Exp $
- */
-public class CacheEvictionException extends Exception {
-
- /**
- * Nested exception -- the original exception that occured, if any.
- */
- protected Exception _nested;
-
- public CacheEvictionException(Exception nested) {
- _nested = nested;
- }
-
- public Exception getNestedException() {
- return _nested;
- }
-}
Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/helper/CachePolicy.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/helper/CachePolicy.java?rev=1034276&r1=1034275&r2=1034276&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/helper/CachePolicy.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/helper/CachePolicy.java Fri Nov 12 06:12:44 2010
@@ -1,159 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * JDBM LICENSE v1.00
- *
- * Redistribution and use of this software and associated documentation
- * ("Software"), with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * 1. Redistributions of source code must retain copyright
- * statements and notices. Redistributions must also contain a
- * copy of this document.
- *
- * 2. Redistributions in binary form must reproduce the
- * above copyright notice, this list of conditions and the
- * following disclaimer in the documentation and/or other
- * materials provided with the distribution.
- *
- * 3. The name "JDBM" must not be used to endorse or promote
- * products derived from this Software without prior written
- * permission of Cees de Groot. For written permission,
- * please contact cg@cdegroot.com.
- *
- * 4. Products derived from this Software may not be called "JDBM"
- * nor may "JDBM" appear in their names without prior written
- * permission of Cees de Groot.
- *
- * 5. Due credit should be given to the JDBM Project
- * (http://jdbm.sourceforge.net/).
- *
- * THIS SOFTWARE IS PROVIDED BY THE JDBM PROJECT AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
- * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * CEES DE GROOT OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * Copyright 2000 (C) Cees de Groot. All Rights Reserved.
- * Contributions are Copyright (C) 2000 by their associated contributors.
- *
- * $Id: CachePolicy.java,v 1.5 2003/11/01 13:25:02 dranatunga Exp $
- */
-
-package org.apache.hadoop.hive.ql.util.jdbm.helper;
-
-import java.util.Enumeration;
-
-/**
- * CachePolicity is an abstraction for different cache policies. (ie. MRU,
- * time-based, soft-refs, ...)
- *
- * @author <a href="mailto:boisvert@intalio.com">Alex Boisvert</a>
- * @author <a href="mailto:dranatunga@users.sourceforge.net">Dilum Ranatunga</a>
- * @version $Id: CachePolicy.java,v 1.5 2003/11/01 13:25:02 dranatunga Exp $
- */
-public interface CachePolicy {
-
- /**
- * Place an object in the cache. If the cache does not currently contain an
- * object for the key specified, this mapping is added. If an object currently
- * exists under the specified key, the current object is replaced with the new
- * object.
- * <p>
- * If the changes to the cache cause the eviction of any objects
- * <strong>stored under other key(s)</strong>, events corresponding to the
- * evictions are fired for each object. If an event listener is unable to
- * handle the eviction, and throws a cache eviction exception, that exception
- * is propagated to the caller. If such an exception is thrown, the cache
- * itself should be left as it was before the <code>put()</code> operation was
- * invoked: the the object whose eviction failed is still in the cache, and
- * the new insertion or modification is reverted.
- *
- * @param key
- * key for the cached object
- * @param value
- * the cached object
- * @throws CacheEvictionException
- * propagated if, while evicting objects to make room for new
- * object, an eviction listener encountered this problem.
- */
- public void put(Object key, Object value) throws CacheEvictionException;
-
- /**
- * Obtain the object stored under the key specified.
- *
- * @param key
- * key the object was cached under
- * @return the object if it is still in the cache, null otherwise.
- */
- public Object get(Object key);
-
- /**
- * Remove the object stored under the key specified. Note that since eviction
- * notices are only fired when objects under <strong>different keys</strong>
- * are evicted, no event is fired for any object stored under this key (see
- * {@link #put(Object, Object) put( )}).
- *
- * @param key
- * key the object was stored in the cache under.
- */
- public void remove(Object key);
-
- /**
- * Remove all objects from the cache. Consistent with {@link #remove(Object)
- * remove( )}, no eviction notices are fired.
- */
- public void removeAll();
-
- /**
- * Enumerate through the objects currently in the cache.
- */
- public Enumeration elements();
-
- /**
- * Add a listener to this cache policy.
- * <p>
- * If this cache policy already contains a listener that is equal to the one
- * being added, this call has no effect.
- *
- * @param listener
- * the (non-null) listener to add to this policy
- * @throws IllegalArgumentException
- * if listener is null.
- */
- public void addListener(CachePolicyListener listener)
- throws IllegalArgumentException;
-
- /**
- * Remove a listener from this cache policy. The listener is found using
- * object equality, not identity.
- *
- * @param listener
- * the listener to remove from this policy
- */
- public void removeListener(CachePolicyListener listener);
-
-}
Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/helper/CachePolicyListener.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/helper/CachePolicyListener.java?rev=1034276&r1=1034275&r2=1034276&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/helper/CachePolicyListener.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/helper/CachePolicyListener.java Fri Nov 12 06:12:44 2010
@@ -1,97 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * JDBM LICENSE v1.00
- *
- * Redistribution and use of this software and associated documentation
- * ("Software"), with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * 1. Redistributions of source code must retain copyright
- * statements and notices. Redistributions must also contain a
- * copy of this document.
- *
- * 2. Redistributions in binary form must reproduce the
- * above copyright notice, this list of conditions and the
- * following disclaimer in the documentation and/or other
- * materials provided with the distribution.
- *
- * 3. The name "JDBM" must not be used to endorse or promote
- * products derived from this Software without prior written
- * permission of Cees de Groot. For written permission,
- * please contact cg@cdegroot.com.
- *
- * 4. Products derived from this Software may not be called "JDBM"
- * nor may "JDBM" appear in their names without prior written
- * permission of Cees de Groot.
- *
- * 5. Due credit should be given to the JDBM Project
- * (http://jdbm.sourceforge.net/).
- *
- * THIS SOFTWARE IS PROVIDED BY THE JDBM PROJECT AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
- * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * CEES DE GROOT OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * Copyright 2000 (C) Cees de Groot. All Rights Reserved.
- * Contributions are Copyright (C) 2000 by their associated contributors.
- *
- * $Id: CachePolicyListener.java,v 1.3 2003/11/01 13:25:41 dranatunga Exp $
- */
-
-package org.apache.hadoop.hive.ql.util.jdbm.helper;
-
-/**
- * Callback interface between {@link CachePolicy} and a Cache implementation to
- * notify about cached object eviction.
- * <p>
- * Note that <code>CachePolicy</code> implementations typically use
- * <em>object equality</em> when removing listeners, so concrete implementations
- * of this interface should also pay attention to their
- * {@link Object#equals(Object)} and {@link Object#hashCode()} methods.
- *
- * @author <a href="mailto:boisvert@intalio.com">Alex Boisvert</a>
- * @version $Id: CachePolicyListener.java,v 1.3 2003/11/01 13:25:41 dranatunga
- * Exp $
- */
-public interface CachePolicyListener {
-
- /**
- * Notification that the cache this listener is attached to is evicting the
- * object indicated.
- *
- * @param obj
- * object being evited from cache
- * @throws CacheEvictionException
- * if this listener encountered problems while preparing for the
- * specified object's eviction. For example, a listener may try to
- * persist the object to disk, and encounter an
- * <code>IOException</code>.
- */
- public void cacheObjectEvicted(Object obj) throws CacheEvictionException;
-
-}
Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/helper/Conversion.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/helper/Conversion.java?rev=1034276&r1=1034275&r2=1034276&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/helper/Conversion.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/helper/Conversion.java Fri Nov 12 06:12:44 2010
@@ -1,211 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * JDBM LICENSE v1.00
- *
- * Redistribution and use of this software and associated documentation
- * ("Software"), with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * 1. Redistributions of source code must retain copyright
- * statements and notices. Redistributions must also contain a
- * copy of this document.
- *
- * 2. Redistributions in binary form must reproduce the
- * above copyright notice, this list of conditions and the
- * following disclaimer in the documentation and/or other
- * materials provided with the distribution.
- *
- * 3. The name "JDBM" must not be used to endorse or promote
- * products derived from this Software without prior written
- * permission of Cees de Groot. For written permission,
- * please contact cg@cdegroot.com.
- *
- * 4. Products derived from this Software may not be called "JDBM"
- * nor may "JDBM" appear in their names without prior written
- * permission of Cees de Groot.
- *
- * 5. Due credit should be given to the JDBM Project
- * (http://jdbm.sourceforge.net/).
- *
- * THIS SOFTWARE IS PROVIDED BY THE JDBM PROJECT AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
- * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * CEES DE GROOT OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * Copyright 2001 (C) Alex Boisvert. All Rights Reserved.
- * Contributions are Copyright (C) 2001 by their associated contributors.
- *
- */
-
-package org.apache.hadoop.hive.ql.util.jdbm.helper;
-
-/**
- * Miscelaneous conversion utility methods.
- *
- * @author <a href="mailto:boisvert@intalio.com">Alex Boisvert</a>
- * @version $Id: Conversion.java,v 1.3 2002/05/31 06:33:20 boisvert Exp $
- */
-public class Conversion {
-
- /**
- * Convert a string into a byte array.
- */
- public static byte[] convertToByteArray(String s) {
- try {
- // see the following page for character encoding
- // http://java.sun.com/products/jdk/1.1/docs/guide/intl/encoding.doc.html
- return s.getBytes("UTF8");
- } catch (java.io.UnsupportedEncodingException uee) {
- uee.printStackTrace();
- throw new Error("Platform doesn't support UTF8 encoding");
- }
- }
-
- /**
- * Convert a byte into a byte array.
- */
- public static byte[] convertToByteArray(byte n) {
- n = (byte) (n ^ ((byte) 0x80)); // flip MSB because "byte" is signed
- return new byte[] {n};
- }
-
- /**
- * Convert a short into a byte array.
- */
- public static byte[] convertToByteArray(short n) {
- n = (short) (n ^ ((short) 0x8000)); // flip MSB because "short" is signed
- byte[] key = new byte[2];
- pack2(key, 0, n);
- return key;
- }
-
- /**
- * Convert an int into a byte array.
- */
- public static byte[] convertToByteArray(int n) {
- n = (n ^ 0x80000000); // flip MSB because "int" is signed
- byte[] key = new byte[4];
- pack4(key, 0, n);
- return key;
- }
-
- /**
- * Convert a long into a byte array.
- */
- public static byte[] convertToByteArray(long n) {
- n = (n ^ 0x8000000000000000L); // flip MSB because "long" is signed
- byte[] key = new byte[8];
- pack8(key, 0, n);
- return key;
- }
-
- /**
- * Convert a byte array (encoded as UTF-8) into a String
- */
- public static String convertToString(byte[] buf) {
- try {
- // see the following page for character encoding
- // http://java.sun.com/products/jdk/1.1/docs/guide/intl/encoding.doc.html
- return new String(buf, "UTF8");
- } catch (java.io.UnsupportedEncodingException uee) {
- uee.printStackTrace();
- throw new Error("Platform doesn't support UTF8 encoding");
- }
- }
-
- /**
- * Convert a byte array into an integer (signed 32-bit) value.
- */
- public static int convertToInt(byte[] buf) {
- int value = unpack4(buf, 0);
- value = (value ^ 0x80000000); // flip MSB because "int" is signed
- return value;
- }
-
- /**
- * Convert a byte array into a long (signed 64-bit) value.
- */
- public static long convertToLong(byte[] buf) {
- long value = ((long) unpack4(buf, 0) << 32)
- + (unpack4(buf, 4) & 0xFFFFFFFFL);
- value = (value ^ 0x8000000000000000L); // flip MSB because "long" is signed
- return value;
- }
-
- static int unpack4(byte[] buf, int offset) {
- int value = (buf[offset] << 24) | ((buf[offset + 1] << 16) & 0x00FF0000)
- | ((buf[offset + 2] << 8) & 0x0000FF00)
- | ((buf[offset + 3] << 0) & 0x000000FF);
-
- return value;
- }
-
- static final void pack2(byte[] data, int offs, int val) {
- data[offs++] = (byte) (val >> 8);
- data[offs++] = (byte) val;
- }
-
- static final void pack4(byte[] data, int offs, int val) {
- data[offs++] = (byte) (val >> 24);
- data[offs++] = (byte) (val >> 16);
- data[offs++] = (byte) (val >> 8);
- data[offs++] = (byte) val;
- }
-
- static final void pack8(byte[] data, int offs, long val) {
- pack4(data, 0, (int) (val >> 32));
- pack4(data, 4, (int) val);
- }
-
- /**
- * Test static methods
- */
- public static void main(String[] args) {
- byte[] buf;
-
- buf = convertToByteArray(5);
- System.out.println("int value of 5 is: " + convertToInt(buf));
-
- buf = convertToByteArray(-1);
- System.out.println("int value of -1 is: " + convertToInt(buf));
-
- buf = convertToByteArray(22111000);
- System.out.println("int value of 22111000 is: " + convertToInt(buf));
-
- buf = convertToByteArray(5L);
- System.out.println("long value of 5 is: " + convertToLong(buf));
-
- buf = convertToByteArray(-1L);
- System.out.println("long value of -1 is: " + convertToLong(buf));
-
- buf = convertToByteArray(1112223334445556667L);
- System.out.println("long value of 1112223334445556667 is: "
- + convertToLong(buf));
- }
-
-}
Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/helper/DefaultSerializer.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/helper/DefaultSerializer.java?rev=1034276&r1=1034275&r2=1034276&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/helper/DefaultSerializer.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/helper/DefaultSerializer.java Fri Nov 12 06:12:44 2010
@@ -1,112 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * JDBM LICENSE v1.00
- *
- * Redistribution and use of this software and associated documentation
- * ("Software"), with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * 1. Redistributions of source code must retain copyright
- * statements and notices. Redistributions must also contain a
- * copy of this document.
- *
- * 2. Redistributions in binary form must reproduce the
- * above copyright notice, this list of conditions and the
- * following disclaimer in the documentation and/or other
- * materials provided with the distribution.
- *
- * 3. The name "JDBM" must not be used to endorse or promote
- * products derived from this Software without prior written
- * permission of Cees de Groot. For written permission,
- * please contact cg@cdegroot.com.
- *
- * 4. Products derived from this Software may not be called "JDBM"
- * nor may "JDBM" appear in their names without prior written
- * permission of Cees de Groot.
- *
- * 5. Due credit should be given to the JDBM Project
- * (http://jdbm.sourceforge.net/).
- *
- * THIS SOFTWARE IS PROVIDED BY THE JDBM PROJECT AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
- * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * CEES DE GROOT OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * Copyright 2001 (C) Alex Boisvert. All Rights Reserved.
- * Contributions are Copyright (C) 2001 by their associated contributors.
- *
- */
-
-package org.apache.hadoop.hive.ql.util.jdbm.helper;
-
-import java.io.IOException;
-
-/**
- * Default java serializer.
- *
- * @author <a href="mailto:boisvert@intalio.com">Alex Boisvert</a>
- * @version $Id: DefaultSerializer.java,v 1.2 2003/09/21 15:47:00 boisvert Exp $
- */
-public class DefaultSerializer implements Serializer {
-
- public static final DefaultSerializer INSTANCE = new DefaultSerializer();
-
- /**
- * Construct a DefaultSerializer.
- */
- public DefaultSerializer() {
- // no op
- }
-
- /**
- * Serialize the content of an object into a byte array.
- *
- * @param obj
- * Object to serialize
- * @return a byte array representing the object's state
- */
- public byte[] serialize(Object obj) throws IOException {
- return Serialization.serialize(obj);
- }
-
- /**
- * Deserialize the content of an object from a byte array.
- *
- * @param serialized
- * Byte array representation of the object
- * @return deserialized object
- */
- public Object deserialize(byte[] serialized) throws IOException {
- try {
- return Serialization.deserialize(serialized);
- } catch (ClassNotFoundException except) {
- throw new WrappedRuntimeException(except);
- }
- }
-
-}
Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/helper/FastIterator.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/helper/FastIterator.java?rev=1034276&r1=1034275&r2=1034276&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/helper/FastIterator.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/helper/FastIterator.java Fri Nov 12 06:12:44 2010
@@ -1,83 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * JDBM LICENSE v1.00
- *
- * Redistribution and use of this software and associated documentation
- * ("Software"), with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * 1. Redistributions of source code must retain copyright
- * statements and notices. Redistributions must also contain a
- * copy of this document.
- *
- * 2. Redistributions in binary form must reproduce the
- * above copyright notice, this list of conditions and the
- * following disclaimer in the documentation and/or other
- * materials provided with the distribution.
- *
- * 3. The name "JDBM" must not be used to endorse or promote
- * products derived from this Software without prior written
- * permission of Cees de Groot. For written permission,
- * please contact cg@cdegroot.com.
- *
- * 4. Products derived from this Software may not be called "JDBM"
- * nor may "JDBM" appear in their names without prior written
- * permission of Cees de Groot.
- *
- * 5. Due credit should be given to the JDBM Project
- * (http://jdbm.sourceforge.net/).
- *
- * THIS SOFTWARE IS PROVIDED BY THE JDBM PROJECT AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
- * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * CEES DE GROOT OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * Copyright 2000 (C) Cees de Groot. All Rights Reserved.
- * Contributions are Copyright (C) 2000 by their associated contributors.
- *
- * $Id: FastIterator.java,v 1.2 2003/10/21 15:43:58 boisvert Exp $
- */
-
-package org.apache.hadoop.hive.ql.util.jdbm.helper;
-
-/**
- * Fast and simple iterator.
- *
- * @version $Revision: 1.2 $
- * @author <a href="boisvert@intalio.com">Alex Boisvert</a>
- */
-public abstract class FastIterator {
-
- /**
- * Returns the next element in the interation.
- *
- * @return the next element in the iteration, or null if no more element.
- */
- public abstract Object next() throws IterationException;
-
-}
Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/helper/IntegerComparator.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/helper/IntegerComparator.java?rev=1034276&r1=1034275&r2=1034276&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/helper/IntegerComparator.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/util/jdbm/helper/IntegerComparator.java Fri Nov 12 06:12:44 2010
@@ -1,121 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * JDBM LICENSE v1.00
- *
- * Redistribution and use of this software and associated documentation
- * ("Software"), with or without modification, are permitted provided
- * that the following conditions are met:
- *
- * 1. Redistributions of source code must retain copyright
- * statements and notices. Redistributions must also contain a
- * copy of this document.
- *
- * 2. Redistributions in binary form must reproduce the
- * above copyright notice, this list of conditions and the
- * following disclaimer in the documentation and/or other
- * materials provided with the distribution.
- *
- * 3. The name "JDBM" must not be used to endorse or promote
- * products derived from this Software without prior written
- * permission of Cees de Groot. For written permission,
- * please contact cg@cdegroot.com.
- *
- * 4. Products derived from this Software may not be called "JDBM"
- * nor may "JDBM" appear in their names without prior written
- * permission of Cees de Groot.
- *
- * 5. Due credit should be given to the JDBM Project
- * (http://jdbm.sourceforge.net/).
- *
- * THIS SOFTWARE IS PROVIDED BY THE JDBM PROJECT AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
- * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * CEES DE GROOT OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * Copyright 2001 (C) Alex Boisvert. All Rights Reserved.
- * Contributions are Copyright (C) 2001 by their associated contributors.
- *
- */
-
-package org.apache.hadoop.hive.ql.util.jdbm.helper;
-
-import java.io.Serializable;
-import java.util.Comparator;
-
-/**
- * Comparator for Integer objects.
- *
- * @author <a href="mailto:cdaller@iicm.edu">Christof Dallermassl</a>
- * @version $Id: IntegerComparator.java,v 1.2 2002/05/31 06:33:20 boisvert Exp $
- */
-public final class IntegerComparator implements Comparator, Serializable {
-
- /**
- * Version id for serialization.
- */
- final static long serialVersionUID = 1L;
-
- /**
- * Compare two objects.
- *
- * @param obj1
- * First object
- * @param obj2
- * Second object
- * @return a positive integer if obj1 > obj2, 0 if obj1 == obj2, and a
- * negative integer if obj1 < obj2
- */
- public int compare(Object obj1, Object obj2) {
- if (obj1 == obj2) {
- return 0;
- }
-
- if (obj1 == null) {
- throw new IllegalArgumentException("Argument 'obj1' is null");
- }
-
- if (obj2 == null) {
- throw new IllegalArgumentException("Argument 'obj2' is null");
- }
-
- // complicated to avoid usage of Integer.compareTo, as this
- // method is Java 1.2 only!
- int int1 = ((Integer) obj1).intValue();
- int int2 = ((Integer) obj2).intValue();
- if (int1 == int2) {
- return 0;
- }
-
- if (int1 < int2) {
- return -1;
- } else {
- return 1;
- }
- }
-
-}