|
@@ -1,26 +1,16 @@
|
|
|
-/**
|
|
|
- * 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.
|
|
|
- */
|
|
|
// File generated by hadoop record compiler. Do not edit.
|
|
|
package org.apache.hadoop.record.test;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
+import org.apache.commons.logging.Log;
|
|
|
+import org.apache.commons.logging.LogFactory;
|
|
|
+import org.apache.hadoop.io.WritableComparator;
|
|
|
+import org.apache.hadoop.io.WritableComparable;
|
|
|
+import org.apache.hadoop.io.WritableUtils;
|
|
|
import org.apache.hadoop.io.Text;
|
|
|
|
|
|
-public class RecRecord1 implements org.apache.hadoop.record.Record, org.apache.hadoop.io.WritableComparable {
|
|
|
+public class RecRecord1 implements org.apache.hadoop.record.Record, WritableComparable {
|
|
|
+ private static final Log LOG= LogFactory.getLog("org.apache.hadoop.record.test.RecRecord1");
|
|
|
private boolean mBoolVal;
|
|
|
private byte mByteVal;
|
|
|
private int mIntVal;
|
|
@@ -299,8 +289,37 @@ public class RecRecord1 implements org.apache.hadoop.record.Record, org.apache.h
|
|
|
if (ret != 0) return ret;
|
|
|
ret = mStringVal.compareTo(peer.mStringVal);
|
|
|
if (ret != 0) return ret;
|
|
|
+ {
|
|
|
+ byte[] my = mBufferVal.toByteArray();
|
|
|
+ byte[] ur = peer.mBufferVal.toByteArray();
|
|
|
+ ret = WritableComparator.compareBytes(my,0,my.length,ur,0,ur.length);
|
|
|
+ }
|
|
|
if (ret != 0) return ret;
|
|
|
+ {
|
|
|
+ int len10 = mVectorVal.size();
|
|
|
+ int len20 = peer.mVectorVal.size();
|
|
|
+ for(int vidx0 = 0; vidx0<len10 && vidx0<len20; vidx0++) {
|
|
|
+ Text e10 = (Text) mVectorVal.get(vidx0);
|
|
|
+ Text e20 = (Text) peer.mVectorVal.get(vidx0);
|
|
|
+ ret = e10.compareTo(e20);
|
|
|
+ if (ret != 0) { return ret; }
|
|
|
+ }
|
|
|
+ ret = (len10 - len20);
|
|
|
+ }
|
|
|
if (ret != 0) return ret;
|
|
|
+ {
|
|
|
+ java.util.Set set10 = mMapVal.keySet();
|
|
|
+ java.util.Set set20 = peer.mMapVal.keySet();
|
|
|
+ java.util.Iterator miter10 = set10.iterator();
|
|
|
+ java.util.Iterator miter20 = set20.iterator();
|
|
|
+ for(; miter10.hasNext() && miter20.hasNext(); ) {
|
|
|
+ Text k10 = (Text) miter10.next();
|
|
|
+ Text k20 = (Text) miter20.next();
|
|
|
+ ret = k10.compareTo(k20);
|
|
|
+ if (ret != 0) { return ret; }
|
|
|
+ }
|
|
|
+ ret = (set10.size() - set20.size());
|
|
|
+ }
|
|
|
if (ret != 0) return ret;
|
|
|
ret = mRecordVal.compareTo(peer.mRecordVal);
|
|
|
if (ret != 0) return ret;
|
|
@@ -369,4 +388,242 @@ public class RecRecord1 implements org.apache.hadoop.record.Record, org.apache.h
|
|
|
public static String signature() {
|
|
|
return "LRecRecord1(zbilfdsB[s]{ss}LRecRecord0(s))";
|
|
|
}
|
|
|
+ public static class Comparator extends WritableComparator {
|
|
|
+ public Comparator() {
|
|
|
+ super(RecRecord1.class);
|
|
|
+ }
|
|
|
+ static public int slurpRaw(byte[] b, int s, int l) {
|
|
|
+ try {
|
|
|
+ int os = s;
|
|
|
+ {
|
|
|
+ if (l<1) {
|
|
|
+ throw new IOException("Boolean is exactly 1 byte. Provided buffer is smaller.");
|
|
|
+ }
|
|
|
+ s++; l--;
|
|
|
+ }
|
|
|
+ {
|
|
|
+ if (l<1) {
|
|
|
+ throw new IOException("Byte is exactly 1 byte. Provided buffer is smaller.");
|
|
|
+ }
|
|
|
+ s++; l--;
|
|
|
+ }
|
|
|
+ {
|
|
|
+ int i = WritableComparator.readVInt(b, s);
|
|
|
+ int z = WritableUtils.getVIntSize(i);
|
|
|
+ s+=z; l-=z;
|
|
|
+ }
|
|
|
+ {
|
|
|
+ long i = WritableComparator.readVLong(b, s);
|
|
|
+ int z = WritableUtils.getVIntSize(i);
|
|
|
+ s+=z; l-=z;
|
|
|
+ }
|
|
|
+ {
|
|
|
+ if (l<4) {
|
|
|
+ throw new IOException("Float is exactly 4 bytes. Provided buffer is smaller.");
|
|
|
+ }
|
|
|
+ s+=4; l-=4;
|
|
|
+ }
|
|
|
+ {
|
|
|
+ if (l<8) {
|
|
|
+ throw new IOException("Double is exactly 8 bytes. Provided buffer is smaller.");
|
|
|
+ }
|
|
|
+ s+=8; l-=8;
|
|
|
+ }
|
|
|
+ {
|
|
|
+ int i = WritableComparator.readVInt(b, s);
|
|
|
+ int z = WritableUtils.getVIntSize(i);
|
|
|
+ s+=(z+i); l-= (z+i);
|
|
|
+ }
|
|
|
+ {
|
|
|
+ int i = WritableComparator.readVInt(b, s);
|
|
|
+ int z = WritableUtils.getVIntSize(i);
|
|
|
+ s += z+i; l -= (z+i);
|
|
|
+ }
|
|
|
+ {
|
|
|
+ int vi1 = WritableComparator.readVInt(b, s);
|
|
|
+ int vz1 = WritableUtils.getVIntSize(vi1);
|
|
|
+ s+=vz1; l-=vz1;
|
|
|
+ for (int vidx1 = 0; vidx1 < vi1; vidx1++) {
|
|
|
+ int i = WritableComparator.readVInt(b, s);
|
|
|
+ int z = WritableUtils.getVIntSize(i);
|
|
|
+ s+=(z+i); l-= (z+i);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ {
|
|
|
+ int mi1 = WritableComparator.readVInt(b, s);
|
|
|
+ int mz1 = WritableUtils.getVIntSize(mi1);
|
|
|
+ s+=mz1; l-=mz1;
|
|
|
+ for (int midx1 = 0; midx1 < mi1; midx1++) { {
|
|
|
+ int i = WritableComparator.readVInt(b, s);
|
|
|
+ int z = WritableUtils.getVIntSize(i);
|
|
|
+ s+=(z+i); l-= (z+i);
|
|
|
+ }
|
|
|
+ {
|
|
|
+ int i = WritableComparator.readVInt(b, s);
|
|
|
+ int z = WritableUtils.getVIntSize(i);
|
|
|
+ s+=(z+i); l-= (z+i);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ {
|
|
|
+ int r = org.apache.hadoop.record.test.RecRecord0.Comparator.slurpRaw(b,s,l);
|
|
|
+ s+=r; l-=r;
|
|
|
+ }
|
|
|
+ return (os - s);
|
|
|
+ } catch(IOException e) {
|
|
|
+ LOG.warn(e);
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ static public int compareRaw(byte[] b1, int s1, int l1,
|
|
|
+ byte[] b2, int s2, int l2) {
|
|
|
+ try {
|
|
|
+ int os1 = s1;
|
|
|
+ {
|
|
|
+ if (l1<1 || l2<1) {
|
|
|
+ throw new IOException("Boolean is exactly 1 byte. Provided buffer is smaller.");
|
|
|
+ }
|
|
|
+ if (b1[s1] != b2[s2]) {
|
|
|
+ return (b1[s1]<b2[s2])? -1 : 0;
|
|
|
+ }
|
|
|
+ s1++; s2++; l1--; l2--;
|
|
|
+ }
|
|
|
+ {
|
|
|
+ if (l1<1 || l2<1) {
|
|
|
+ throw new IOException("Byte is exactly 1 byte. Provided buffer is smaller.");
|
|
|
+ }
|
|
|
+ if (b1[s1] != b2[s2]) {
|
|
|
+ return (b1[s1]<b2[s2])?-1:0;
|
|
|
+ }
|
|
|
+ s1++; s2++; l1--; l2--;
|
|
|
+ }
|
|
|
+ {
|
|
|
+ int i1 = WritableComparator.readVInt(b1, s1);
|
|
|
+ int i2 = WritableComparator.readVInt(b2, s2);
|
|
|
+ if (i1 != i2) {
|
|
|
+ return ((i1-i2) < 0) ? -1 : 0;
|
|
|
+ }
|
|
|
+ int z1 = WritableUtils.getVIntSize(i1);
|
|
|
+ int z2 = WritableUtils.getVIntSize(i2);
|
|
|
+ s1+=z1; s2+=z2; l1-=z1; l2-=z2;
|
|
|
+ }
|
|
|
+ {
|
|
|
+ long i1 = WritableComparator.readVLong(b1, s1);
|
|
|
+ long i2 = WritableComparator.readVLong(b2, s2);
|
|
|
+ if (i1 != i2) {
|
|
|
+ return ((i1-i2) < 0) ? -1 : 0;
|
|
|
+ }
|
|
|
+ int z1 = WritableUtils.getVIntSize(i1);
|
|
|
+ int z2 = WritableUtils.getVIntSize(i2);
|
|
|
+ s1+=z1; s2+=z2; l1-=z1; l2-=z2;
|
|
|
+ }
|
|
|
+ {
|
|
|
+ if (l1<4 || l2<4) {
|
|
|
+ throw new IOException("Float is exactly 4 bytes. Provided buffer is smaller.");
|
|
|
+ }
|
|
|
+ float f1 = WritableComparator.readFloat(b1, s1);
|
|
|
+ float f2 = WritableComparator.readFloat(b2, s2);
|
|
|
+ if (f1 != f2) {
|
|
|
+ return ((f1-f2) < 0) ? -1 : 0;
|
|
|
+ }
|
|
|
+ s1+=4; s2+=4; l1-=4; l2-=4;
|
|
|
+ }
|
|
|
+ {
|
|
|
+ if (l1<8 || l2<8) {
|
|
|
+ throw new IOException("Double is exactly 8 bytes. Provided buffer is smaller.");
|
|
|
+ }
|
|
|
+ double d1 = WritableComparator.readDouble(b1, s1);
|
|
|
+ double d2 = WritableComparator.readDouble(b2, s2);
|
|
|
+ if (d1 != d2) {
|
|
|
+ return ((d1-d2) < 0) ? -1 : 0;
|
|
|
+ }
|
|
|
+ s1+=8; s2+=8; l1-=8; l2-=8;
|
|
|
+ }
|
|
|
+ {
|
|
|
+ int i1 = WritableComparator.readVInt(b1, s1);
|
|
|
+ int i2 = WritableComparator.readVInt(b2, s2);
|
|
|
+ int z1 = WritableUtils.getVIntSize(i1);
|
|
|
+ int z2 = WritableUtils.getVIntSize(i2);
|
|
|
+ s1+=z1; s2+=z2; l1-=z1; l2-=z2;
|
|
|
+ int r1 = WritableComparator.compareBytes(b1,s1,l1,b2,s2,l2);
|
|
|
+ if (r1 != 0) { return (r1<0)?-1:0; }
|
|
|
+ s1+=i1; s2+=i2; l1-=i1; l1-=i2;
|
|
|
+ }
|
|
|
+ {
|
|
|
+ int i1 = WritableComparator.readVInt(b1, s1);
|
|
|
+ int i2 = WritableComparator.readVInt(b2, s2);
|
|
|
+ int z1 = WritableUtils.getVIntSize(i1);
|
|
|
+ int z2 = WritableUtils.getVIntSize(i2);
|
|
|
+ s1+=z1; s2+=z2; l1-=z1; l2-=z2;
|
|
|
+ int r1 = WritableComparator.compareBytes(b1,s1,l1,b2,s2,l2);
|
|
|
+ if (r1 != 0) { return (r1<0)?-1:0; }
|
|
|
+ s1+=i1; s2+=i2; l1-=i1; l1-=i2;
|
|
|
+ }
|
|
|
+ {
|
|
|
+ int vi11 = WritableComparator.readVInt(b1, s1);
|
|
|
+ int vi21 = WritableComparator.readVInt(b2, s2);
|
|
|
+ int vz11 = WritableUtils.getVIntSize(vi11);
|
|
|
+ int vz21 = WritableUtils.getVIntSize(vi21);
|
|
|
+ s1+=vz11; s2+=vz21; l1-=vz11; l2-=vz21;
|
|
|
+ for (int vidx1 = 0; vidx1 < vi11 && vidx1 < vi21; vidx1++) {
|
|
|
+ int i1 = WritableComparator.readVInt(b1, s1);
|
|
|
+ int i2 = WritableComparator.readVInt(b2, s2);
|
|
|
+ int z1 = WritableUtils.getVIntSize(i1);
|
|
|
+ int z2 = WritableUtils.getVIntSize(i2);
|
|
|
+ s1+=z1; s2+=z2; l1-=z1; l2-=z2;
|
|
|
+ int r1 = WritableComparator.compareBytes(b1,s1,l1,b2,s2,l2);
|
|
|
+ if (r1 != 0) { return (r1<0)?-1:0; }
|
|
|
+ s1+=i1; s2+=i2; l1-=i1; l1-=i2;
|
|
|
+ }
|
|
|
+ if (vi11 != vi21) { return (vi11<vi21)?-1:0; }
|
|
|
+ }
|
|
|
+ {
|
|
|
+ int mi11 = WritableComparator.readVInt(b1, s1);
|
|
|
+ int mi21 = WritableComparator.readVInt(b2, s2);
|
|
|
+ int mz11 = WritableUtils.getVIntSize(mi11);
|
|
|
+ int mz21 = WritableUtils.getVIntSize(mi21);
|
|
|
+ s1+=mz11; s2+=mz21; l1-=mz11; l2-=mz21;
|
|
|
+ for (int midx1 = 0; midx1 < mi11 && midx1 < mi21; midx1++) { {
|
|
|
+ int i1 = WritableComparator.readVInt(b1, s1);
|
|
|
+ int i2 = WritableComparator.readVInt(b2, s2);
|
|
|
+ int z1 = WritableUtils.getVIntSize(i1);
|
|
|
+ int z2 = WritableUtils.getVIntSize(i2);
|
|
|
+ s1+=z1; s2+=z2; l1-=z1; l2-=z2;
|
|
|
+ int r1 = WritableComparator.compareBytes(b1,s1,l1,b2,s2,l2);
|
|
|
+ if (r1 != 0) { return (r1<0)?-1:0; }
|
|
|
+ s1+=i1; s2+=i2; l1-=i1; l1-=i2;
|
|
|
+ }
|
|
|
+ {
|
|
|
+ int i = WritableComparator.readVInt(b1, s1);
|
|
|
+ int z = WritableUtils.getVIntSize(i);
|
|
|
+ s1+=(z+i); l1-= (z+i);
|
|
|
+ }
|
|
|
+ {
|
|
|
+ int i = WritableComparator.readVInt(b2, s2);
|
|
|
+ int z = WritableUtils.getVIntSize(i);
|
|
|
+ s2+=(z+i); l2-= (z+i);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (mi11 != mi21) { return (mi11<mi21)?-1:0; }
|
|
|
+ }
|
|
|
+ {
|
|
|
+ int r1 = org.apache.hadoop.record.test.RecRecord0.Comparator.compareRaw(b1,s1,l1,b2,s2,l2);
|
|
|
+ if (r1 <= 0) { return r1; }
|
|
|
+ s1+=r1; s2+=r1; l1-=r1; l2-=r1;
|
|
|
+ }
|
|
|
+ return (os1 - s1);
|
|
|
+ } catch(IOException e) {
|
|
|
+ LOG.warn(e);
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public int compare(byte[] b1, int s1, int l1,
|
|
|
+ byte[] b2, int s2, int l2) {
|
|
|
+ int ret = compareRaw(b1,s1,l1,b2,s2,l2);
|
|
|
+ return (ret == -1)? -1 : ((ret==0)? 1 : 0); }
|
|
|
+ }
|
|
|
+
|
|
|
+ static {
|
|
|
+ WritableComparator.define(RecRecord1.class, new Comparator());
|
|
|
+ }
|
|
|
}
|