Package com.asakusafw.vocabulary.directio

Examples of com.asakusafw.vocabulary.directio.DirectFileInputDescription


        return valid;
    }

    private boolean validateInput(InputDescription input) {
        boolean valid = true;
        DirectFileInputDescription desc = extract(input);
        valid &= checkBasePath(desc.getClass(), desc.getBasePath(), "入力ベースパス");
        String pattern = desc.getResourcePattern();
        try {
            FilePattern.compile(pattern);
        } catch (IllegalArgumentException e) {
            getEnvironment().error(
                    "入力リソース名のパターンが不正です ({1}): {0}",
                    e.getMessage(),
                    desc.getClass().getName());
            valid = false;
        }
        valid &= validateFormat(desc.getClass(), desc.getModelType(), desc.getFormat());
        return valid;
    }
View Full Code Here


        assert inputs != null;
        assert outputs != null;
        boolean valid = true;
        TreeMap<String, InputDescription> inputPaths = new TreeMap<String, InputDescription>();
        for (InputDescription input : inputs) {
            DirectFileInputDescription desc = extract(input);
            String path = normalizePath(desc.getBasePath());
            inputPaths.put(path, input);
        }
        TreeMap<String, OutputDescription> outputPaths = new TreeMap<String, OutputDescription>();
        for (OutputDescription output : outputs) {
            DirectFileOutputDescription desc = extract(output);
            String path = normalizePath(desc.getBasePath());
            for (Map.Entry<String, InputDescription> entry : inputPaths.tailMap(path, true).entrySet()) {
                if (entry.getKey().startsWith(path) == false) {
                    break;
                }
                DirectFileInputDescription other = extract(entry.getValue());
                getEnvironment().error(
                        "入出力のベースパスが衝突しています: {0}[{1}] -> {2}[{3}]",
                        desc.getClass().getName(),
                        desc.getBasePath(),
                        other.getClass().getName(),
                        other.getBasePath());
                valid = false;
            }
            if (outputPaths.containsKey(path)) {
                DirectFileOutputDescription other = extract(outputPaths.get(path));
                getEnvironment().error(
                        "2つの出力のベースパスが重複しています: {0}[{1}] <-> {2}[{3}]",
                        desc.getClass().getName(),
                        desc.getBasePath(),
                        other.getClass().getName(),
                        other.getBasePath());
                valid = false;
            } else {
                outputPaths.put(path, output);
            }
        }
        for (Map.Entry<String, OutputDescription> base : outputPaths.entrySet()) {
            String path = base.getKey();
            DirectFileOutputDescription desc = extract(base.getValue());
            for (Map.Entry<String, OutputDescription> entry : outputPaths.tailMap(path, false).entrySet()) {
                if (entry.getKey().startsWith(path) == false) {
                    break;
                }
                DirectFileOutputDescription other = extract(entry.getValue());
                getEnvironment().error(
                        "2つの出力のベースパスが衝突しています: {0}[{1}] -> {2}[{3}]",
                        desc.getClass().getName(),
                        desc.getBasePath(),
                        other.getClass().getName(),
                        other.getBasePath());
                valid = false;
            }
        }
        return valid;
    }
View Full Code Here

        return true;
    }

    @Override
    public SourceInfo getInputInfo(InputDescription description) {
        DirectFileInputDescription desc = extract(description);
        if (isCacheTarget(desc)) {
            String outputName = getProcessedInputName(description);
            Location location = getEnvironment().getPrologueLocation(MODULE_NAME).append(outputName).asPrefix();
            return new SourceInfo(Collections.singleton(location), TemporaryInputFormat.class);
        } else {
View Full Code Here

            return getOriginalInputInfo(description);
        }
    }

    private SourceInfo getOriginalInputInfo(InputDescription description) {
        DirectFileInputDescription desc = extract(description);
        Set<Location> locations = Collections.singleton(
                Location.fromPath("__DIRECTIO__", '/')
                .append(description.getName())
                .append(Location.fromPath(desc.getBasePath(), '/')));
        return new SourceInfo(locations, INPUT_FORMAT, getAttributes(desc));
    }
View Full Code Here

    public List<ExternalIoStage> emitPrologue(IoContext context) throws IOException {
        IoContextBuilder builder = new IoContextBuilder();
        List<CopyDescription> targets = Lists.create();
        for (Input input : context.getInputs()) {
            InputDescription description = input.getDescription();
            DirectFileInputDescription desc = extract(description);
            if (isCacheTarget(desc)) {
                LOG.debug("Input will be copied in prologue: {}", description.getName());
                targets.add(new CopyDescription(
                        getProcessedInputName(description),
                        getEnvironment().getDataClasses().load(description.getDataType()),
View Full Code Here

        Class<? extends DirectFileInputDescription> aClass = generate(description);
        assertThat(DirectFileInputDescription.class.isAssignableFrom(aClass), is(true));
        assertThat(Modifier.isAbstract(aClass.getModifiers()), is(false));

        DirectFileInputDescription object = aClass.newInstance();
        assertThat(object.getModelType(), is((Object) MockData.class));
        assertThat(object.getBasePath(), is("base-path"));
        assertThat(object.getResourcePattern(), is("*"));
        assertThat(object.getFormat(), is((Object) MockDataFormat.class));
        assertThat(object.isOptional(), is(false));
        assertThat(object.getDataSize(), is(DataSize.UNKNOWN));
    }
View Full Code Here

        Class<? extends DirectFileInputDescription> aClass = generate(description);
        assertThat(DirectFileInputDescription.class.isAssignableFrom(aClass), is(true));
        assertThat(Modifier.isAbstract(aClass.getModifiers()), is(false));

        DirectFileInputDescription object = aClass.newInstance();
        assertThat(object.getModelType(), is((Object) MockData.class));
        assertThat(object.getBasePath(), is("base-path"));
        assertThat(object.getResourcePattern(), is("*"));
        assertThat(object.getFormat(), is((Object) MockDataFormat.class));
        assertThat(object.isOptional(), is(true));
        assertThat(object.getDataSize(), is(DataSize.TINY));
    }
View Full Code Here

TOP

Related Classes of com.asakusafw.vocabulary.directio.DirectFileInputDescription

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.