Package com.asakusafw.runtime.directio

Examples of com.asakusafw.runtime.directio.DirectDataSource


        fs.create(txPath).close();
        fs.create(cmPath).close();
        int index = 0;
        for (String path : repo.getContainerPaths()) {
            String id = repo.getRelatedId(path);
            DirectDataSource ds = repo.getRelatedDataSource(path);
            OutputTransactionContext txContext = HadoopDataSourceUtil.createContext(executionId, id);
            OutputAttemptContext aContext = new OutputAttemptContext(
                    txContext.getTransactionId(),
                    String.valueOf(index),
                    txContext.getOutputId(),
                    new Counter());

            ds.setupTransactionOutput(txContext);
            ds.setupAttemptOutput(aContext);
            ModelOutput<StringBuilder> output = ds.openOutput(
                    aContext,
                    SimpleDataDefinition.newInstance(StringBuilder.class, new MockFormat()),
                    "",
                    executionId,
                    new Counter());
            try {
                output.write(new StringBuilder("Hello, world!"));
            } finally {
                output.close();
            }
            ds.commitAttemptOutput(aContext);
            ds.cleanupAttemptOutput(aContext);

            index++;
        }
    }
View Full Code Here


        }
        if (repository == null) {
            repository = HadoopDataSourceUtil.loadRepository(getConf());
        }
        String basePath = repository.getComponentPath(path);
        DirectDataSource source = repository.getRelatedDataSource(path);
        for (FilePattern pattern : patterns) {
            source.delete(basePath, pattern, recursive, new Counter());
        }
        return 0;
    }
View Full Code Here

        }
        if (repository == null) {
            repository = HadoopDataSourceUtil.loadRepository(getConf());
        }
        String basePath = repository.getComponentPath(path);
        DirectDataSource source = repository.getRelatedDataSource(path);
        for (FilePattern pattern : patterns) {
            List<ResourceInfo> list = source.list(basePath, pattern, new Counter());
            for (ResourceInfo info : list) {
                System.out.println(info.getPath());
            }
        }
        return 0;
View Full Code Here

            String path = variables.parse(rawBasePath, false);
            String id = repository.getRelatedId(path);
            OutputAttemptContext outputContext = HadoopDataSourceUtil.createContext(context, id);
            DataFormat<? super T> format = ReflectionUtils.newInstance(dataFormatClass, context.getConfiguration());
            DirectDataSource datasource = repository.getRelatedDataSource(path);
            String basePath = repository.getComponentPath(path);
            String unresolvedResourcePath = rawResourcePath.replaceAll(
                    Pattern.quote("*"),
                    String.format("%04d", context.getTaskAttemptID().getTaskID().getId()));
            String resourcePath = variables.parse(unresolvedResourcePath);
            DataDefinition<? super T> definition = SimpleDataDefinition.newInstance(dataType, format);

            if (log.isDebugEnabled()) {
                log.debug(MessageFormat.format(
                        "Open mapper output (id={0}, basePath={1}, resourcePath={2})",
                        id,
                        basePath,
                        resourcePath));
            }

            int records = 0;
            ModelOutput<? super T> output = datasource.openOutput(
                    outputContext,
                    definition,
                    basePath,
                    resourcePath,
                    outputContext.getCounter());
View Full Code Here

        String id = repository.getRelatedId(path);
        OutputAttemptContext outputContext = HadoopDataSourceUtil.createContext(context, id);
        DataDefinition definition = SimpleDataDefinition.newInstance(
                group.getDataType(),
                configure(context, group.getFormat()));
        DirectDataSource datasource = repository.getRelatedDataSource(path);
        String basePath = repository.getComponentPath(path);
        String resourcePath = variables.parse(group.getResourcePath());

        Counter counter = new Counter();
        ModelOutput output = datasource.openOutput(outputContext, definition, basePath, resourcePath, counter);

        long records = 0;
        try {
            for (Union union : values) {
                Object object = union.getObject();
View Full Code Here

        fs.create(txPath).close();
        fs.create(cmPath).close();
        int index = 0;
        for (String path : repo.getContainerPaths()) {
            String id = repo.getRelatedId(path);
            DirectDataSource ds = repo.getRelatedDataSource(path);
            OutputTransactionContext txContext = HadoopDataSourceUtil.createContext(executionId, id);
            OutputAttemptContext aContext = new OutputAttemptContext(
                    txContext.getTransactionId(),
                    String.valueOf(index),
                    txContext.getOutputId(),
                    new Counter());

            ds.setupTransactionOutput(txContext);
            ds.setupAttemptOutput(aContext);
            ModelOutput<StringBuilder> output = ds.openOutput(
                    aContext,
                    SimpleDataDefinition.newInstance(StringBuilder.class, new MockFormat()),
                    "",
                    executionId,
                    new Counter());
            try {
                output.write(new StringBuilder("Hello, world!"));
            } finally {
                output.close();
            }
            ds.commitAttemptOutput(aContext);
            ds.cleanupAttemptOutput(aContext);

            index++;
        }
    }
View Full Code Here

        Map<DirectInputGroup, List<InputPath>> patternGroups = extractInputList(context, repo, inputList);
        long totalSize = 0;
        for (Map.Entry<DirectInputGroup, List<InputPath>> entry : patternGroups.entrySet()) {
            DirectInputGroup group = entry.getKey();
            List<InputPath> paths = entry.getValue();
            DirectDataSource dataSource = repo.getRelatedDataSource(group.containerPath);
            DataFormat<?> format = ReflectionUtils.newInstance(group.formatClass, context.getConfiguration());
            DataDefinition<?> definition = SimpleDataDefinition.newInstance(group.dataType, format);
            for (InputPath path : paths) {
                List<DirectInputFragment> fragments = getFragments(repo, group, path, definition, dataSource);
                for (DirectInputFragment fragment : fragments) {
View Full Code Here

        assert containerPath != null;
        assert definition != null;
        assert counter != null;
        assert fragment != null;
        DirectDataSourceRepository repo = getDataSourceRepository(context);
        DirectDataSource ds = repo.getRelatedDataSource(containerPath);
        return ds.openInput(definition, fragment, counter);
    }
View Full Code Here

                            taskContext.getJobID(),
                            taskContext.getTaskAttemptID()));
                }
                OutputAttemptContext context = HadoopDataSourceUtil.createContext(taskContext, id);
                try {
                    DirectDataSource repo = repository.getRelatedDataSource(containerPath);
                    repo.setupAttemptOutput(context);
                } catch (IOException e) {
                    LOG.error(MessageFormat.format(
                            "Failed directio task setup: datasource={0} (job={1}, task={2})",
                            id,
                            taskContext.getJobID(),
View Full Code Here

                            taskContext.getJobID(),
                            taskContext.getTaskAttemptID()));
                }
                OutputAttemptContext context = HadoopDataSourceUtil.createContext(taskContext, id);
                try {
                    DirectDataSource repo = repository.getRelatedDataSource(containerPath);
                    repo.commitAttemptOutput(context);
                } catch (IOException e) {
                    LOG.error(MessageFormat.format(
                            "Failed directio task commit: datasource={0} (job={1}, task={2})",
                            id,
                            taskContext.getJobID(),
View Full Code Here

TOP

Related Classes of com.asakusafw.runtime.directio.DirectDataSource

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.