List of usage examples for org.apache.hadoop.io BytesWritable getBytes
@Override public byte[] getBytes()
From source file:co.nubetech.hiho.dedup.HashUtility.java
License:Apache License
public static MD5Hash getMD5Hash(BytesWritable key) throws IOException { return MD5Hash.digest(key.getBytes()); }
From source file:com.axiomine.largecollections.kryo.serializers.BytesWritableSerializer.java
License:Apache License
public void write(Kryo kryo, Output output, BytesWritable object) { output.writeInt(object.getLength(), true); output.write(object.getBytes()); }
From source file:com.bixolabs.cascading.avro.AvroScheme.java
License:Apache License
private Object convertToAvroPrimitive(Object inObj) { if (inObj == null) { return null; } else if (inObj instanceof String) { return new Utf8((String) inObj); } else if (inObj instanceof BytesWritable) { BytesWritable bw = (BytesWritable) inObj; ByteBuffer convertedObj = ByteBuffer.wrap(bw.getBytes(), 0, bw.getLength()); return convertedObj; // } else if (curType.isEnum()) { // Object result = new CascadingEnumSymbol((String) inObj); // return result; } else if (inObj instanceof Short) { Short val = (Short) inObj; return val.intValue(); } else {/*from ww w.jav a 2s . c o m*/ return inObj; } }
From source file:com.bizosys.hsearch.kv.impl.bytescookernew.IndexFieldBoolean.java
License:Apache License
public static byte[] cook(Iterable<BytesWritable> values, final boolean isRepetable, final boolean isCompressed) throws IOException { if (isRepetable) { final HSearchTableKVBooleanInverted table = new HSearchTableKVBooleanInverted(isCompressed); ComputeSerValues<Boolean> compute = new ComputeSerValues<Boolean>() { @Override/*from w w w. j av a 2 s .co m*/ public final void visit(final int key, final Boolean val) { table.put(key, val); } }; for (BytesWritable bucketBytes : values) { byte[] data = bucketBytes.getBytes(); if (null == data) continue; compute.compute(createBlankTable(), data); } return table.toBytes(); } else { final HSearchTableKVBoolean table = new HSearchTableKVBoolean(); ComputeSerValues<Boolean> compute = new ComputeSerValues<Boolean>() { @Override public final void visit(final int key, final Boolean val) { table.put(key, val); } }; for (BytesWritable bucketBytes : values) { byte[] data = bucketBytes.getBytes(); if (null == data) continue; compute.compute(createBlankTable(), data); } return table.toBytes(); } }
From source file:com.bizosys.hsearch.kv.impl.bytescookernew.IndexFieldByte.java
License:Apache License
public static byte[] cook(Iterable<BytesWritable> values, final boolean isRepetable, final boolean isCompressed) throws IOException { if (isRepetable) { final HSearchTableKVByteInverted table = new HSearchTableKVByteInverted(isCompressed); ComputeSerValues<Byte> compute = new ComputeSerValues<Byte>() { @Override//from ww w . j a v a 2 s. c o m public final void visit(final int key, final Byte val) { table.put(key, val); } }; for (BytesWritable bucketBytes : values) { byte[] data = bucketBytes.getBytes(); if (null == data) continue; compute.compute(createBlankTable(), data); } return table.toBytes(); } else { final HSearchTableKVByte table = new HSearchTableKVByte(); ComputeSerValues<Byte> compute = new ComputeSerValues<Byte>() { @Override public final void visit(final int key, final Byte val) { table.put(key, val); } }; for (BytesWritable bucketBytes : values) { byte[] data = bucketBytes.getBytes(); if (null == data) continue; compute.compute(createBlankTable(), data); } return table.toBytes(); } }
From source file:com.bizosys.hsearch.kv.impl.bytescookernew.IndexFieldDouble.java
License:Apache License
public static byte[] cook(Iterable<BytesWritable> values, final boolean isRepetable, final boolean isCompressed) throws IOException { if (isRepetable) { final HSearchTableKVDoubleInverted table = new HSearchTableKVDoubleInverted(isCompressed); ComputeSerValues<Double> compute = new ComputeSerValues<Double>() { @Override/*from ww w . j a va 2 s. co m*/ public final void visit(final int key, final Double val) { table.put(key, val); } }; for (BytesWritable bucketBytes : values) { byte[] data = bucketBytes.getBytes(); if (null == data) continue; compute.compute(createBlankTable(), data); } return table.toBytes(); } else { final HSearchTableKVDouble table = new HSearchTableKVDouble(); ComputeSerValues<Double> compute = new ComputeSerValues<Double>() { @Override public final void visit(final int key, final Double val) { table.put(key, val); } }; for (BytesWritable bucketBytes : values) { byte[] data = bucketBytes.getBytes(); if (null == data) continue; compute.compute(createBlankTable(), data); } return table.toBytes(); } }
From source file:com.bizosys.hsearch.kv.impl.bytescookernew.IndexFieldFloat.java
License:Apache License
public static byte[] cook(Iterable<BytesWritable> values, final boolean isRepetable, final boolean isCompressed) throws IOException { if (isRepetable) { final HSearchTableKVFloatInverted table = new HSearchTableKVFloatInverted(isCompressed); ComputeSerValues<Float> compute = new ComputeSerValues<Float>() { @Override/*from ww w. jav a2s . c o m*/ public final void visit(final int key, final Float val) { table.put(key, val); } }; for (BytesWritable bucketBytes : values) { byte[] data = bucketBytes.getBytes(); if (null == data) continue; compute.compute(createBlankTable(), data); } return table.toBytes(); } else { final HSearchTableKVFloat table = new HSearchTableKVFloat(); ComputeSerValues<Float> compute = new ComputeSerValues<Float>() { @Override public final void visit(final int key, final Float val) { table.put(key, val); } }; for (BytesWritable bucketBytes : values) { byte[] data = bucketBytes.getBytes(); if (null == data) continue; compute.compute(createBlankTable(), data); } return table.toBytes(); } }
From source file:com.bizosys.hsearch.kv.impl.bytescookernew.IndexFieldInteger.java
License:Apache License
public static byte[] cook(Iterable<BytesWritable> values, final boolean isRepetable, final boolean isCompressed) throws IOException { if (isRepetable) { final HSearchTableKVIntegerInverted table = new HSearchTableKVIntegerInverted(isCompressed); ComputeSerValues<Integer> compute = new ComputeSerValues<Integer>() { @Override//from ww w . j a va2 s .co m public final void visit(final int key, final Integer val) { table.put(key, val); } }; for (BytesWritable bucketBytes : values) { byte[] data = bucketBytes.getBytes(); if (null == data) continue; compute.compute(createBlankTable(), data); } return table.toBytes(); } else { final HSearchTableKVInteger table = new HSearchTableKVInteger(); ComputeSerValues<Integer> compute = new ComputeSerValues<Integer>() { @Override public final void visit(final int key, final Integer val) { table.put(key, val); } }; for (BytesWritable bucketBytes : values) { byte[] data = bucketBytes.getBytes(); if (null == data) continue; compute.compute(createBlankTable(), data); } return table.toBytes(); } }
From source file:com.bizosys.hsearch.kv.impl.bytescookernew.IndexFieldLong.java
License:Apache License
public static byte[] cook(Iterable<BytesWritable> values, final boolean isRepetable, final boolean isCompressed) throws IOException { if (isRepetable) { final HSearchTableKVLongInverted table = new HSearchTableKVLongInverted(isCompressed); ComputeSerValues<Long> compute = new ComputeSerValues<Long>() { @Override// www .jav a 2 s .co m public final void visit(final int key, final Long val) { table.put(key, val); } }; for (BytesWritable bucketBytes : values) { byte[] data = bucketBytes.getBytes(); if (null == data) continue; compute.compute(createBlankTable(), data); } return table.toBytes(); } else { final HSearchTableKVLong table = new HSearchTableKVLong(); ComputeSerValues<Long> compute = new ComputeSerValues<Long>() { @Override public final void visit(final int key, final Long val) { table.put(key, val); } }; for (BytesWritable bucketBytes : values) { byte[] data = bucketBytes.getBytes(); if (null == data) continue; compute.compute(createBlankTable(), data); } return table.toBytes(); } }
From source file:com.bizosys.hsearch.kv.impl.bytescookernew.IndexFieldShort.java
License:Apache License
public static byte[] cook(Iterable<BytesWritable> values, final boolean isRepetable, final boolean isCompressed) throws IOException { if (isRepetable) { final HSearchTableKVShortInverted table = new HSearchTableKVShortInverted(isCompressed); ComputeSerValues<Short> compute = new ComputeSerValues<Short>() { @Override/*from w w w .j a v a 2 s . c om*/ public final void visit(final int key, final Short val) { table.put(key, val); } }; for (BytesWritable bucketBytes : values) { byte[] data = bucketBytes.getBytes(); if (null == data) continue; compute.compute(createBlankTable(), data); } return table.toBytes(); } else { final HSearchTableKVShort table = new HSearchTableKVShort(); ComputeSerValues<Short> compute = new ComputeSerValues<Short>() { @Override public final void visit(final int key, final Short val) { table.put(key, val); } }; for (BytesWritable bucketBytes : values) { byte[] data = bucketBytes.getBytes(); if (null == data) continue; compute.compute(createBlankTable(), data); } return table.toBytes(); } }