Package com.thinkaurelius.faunus.mapreduce.util

Examples of com.thinkaurelius.faunus.mapreduce.util.WritableHandler


        public void setup(final Mapper.Context context) throws IOException, InterruptedException {
            this.map = new CounterMap<Object>();
            this.mapSpillOver = context.getConfiguration().getInt(Tokens.FAUNUS_PIPELINE_MAP_SPILL_OVER, Tokens.DEFAULT_MAP_SPILL_OVER);
            this.property = context.getConfiguration().get(PROPERTY);
            this.isVertex = context.getConfiguration().getClass(CLASS, Element.class, Element.class).equals(Vertex.class);
            this.handler = new WritableHandler(context.getConfiguration().getClass(TYPE, Text.class, WritableComparable.class));
            this.outputs = new SafeMapperOutputs(context);

        }
View Full Code Here


        @Override
        public void setup(final Mapper.Context context) throws IOException, InterruptedException {
            this.isVertex = context.getConfiguration().getClass(CLASS, Element.class, Element.class).equals(Vertex.class);
            this.key = context.getConfiguration().get(KEY);
            this.handler = new WritableHandler(context.getConfiguration().getClass(TYPE, Text.class, WritableComparable.class));
            this.elementKey = context.getConfiguration().get(ELEMENT_KEY);
            this.outputs = new SafeMapperOutputs(context);
        }
View Full Code Here

* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
public class WritableHandlerTest extends TestCase {

    public void testUnsupportedType() {
        new WritableHandler(Text.class);
        new WritableHandler(DoubleWritable.class);
        new WritableHandler(LongWritable.class);
        new WritableHandler(IntWritable.class);
        new WritableHandler(FloatWritable.class);

        try {
            new WritableHandler(BooleanWritable.class);
            assertTrue(false);
        } catch (IllegalArgumentException e) {
            assertTrue(true);
        }

        try {
            new WritableHandler(FaunusVertex.class);
            assertTrue(false);
        } catch (IllegalArgumentException e) {
            assertTrue(true);
        }

        try {
            new WritableHandler(FaunusEdge.class);
            assertTrue(false);
        } catch (IllegalArgumentException e) {
            assertTrue(true);
        }
    }
View Full Code Here

            assertTrue(true);
        }
    }

    public void testTextTypeConversion() {
        WritableHandler handler = new WritableHandler(Text.class);
        Text text = (Text) handler.set("marko");
        assertEquals(text.toString(), "marko");
        text = (Text) handler.set(1.0d);
        assertEquals(text.toString(), "1.0");
        text = (Text) handler.set(1.0f);
        assertEquals(text.toString(), "1.0");
        text = (Text) handler.set(1l);
        assertEquals(text.toString(), "1");
        text = (Text) handler.set(1);
        assertEquals(text.toString(), "1");
        try {
            text = (Text) handler.set(true);
            assertTrue(false);
        } catch (IllegalArgumentException e) {
            assertTrue(true);
        }
    }
View Full Code Here

            assertTrue(true);
        }
    }

    public void testLongTypeConversion() {
        WritableHandler handler = new WritableHandler(LongWritable.class);
        LongWritable l = (LongWritable) handler.set("1");
        assertEquals(l.get(), 1l);
        l = (LongWritable) handler.set(1.0d);
        assertEquals(l.get(), 1l);
        l = (LongWritable) handler.set(1.0f);
        assertEquals(l.get(), 1l);
        l = (LongWritable) handler.set(1l);
        assertEquals(l.get(), 1l);
        l = (LongWritable) handler.set(1);
        assertEquals(l.get(), 1l);
        try {
            l = (LongWritable) handler.set(true);
            assertTrue(false);
        } catch (IllegalArgumentException e) {
            assertTrue(true);
        }
    }
View Full Code Here

            assertTrue(true);
        }
    }

    public void testDoubleTypeConversion() {
        WritableHandler handler = new WritableHandler(DoubleWritable.class);
        DoubleWritable d = (DoubleWritable) handler.set("1.0");
        assertEquals(d.get(), 1.0d);
        d = (DoubleWritable) handler.set(1.0d);
        assertEquals(d.get(), 1.0d);
        d = (DoubleWritable) handler.set(1.0f);
        assertEquals(d.get(), 1.0d);
        d = (DoubleWritable) handler.set(1l);
        assertEquals(d.get(), 1.0d);
        d = (DoubleWritable) handler.set(1);
        assertEquals(d.get(), 1.0d);
        try {
            d = (DoubleWritable) handler.set(true);
            assertTrue(false);
        } catch (IllegalArgumentException e) {
            assertTrue(true);
        }
    }
View Full Code Here

            assertTrue(true);
        }
    }

    public void testFloatTypeConversion() {
        WritableHandler handler = new WritableHandler(FloatWritable.class);
        FloatWritable f = (FloatWritable) handler.set("1");
        assertEquals(f.get(), 1.0f);
        f = (FloatWritable) handler.set(1.0d);
        assertEquals(f.get(), 1.0f);
        f = (FloatWritable) handler.set(1.0f);
        assertEquals(f.get(), 1.0f);
        f = (FloatWritable) handler.set(1l);
        assertEquals(f.get(), 1.0f);
        f = (FloatWritable) handler.set(1);
        assertEquals(f.get(), 1.0f);
        try {
            f = (FloatWritable) handler.set(true);
            assertTrue(false);
        } catch (IllegalArgumentException e) {
            assertTrue(true);
        }
    }
View Full Code Here

            assertTrue(true);
        }
    }

    public void testIntTypeConversion() {
        WritableHandler handler = new WritableHandler(IntWritable.class);
        IntWritable i = (IntWritable) handler.set("1");
        assertEquals(i.get(), 1);
        i = (IntWritable) handler.set(1.0d);
        assertEquals(i.get(), 1);
        i = (IntWritable) handler.set(1.0f);
        assertEquals(i.get(), 1);
        i = (IntWritable) handler.set(1l);
        assertEquals(i.get(), 1);
        i = (IntWritable) handler.set(1);
        assertEquals(i.get(), 1);
        try {
            i = (IntWritable) handler.set(true);
            assertTrue(false);
        } catch (IllegalArgumentException e) {
            assertTrue(true);
        }
    }
View Full Code Here

        @Override
        public void setup(final Mapper.Context context) throws IOException, InterruptedException {
            this.isVertex = context.getConfiguration().getClass(CLASS, Element.class, Element.class).equals(Vertex.class);
            this.key = context.getConfiguration().get(KEY);
            this.handler = new WritableHandler(context.getConfiguration().getClass(TYPE, Text.class, WritableComparable.class));
            this.outputs = new SafeMapperOutputs(context);
        }
View Full Code Here

TOP

Related Classes of com.thinkaurelius.faunus.mapreduce.util.WritableHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.