Package com.netflix.lipstick.model

Examples of com.netflix.lipstick.model.P2jPlan


    /* Create Mock P2jPlanGenerator objects with methods stubbed out to
       let the BasicP2LClient.createPlan() method complete, and
       pass them to the client via the setter method. */
    public void setMockPlanGenerators(BasicP2LClient client) {
        P2jPlan pln = mock(P2jPlan.class);
        P2jPlanGenerator unopt_plan = mock(P2jPlanGenerator.class);
        when(unopt_plan.getP2jPlan()).thenReturn(pln);
        P2jPlanGenerator opt_plan = mock(P2jPlanGenerator.class);
        when(opt_plan.getP2jPlan()).thenReturn(pln);
        client.setPlanGenerators(unopt_plan, opt_plan);
View Full Code Here


        reverseMap = generateReverseMap(lp);
        Map<String, P2jLogicalRelationalOperator> nodeMap = Maps.newHashMap();
        for (Entry<Operator, String> entry : reverseMap.entrySet()) {
            nodeMap.put(entry.getValue(), convertNodeToP2j((LogicalRelationalOperator) entry.getKey(), lp, reverseMap));
        }
        p2jPlan = new P2jPlan(nodeMap);
    }
View Full Code Here

        LipstickPigServer lps = new LipstickPigServer("local");
        lps.setBatchOn();
        lps.registerScript("./src/test/resources/test.pig");

        P2jPlanGenerator opg = new P2jPlanGenerator(lps.getLP(null));
        P2jPlan plan = opg.getP2jPlan();

        // Build a map of scope to id from the built plan
        Map<String, String> scopeToIdMap = new HashMap<String, String>();

        for (String scope : plan.getPlan().keySet()) {
            scopeToIdMap.put(scope, getIdentifier(plan.getPlan().get(scope)));
        }

        // Container for all expected P2j objects
        Set<P2jLogicalRelationalOperator> expectedOps = new HashSet<P2jLogicalRelationalOperator>();

        // Add all expected P2jLOLoad objects
        P2jLOLoad load1 = new P2jLOLoad();
        load1.setAlias("tiny");
        load1.setSuccessors(Lists.newArrayList("tiny_colors", "tiny_colors_cogrp", "tiny_colors_join"));
        P2jLOLoad load2 = new P2jLOLoad();
        load2.setAlias("colors");
        load2.setSuccessors(Lists.newArrayList("tiny_colors", "colors_filtered", "tiny_colors_cogrp", "tiny_colors_join"));
        P2jLOLoad load3 = new P2jLOLoad();
        load3.setAlias("colors2");
        load3.setSuccessors(Lists.newArrayList("tiny_colors_cogrp", "tiny_colors_join"));
        P2jLOLoad load4 = new P2jLOLoad();
        load4.setAlias("colors3");
        load4.setSuccessors(Lists.newArrayList("tiny_colors_join"));

        expectedOps.addAll(Lists.newArrayList(load1, load2, load3, load4));

        // Add all expected P2jLOStore objects
        // Aliases are lost, so use storageLocation instead
        P2jLOStore store1 = new P2jLOStore();
        store1.setStorageLocation("file://" + System.getProperty("user.dir") + "/test_out_cogrp");
        store1.setPredecessors(Lists.newArrayList("out"));
        P2jLOStore store2 = new P2jLOStore();
        store2.setStorageLocation("file://" + System.getProperty("user.dir") + "/test_out_join");
        store2.setPredecessors(Lists.newArrayList("tiny_colors_join"));
        P2jLOStore store3 = new P2jLOStore();
        store3.setStorageLocation("file://" + System.getProperty("user.dir") + "/test_out_tiny_colors");
        store3.setPredecessors(Lists.newArrayList("tiny_colors"));

        expectedOps.addAll(Lists.newArrayList(store1, store2, store3));

        // Add all expected P2jLOJoin objects
        P2jLOJoin join1 = new P2jLOJoin();
        join1.setAlias("tiny_colors");
        join1.setPredecessors(Lists.newArrayList("tiny", "colors"));
        join1.setSuccessors(Lists.newArrayList("file://" + System.getProperty("user.dir") + "/test_out_tiny_colors"));
        P2jLOJoin join2 = new P2jLOJoin();
        join2.setAlias("tiny_colors_join");
        join2.setPredecessors(Lists.newArrayList("tiny", "colors", "colors2", "colors3"));
        join2.setSuccessors(Lists.newArrayList("file://" + System.getProperty("user.dir") + "/test_out_join"));

        expectedOps.addAll(Lists.newArrayList(join1, join2));

        // Add all expected P2jLOFilter objects
        P2jLOFilter filter1 = new P2jLOFilter();
        filter1.setAlias("colors_filtered");
        filter1.setPredecessors(Lists.newArrayList("colors"));

        expectedOps.add(filter1);

        // Add all expected P2jLOCogroup objects
        P2jLOCogroup cogroup1 = new P2jLOCogroup();
        cogroup1.setAlias("tiny_colors_cogrp");
        cogroup1.setPredecessors(Lists.newArrayList("tiny", "colors", "colors2"));
        cogroup1.setSuccessors(Lists.newArrayList("out"));

        expectedOps.add(cogroup1);

        // Add all expected P2jLOLimit objects
        P2jLOLimit limit1 = new P2jLOLimit();
        limit1.setAlias("out");
        limit1.setPredecessors(Lists.newArrayList("tiny_colors_cogrp"));
        limit1.setSuccessors(Lists.newArrayList("file://" + System.getProperty("user.dir") + "/test_out_cogrp"));

        expectedOps.add(limit1);

        // For each op, ensure the aliases and all predecessors/successors match
        for (String scope : plan.getPlan().keySet()) {
            P2jLogicalRelationalOperator actualOp = plan.getPlan().get(scope);

            String actualId = getIdentifier(actualOp);

            P2jLogicalRelationalOperator matchedOp = null;
            for (P2jLogicalRelationalOperator expectedOp : expectedOps) {
View Full Code Here

        MROperPlan plan = getMROperPlan(lps);
        Map<PhysicalOperator, Operator> p2lMap = getP2lMap(lps);

        MRPlanCalculator opCalc = new MRPlanCalculator(opg.getP2jPlan(), plan, p2lMap, opg.getReverseMap());

        P2jPlan opPlan = opCalc.getP2jPlan();

        Map<String, MRStepType> expectedIdToStepTypeMap = new HashMap<String, MRStepType>();
        expectedIdToStepTypeMap.put("tiny", MRStepType.MAPPER);
        expectedIdToStepTypeMap.put("colors", MRStepType.MAPPER);
        expectedIdToStepTypeMap.put("colors2", MRStepType.MAPPER);
        expectedIdToStepTypeMap.put("colors3", MRStepType.MAPPER);
        expectedIdToStepTypeMap.put("file://" + System.getProperty("user.dir") + "/test_out_cogrp", MRStepType.REDUCER);
        expectedIdToStepTypeMap.put("file://" + System.getProperty("user.dir") + "/test_out_join", MRStepType.REDUCER);
        expectedIdToStepTypeMap.put("file://" + System.getProperty("user.dir") + "/test_out_tiny_colors", MRStepType.REDUCER);
        expectedIdToStepTypeMap.put("tiny_colors", MRStepType.REDUCER);
        expectedIdToStepTypeMap.put("tiny_colors_join", MRStepType.REDUCER);
        expectedIdToStepTypeMap.put("colors_filtered", MRStepType.UNKNOWN);
        expectedIdToStepTypeMap.put("tiny_colors_cogrp", MRStepType.MAPPER);
        expectedIdToStepTypeMap.put("out", MRStepType.REDUCER);

        for (String scope : opPlan.getPlan().keySet()) {
            P2jLogicalRelationalOperator actualOp = opPlan.getPlan().get(scope);

            String actualId = getIdentifier(actualOp);

            String actualStepType = actualOp.getMapReduce().getStepType();
            String expectedStepType = expectedIdToStepTypeMap.get(actualId).toString();
View Full Code Here

TOP

Related Classes of com.netflix.lipstick.model.P2jPlan

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.