Exemplo n.º 1
0
 // Serialize the keys and append the tag
 protected HiveKey toHiveKey(Object obj, int tag, Integer distLength) throws SerDeException {
   BinaryComparable key = (BinaryComparable) keySerializer.serialize(obj, keyObjectInspector);
   int keyLength = key.getLength();
   if (tag == -1 || skipTag) {
     keyWritable.set(key.getBytes(), 0, keyLength);
   } else {
     keyWritable.setSize(keyLength + 1);
     System.arraycopy(key.getBytes(), 0, keyWritable.get(), 0, keyLength);
     keyWritable.get()[keyLength] = tagByte[0];
   }
   keyWritable.setDistKeyLength((distLength == null) ? keyLength : distLength);
   return keyWritable;
 }
Exemplo n.º 2
0
 @Override
 public void writeValue(RandomAccessOutput dest) throws SerDeException {
   if (!(value instanceof BinaryComparable)) {
     throw new SerDeException("Unexpected type " + value.getClass().getCanonicalName());
   }
   BinaryComparable b = (BinaryComparable) value;
   dest.write(b.getBytes(), 0, b.getLength());
 }
Exemplo n.º 3
0
 @Override
 public int getHashFromKey() throws SerDeException {
   if (!(key instanceof BinaryComparable)) {
     throw new SerDeException("Unexpected type " + key.getClass().getCanonicalName());
   }
   sanityCheckKeyForTag();
   BinaryComparable b = (BinaryComparable) key;
   return WriteBuffers.murmurHash(b.getBytes(), 0, b.getLength() - (hasTag ? 1 : 0));
 }
Exemplo n.º 4
0
 @Override
 public void writeKey(RandomAccessOutput dest) throws SerDeException {
   if (!(key instanceof BinaryComparable)) {
     throw new SerDeException("Unexpected type " + key.getClass().getCanonicalName());
   }
   sanityCheckKeyForTag();
   BinaryComparable b = (BinaryComparable) key;
   dest.write(b.getBytes(), 0, b.getLength() - (hasTag ? 1 : 0));
 }