Examples of StreamSpec


Examples of org.apache.pig.impl.eval.StreamSpec

        super.visitEval(e);
        eval = e;
        parentEval = true;

        if (e.getSpec() instanceof StreamSpec) {
            StreamSpec streamSpec = (StreamSpec)e.getSpec();
            streamSpec.revertOptimizedCommand(Handle.OUTPUT);
        }
    }
View Full Code Here

Examples of org.apache.pig.impl.eval.StreamSpec

       
        if (parentEval) {
            EvalSpec spec = eval.getSpec();
            if (spec instanceof StreamSpec) {
                // Try and optimize if the store and stream output specs match
                StreamSpec streamSpec = (StreamSpec)spec;
                StreamingCommand command = streamSpec.getCommand();
                HandleSpec streamOutputSpec = command.getOutputSpec();
               
                FileSpec storeFileSpec = s.getOutputFileSpec();
               
                // Instantiate both to compare them for equality
                LoadFunc streamLoader =
                    (LoadFunc)PigContext.instantiateFuncFromSpec(
                            streamOutputSpec.getSpec());
               
                StoreFunc outputStorer = (StoreFunc)PigContext.instantiateFuncFromSpec(
                                                storeFileSpec.getFuncSpec());
               

                // Check if the streaming command's outputSpec also implements
                // StoreFunc and if it does, are they of the same _reversible_
                // type?
                boolean sameType = false;
                try {
                    // Check if the streamLoader is _reversible_ as
                    // the outputStorer ...
                    if (streamLoader instanceof StoreFunc) {
                        // Cast to check if they are of the same type...
                        streamLoader.getClass().cast(outputStorer);
                       
                        // Now check if they both are reversible...
                        if (streamLoader instanceof ReversibleLoadStoreFunc &&
                            outputStorer instanceof ReversibleLoadStoreFunc) {
                            sameType = true;
                        }
                    }
                } catch (ClassCastException cce) {
                    sameType = false;
                }
               
                // Check if both LoadFunc objects belong to the same type and
                // are equivalent
                if (sameType && streamLoader.equals(outputStorer)) {
                    // Since they both are the same, we can flip them
                    // for BinaryStorage
                    s.setOutputFileSpec(new FileSpec(storeFileSpec.getFileName(), BinaryStorage.class.getName()));
                    streamSpec.setOptimizedSpec(Handle.OUTPUT,
                                                   BinaryStorage.class.getName());
                    optimize = true;
                }
            }
        }
View Full Code Here

Examples of org.apache.pig.impl.eval.StreamSpec

        if (parentLoad) {
            EvalSpec spec = e.getSpec();
            if (spec instanceof StreamSpec && !load.isSplittable()) {
                // Try and optimize if the load and stream input specs match
                // and input files are to be processed as-is
                StreamSpec streamSpec = (StreamSpec)spec;
                StreamingCommand command = streamSpec.getCommand();
                HandleSpec streamInputSpec = command.getInputSpec();
               
                FileSpec loadFileSpec = load.getInputFileSpec();
               
                // Instantiate both to compare them for equality
                StoreFunc streamStorer =
                    (StoreFunc)PigContext.instantiateFuncFromSpec(
                            streamInputSpec.getSpec());
               
                LoadFunc inputLoader = (LoadFunc)PigContext.instantiateFuncFromSpec(
                                                loadFileSpec.getFuncSpec());

                // Check if the streaming command's inputSpec also implements
                // LoadFunc and if it does, are they of the same _reversible_
                // type?
                boolean sameType = false;
                try {
                    // Check if the streamStorer is _reversible_ as
                    // the inputLoader ...
                    if (streamStorer instanceof LoadFunc) {
                        // Cast to check if they are of the same type...
                        streamStorer.getClass().cast(inputLoader);
                       
                        // Now check if they both are reversible...
                        if (streamStorer instanceof ReversibleLoadStoreFunc &&
                            inputLoader instanceof ReversibleLoadStoreFunc) {
                            sameType = true;
                        }
                    }
                } catch (ClassCastException cce) {
                    sameType = false;
                }
               
                // Check if both LoadFunc objects belong to the same type and
                // are equivalent
                if (sameType && streamStorer.equals(inputLoader)) {
                    // Since they both are the same, we can flip them
                    // for BinaryStorage
                    load.setInputFileSpec(new FileSpec(loadFileSpec.getFileName(), BinaryStorage.class.getName()));
                    streamSpec.setOptimizedSpec(Handle.INPUT,
                                                   BinaryStorage.class.getName());
                    optimize = true;
                }
            }
        } else {
            if (e.getSpec() instanceof StreamSpec) {
                StreamSpec streamSpec = (StreamSpec)e.getSpec();
                streamSpec.revertOptimizedCommand(Handle.INPUT);
            }
        }
       
        parentLoad = false;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.