Package org.apache.pig.backend.datastorage

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


   
    protected void processCat(String path) throws IOException
    {
        try {
            byte buffer[] = new byte[65536];
            ElementDescriptor dfsPath = mDfs.asElement(path);
            int rc;
           
            if (!dfsPath.exists()) {
                StringBuilder sb = new StringBuilder();
                sb.append("Directory ");
                sb.append(path);
                sb.append(" does not exist.");
                throw new IOException(sb.toString());
            }
   
            if (mDfs.isContainer(path)) {
                ContainerDescriptor dfsDir = (ContainerDescriptor) dfsPath;
                Iterator<ElementDescriptor> paths = dfsDir.iterator();
               
                while (paths.hasNext()) {
                    ElementDescriptor curElem = paths.next();
                   
                    if (mDfs.isContainer(curElem.toString())) {
                        continue;
                    }
                   
                    InputStream is = curElem.open();
                    while ((rc = is.read(buffer)) > 0) {
                        System.out.write(buffer, 0, rc);
                    }
                    is.close();               
                }
View Full Code Here


    }
       
    protected void processLS(String path) throws IOException
    {
        try {
            ElementDescriptor pathDescriptor;
           
            if (path == null) {
                pathDescriptor = mDfs.getActiveContainer();
            }
            else {
                pathDescriptor = mDfs.asElement(path);
            }

            if (!pathDescriptor.exists()) {
                StringBuilder sb = new StringBuilder();
                sb.append("File or directory ");
                sb.append(path);
                sb.append(" does not exist.");
                throw new IOException(sb.toString());
            }
           
            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

    }

    protected void processMove(String src, String dst) throws IOException
    {
        try {
            ElementDescriptor srcPath = mDfs.asElement(src);
            ElementDescriptor dstPath = mDfs.asElement(dst);
           
            if (!srcPath.exists()) {
                StringBuilder sb = new StringBuilder();
                sb.append("File or directory ");
                sb.append(src);
View Full Code Here

    }
   
    protected void processCopy(String src, String dst) throws IOException
    {
        try {
            ElementDescriptor srcPath = mDfs.asElement(src);
            ElementDescriptor dstPath = mDfs.asElement(dst);
           
            srcPath.copy(dstPath, mConf, false);
        }
        catch (DataStorageException e) {
            StringBuilder sb = new StringBuilder();
View Full Code Here

    }
   
    protected void processCopyToLocal(String src, String dst) throws IOException
    {
        try {
            ElementDescriptor srcPath = mDfs.asElement(src);
            ElementDescriptor dstPath = mLfs.asElement(dst);
           
            srcPath.copy(dstPath, false);
        }
        catch (DataStorageException e) {
            StringBuilder sb = new StringBuilder();
View Full Code Here

    }

    protected void processCopyFromLocal(String src, String dst) throws IOException
    {
        try {
            ElementDescriptor srcPath = mLfs.asElement(src);
            ElementDescriptor dstPath = mDfs.asElement(dst);
           
            srcPath.copy(dstPath, false);
        }
        catch (DataStorageException e) {
            StringBuilder sb = new StringBuilder();
View Full Code Here

            mPigServer.registerQuery(cmd);
    }

    protected void processRemove(String path) throws IOException
    {
        ElementDescriptor dfsPath = mDfs.asElement(path);
       
        if (!dfsPath.exists()) {
            StringBuilder sb = new StringBuilder();
            sb.append("File or directory ");
            sb.append(path);
            sb.append(" does not exist.");
            throw new IOException(sb.toString());
        }
           
        dfsPath.delete();
    }
View Full Code Here

            sb.append(" to ");
            sb.append(newName);
            log.info(sb.toString());
        }

        ElementDescriptor dst = null;
        ElementDescriptor src = null;

        try {
            dst = dfs.asElement(newName);
            src = dfs.asElement(oldName);
        } catch (DataStorageException e) {
            StringBuilder sb = new StringBuilder();
            sb.append("Unable to rename ");
            sb.append(oldName);
            sb.append(" to ");
            sb.append(newName);
            throw WrappedIOException.wrap(sb.toString(), e);
        }

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

    }
View Full Code Here

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

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

        System.out.println("testing capacity");
        long capacity = pig.capacity();
        assertTrue(capacity > 0);
        String sampleFileName = "/tmp/fileTest";
        if (!pig.existsFile(sampleFileName)) {
            ElementDescriptor path = pigContext.getDfs().asElement(sampleFileName);
            OutputStream os = path.create();
            os.write("Ben was here!".getBytes());
            os.close();
        }
        long length = pig.fileSize(sampleFileName);
        assertTrue(length > 0);
View Full Code Here

TOP

Related Classes of org.apache.pig.backend.datastorage.ElementDescriptor

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.