@Override protected TripleWritable createInstance(Triple tuple) { return new TripleWritable(tuple); } }
@Override protected void sendOutput(TKey key, TripleWritable value, StreamRDF stream) { stream.triple(value.get()); } }
/** * Creates a new instance from the given input * * @param input * Input * @return New instance * @throws IOException */ public static TripleWritable read(DataInput input) throws IOException { TripleWritable t = new TripleWritable(); t.readFields(input); return t; }
@Test public void distinct_triples_04() throws IOException { MapReduceDriver<LongWritable, TripleWritable, TripleWritable, NullWritable, NullWritable, TripleWritable> driver = this .getMapReduceDriver(); Node s1 = NodeFactory.createURI("urn:nf#cbf2b2c7-109e-4097-bbea-f67f272c7fcc"); Node s2 = NodeFactory.createURI("urn:nf#bb08b75c-1ad2-47ef-acd2-eb2d92b94b89"); Node p = NodeFactory.createURI("urn:p"); Node o = NodeFactory.createURI("urn:66.230.159.118"); Assert.assertNotEquals(s1, s2); Triple t1 = new Triple(s1, p, o); Triple t2 = new Triple(s2, p, o); Assert.assertNotEquals(t1, t2); TripleWritable tw1 = new TripleWritable(t1); TripleWritable tw2 = new TripleWritable(t2); Assert.assertNotEquals(tw1, tw2); Assert.assertNotEquals(0, tw1.compareTo(tw2)); driver.addInput(new LongWritable(1), tw1); driver.addInput(new LongWritable(2), tw2); driver.addOutput(NullWritable.get(), tw1); driver.addOutput(NullWritable.get(), tw2); driver.runTest(false); } }
@Override public void readFields(DataInput input) throws IOException { this.triple.clear(); int tripleLength = input.readInt(); byte[] buffer = new byte[tripleLength]; input.readFully(buffer); try { ThriftConverter.fromBytes(buffer, this.triple); } catch (TException e) { throw new IOException(e); } this.setInternal(new Triple(ThriftConvert.convert(this.triple.getS()), ThriftConvert.convert(this.triple.getP()), ThriftConvert.convert(this.triple.getO()))); }
@Override public void readFields(DataInput input) throws IOException { this.triple.clear(); int tripleLength = input.readInt(); byte[] buffer = new byte[tripleLength]; input.readFully(buffer); try { ThriftConverter.fromBytes(buffer, this.triple); } catch (TException e) { throw new IOException(e); } this.setInternal(new Triple(ThriftConvert.convert(this.triple.getS()), ThriftConvert.convert(this.triple.getP()), ThriftConvert.convert(this.triple.getO()))); }
@Override protected void sendOutput(TKey key, TripleWritable value, StreamRDF stream) { stream.triple(value.get()); } }
@Override protected TripleWritable createInstance(Triple tuple) { return new TripleWritable(tuple); } }
/** * Creates a new instance from the given input * * @param input * Input * @return New instance * @throws IOException */ public static TripleWritable read(DataInput input) throws IOException { TripleWritable t = new TripleWritable(); t.readFields(input); return t; }
@Override protected final void add(TripleWritable value) { this.g.add(value.get()); }
@Override protected TripleWritable createInstance(Triple tuple) { return new TripleWritable(tuple); } }
@Override protected final void add(TripleWritable value) { this.g.add(value.get()); }
@Override protected TripleWritable createInstance(Triple tuple) { return new TripleWritable(tuple); } }
protected abstract NodeWritable selectKey(Triple triple); }
@Override protected TripleWritable createInstance(Triple t) { return new TripleWritable(t); }
@Override protected NodeWritable[] getNodes(TripleWritable tuple) { return new NodeWritable[] { new NodeWritable(tuple.get().getPredicate()) }; } }
@Override protected TripleWritable createInstance(Triple t) { return new TripleWritable(t); }
@Override protected final long add(TripleWritable value) { g.add(value.get()); return g.size(); }
@Override protected void map(TKey key, QuadWritable value, Context context) throws IOException, InterruptedException { context.write(key, new TripleWritable(value.get().asTriple())); }
@Override protected final long add(TripleWritable value) { g.add(value.get()); return g.size(); }