Package org.apache.pig.backend.datastorage

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


        return fileExists(filename, context.getFs());
    }

    public static boolean fileExists(String filename, DataStorage store)
            throws IOException {
        ElementDescriptor elem = store.asElement(filename);
        return elem.exists() || globMatchesFiles(elem, store);
    }
View Full Code Here


        return isDirectory(filename, context.getDfs());
    }

    public static boolean isDirectory(String filename, DataStorage store)
    throws IOException {
        ElementDescriptor elem = store.asElement(filename);
        return (elem instanceof ContainerDescriptor);
    }
View Full Code Here

      deleteOnFail.clear();
    }
    public static void registerDeleteOnFail(String filename, PigContext pigContext) throws IOException
    {
      try {
        ElementDescriptor elem = pigContext.getDfs().asElement(filename);
        if (!toDelete.contains(elem))
            deleteOnFail.push(elem);
      }
        catch (DataStorageException e) {
            log.warn("Unable to register output file to delete on failure: " + filename);
View Full Code Here

            log.warn("Unable to register output file to delete on failure: " + filename);
        }
    }
    public static void triggerDeleteOnFail()
    {
      ElementDescriptor elem = null;
      while (!deleteOnFail.empty()) {
            try {
                elem = deleteOnFail.pop();
                if (elem.exists())
                  elem.delete();
            }
            catch (IOException e) {
                log.warn("Unable to delete output file on failure: " + elem.toString());
            }
      }
    }
View Full Code Here

           
            executeBatch();

            try {
                byte buffer[] = new byte[65536];
                ElementDescriptor dfsPath = mDfs.asElement(path);
                int rc;
               
                if (!dfsPath.exists())
                    throw new IOException("Directory " + path + " does not exist.");
       
                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

    @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

        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

        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

        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

        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

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.