Examples of ElementDescriptor


Examples of org.apache.pig.backend.datastorage.ElementDescriptor

    @Override
    protected void processLS(String path) throws IOException
    {
        if(mExplain == null) { // process only if not in "explain" mode
            try {
                ElementDescriptor pathDescriptor;
               
                if (path == null) {
                    pathDescriptor = mDfs.getActiveContainer();
                }
                else {
                    pathDescriptor = mDfs.asElement(path);
                }
   
                if (!pathDescriptor.exists()) {
                    throw new IOException("File or directory " + path + " does not exist.");               
                }
               
                if (mDfs.isContainer(pathDescriptor.toString())) {
                    ContainerDescriptor container = (ContainerDescriptor) pathDescriptor;
                    Iterator<ElementDescriptor> elems = container.iterator();
                   
                    while (elems.hasNext()) {
                        ElementDescriptor curElem = elems.next();
                       
                        if (mDfs.isContainer(curElem.toString())) {
                               System.out.println(curElem.toString() + "\t<dir>");
                        } else {
                            printLengthAndReplication(curElem);
                        }
                    }
                } else {
View Full Code Here

Examples of org.apache.pig.backend.datastorage.ElementDescriptor

        if(mExplain == null) { // process only if not in "explain" mode

            executeBatch();
       
            try {
                ElementDescriptor srcPath = mDfs.asElement(src);
                ElementDescriptor dstPath = mDfs.asElement(dst);
               
                if (!srcPath.exists()) {
                    throw new IOException("File or directory " + src + " does not exist.");               
                }
               
View Full Code Here

Examples of org.apache.pig.backend.datastorage.ElementDescriptor

        if(mExplain == null) { // process only if not in "explain" mode

            executeBatch();
       
            try {
                ElementDescriptor srcPath = mDfs.asElement(src);
                ElementDescriptor dstPath = mDfs.asElement(dst);
               
                srcPath.copy(dstPath, mConf, false);
            }
            catch (DataStorageException e) {
                throw new IOException("Failed to copy " + src + " to " + dst, e);
View Full Code Here

Examples of org.apache.pig.backend.datastorage.ElementDescriptor

        if(mExplain == null) { // process only if not in "explain" mode
           
            executeBatch();
       
            try {
                ElementDescriptor srcPath = mDfs.asElement(src);
                ElementDescriptor dstPath = mLfs.asElement(dst);
               
                srcPath.copy(dstPath, false);
            }
            catch (DataStorageException e) {
                throw new IOException("Failed to copy " + src + "to (locally) " + dst, e);
View Full Code Here

Examples of org.apache.pig.backend.datastorage.ElementDescriptor

        if(mExplain == null) { // process only if not in "explain" mode
           
            executeBatch();
       
            try {
                ElementDescriptor srcPath = mLfs.asElement(src);
                ElementDescriptor dstPath = mDfs.asElement(dst);
               
                srcPath.copy(dstPath, false);
            }
            catch (DataStorageException e) {
                throw new IOException("Failed to copy (loally) " + src + "to " + dst, e);
View Full Code Here

Examples of org.apache.pig.backend.datastorage.ElementDescriptor

    @Override
    protected void processRemove(String path, String options ) throws IOException
    {
        if(mExplain == null) { // process only if not in "explain" mode

            ElementDescriptor dfsPath = mDfs.asElement(path);   
            executeBatch();
       
            if (!dfsPath.exists()) {
                if (options == null || !options.equalsIgnoreCase("force")) {
                    throw new IOException("File or directory " + path + " does not exist.");
                }
            }
            else {
               
                dfsPath.delete();
            }
        } else {
            log.warn("'rm/rmf' statement is ignored while processing 'explain -script' or '-check'");
        }
    }
View Full Code Here

Examples of org.apache.pig.backend.datastorage.ElementDescriptor

            return;
        }
       
        System.out.println("Renaming " + oldName + " to " + newName);

        ElementDescriptor dst = null;
        ElementDescriptor src = null;           

        try {
            dst = dfs.asElement(newName);
            src = dfs.asElement(oldName);           
        }
        catch (DataStorageException e) {
            byte errSrc = getErrorSource();           
            int errCode = 0;
            switch(errSrc) {
            case PigException.REMOTE_ENVIRONMENT:
                errCode = 6005;
                break;
            case PigException.USER_ENVIRONMENT:
                errCode = 4005;
                break;
            default:
                errCode = 2038;
                    break;
            }
            String msg = "Unable to rename " + oldName + " to " + newName;           
            throw new ExecException(msg, errCode, errSrc, e);
        }

        if (dst.exists()) {
            dst.delete();
        }
       
        src.rename(dst);

    }
View Full Code Here

Examples of org.apache.pig.backend.datastorage.ElementDescriptor

       
        if (localDst) {
            dstStorage = lfs;
        }
       
        ElementDescriptor srcElement = null;
        ElementDescriptor dstElement = null;

        try {
            srcElement = dfs.asElement(src);
            dstElement = dstStorage.asElement(dst);
        }
View Full Code Here

Examples of org.apache.pig.backend.datastorage.ElementDescriptor

     * @return length of the file in bytes
     * @throws IOException
     */
    public long fileSize(String filename) throws IOException {
        DataStorage dfs = pigContext.getDfs();
        ElementDescriptor elem = dfs.asElement(filename);
        Map<String, Object> stats = elem.getStatistics();
        long length = (Long) stats.get(ElementDescriptor.LENGTH_KEY);
        int replication = (Short) stats
                .get(ElementDescriptor.BLOCK_REPLICATION_KEY);

        return length * replication;
 
View Full Code Here

Examples of org.apache.pig.backend.datastorage.ElementDescriptor

     * @param filename to test
     * @return true if file exists, false otherwise
     * @throws IOException
     */
    public boolean existsFile(String filename) throws IOException {
        ElementDescriptor elem = pigContext.getDfs().asElement(filename);
        return elem.exists();
    }
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.