List of usage examples for org.apache.mahout.cf.taste.hadoop EntityEntityWritable EntityEntityWritable
public EntityEntityWritable(long aID, long bID)
From source file:org.apache.hadoop.mapred.nativetask.testutil.BytesUtil.java
License:Apache License
private static Object newMahoutObject(byte[] seed, String className) { if (className.equals(VarIntWritable.class.getName())) { return new VarIntWritable(Bytes.toInt(seed)); } else if (className.equals(VarLongWritable.class.getName())) { return new VarLongWritable(Bytes.toLong(seed)); } else if (className.equals(TreeID.class.getName())) { TreeID treeID = new TreeID(); treeID.set(Bytes.toLong(seed));/*from ww w . java 2s.com*/ return treeID; } else if (className.equals(SplitPartitionedWritable.class.getName())) { SplitPartitionedWritable spWritable = new SplitPartitionedWritable(); long taskItemOrdinal = Math.abs(Bytes.toLong(seed, 4)); spWritable.setTaskItemOrdinal(taskItemOrdinal); return spWritable; } else if (className.equals(EntityEntityWritable.class.getName())) { EntityEntityWritable entityWritable = new EntityEntityWritable(Bytes.toLong(seed, 0), Bytes.toLong(seed, 8)); return entityWritable; } else if (className.equals(Gram.class.getName())) { String ngram = Bytes.toStringBinary(seed); return new Gram(ngram, Gram.Type.NGRAM); } else if (className.equals(GramKey.class.getName())) { int primaryLength = r.nextInt(seed.length); Gram gram = new Gram(Bytes.toStringBinary(seed, 0, Math.max(primaryLength, 1)), Gram.Type.NGRAM); byte[] order = new byte[seed.length - primaryLength]; System.arraycopy(seed, primaryLength, order, 0, order.length); return new GramKey(gram, order); } else if (className.equals(StringTuple.class.getName())) { int tupleSize = r.nextInt(4); StringTuple stringTuple = new StringTuple(); for (int i = 0; i < tupleSize; i++) { int index = r.nextInt(seed.length); stringTuple.add(Bytes.toStringBinary(seed, index, seed.length - index)); } return stringTuple; } else { return null; } }