Example usage for org.apache.mahout.math.hadoop.stochasticsvd SplitPartitionedWritable getTaskId

List of usage examples for org.apache.mahout.math.hadoop.stochasticsvd SplitPartitionedWritable getTaskId

Introduction

In this page you can find the example usage for org.apache.mahout.math.hadoop.stochasticsvd SplitPartitionedWritable getTaskId.

Prototype

public int getTaskId() 

Source Link

Usage

From source file:org.apache.hadoop.mapred.nativetask.testutil.BytesUtil.java

License:Apache License

private static <VTYPE> byte[] MahoutObjectToBytes(VTYPE obj) {
    String className = obj.getClass().getName();
    if (className.equals(VarIntWritable.class.getName())) {
        return Bytes.toBytes(((VarIntWritable) obj).get());
    } else if (className.equals(VarLongWritable.class.getName())) {
        return Bytes.toBytes(((VarLongWritable) obj).get());
    } else if (className.equals(TreeID.class.getName())) {
        return Bytes.toBytes(((TreeID) obj).get());
    } else if (className.equals(SplitPartitionedWritable.class.getName())) {
        byte[] bytes = new byte[12];
        SplitPartitionedWritable spWritable = (SplitPartitionedWritable) obj;
        System.arraycopy(Bytes.toBytes(spWritable.getTaskId()), 0, bytes, 0, 4);
        System.arraycopy(Bytes.toBytes(spWritable.getTaskItemOrdinal()), 0, bytes, 4, 8);
        return bytes;
    } else if (className.equals(EntityEntityWritable.class.getName())) {
        byte[] bytes = new byte[16];
        String[] nums = ((EntityEntityWritable) obj).toString().split("\t");
        System.arraycopy(Bytes.toBytes(Long.parseLong(nums[0])), 0, bytes, 0, 8);
        System.arraycopy(Bytes.toBytes(Long.parseLong(nums[1])), 0, bytes, 8, 8);
        return bytes;
    } else if (className.equals(Gram.class.getName())) {
        return ((Gram) obj).getBytes();
    } else if (className.equals(GramKey.class.getName())) {
        return ((GramKey) obj).getBytes();
    } else if (className.equals(StringTuple.class.getName())) {
        return Bytes.toBytes(((StringTuple) obj).toString());
    } else {/*from  ww  w.  j ava2s . co m*/
        return new byte[0];
    }
}