Package com.asakusafw.runtime.value

Examples of com.asakusafw.runtime.value.StringOption


        } finally {
            writer.close();
        }

        long fileLen = fs.getFileStatus(path).getLen();
        StringOption value = new StringOption();
        for (int attempt = 0; attempt < 5; attempt++) {
            int index = 0;
            long offset = 0;
            while (offset < fileLen) {
                long length = SequenceFile.SYNC_INTERVAL * (rand.nextInt(10) + 2);
                length = Math.min(length, fileLen - offset);
                ModelInput<StringOption> in = format.createInput(
                        StringOption.class,
                        fs,
                        path,
                        offset,
                        length,
                        new Counter());
                try {
                    while (in.readTo(value)) {
                        String answer = "Hello, world at " + index;
                        assertThat(value.getAsString(), is(answer));
                        index++;
                    }
                    assertThat("eof", in.readTo(value), is(false));
                } finally {
                    in.close();
View Full Code Here


        } finally {
            writer.close();
        }

        long fileLen = fs.getFileStatus(path).getLen();
        StringOption value = new StringOption();
        int index = 0;
        long offset = 0;
        while (offset < fileLen) {
            long length = SequenceFile.SYNC_INTERVAL * 2;
            length = Math.min(length, fileLen - offset);
            ModelInput<StringOption> in = format.createInput(
                    StringOption.class,
                    fs,
                    path,
                    offset,
                    length,
                    new Counter());
            try {
                while (in.readTo(value)) {
                    assertThat(value.get(), is(record));
                    index++;
                }
                assertThat("eof", in.readTo(value), is(false));
            } finally {
                in.close();
View Full Code Here

                path,
                0,
                fs.getFileStatus(path).getLen(),
                new Counter());
        try {
            assertThat("eof", in.readTo(new StringOption()), is(false));
        } finally {
            in.close();
        }
    }
View Full Code Here

        final int count = 10000;
        LocalFileSystem fs = FileSystem.getLocal(conf);
        Path path = new Path(folder.newFile("testing").toURI());
        ModelOutput<StringOption> out = format.createOutput(StringOption.class, fs, path, new Counter());
        try {
            StringOption value = new StringOption();
            for (int i = 0; i < count; i++) {
                value.modify("Hello, world at " + i);
                out.write(value);
            }
        } finally {
            out.close();
        }
View Full Code Here

        LocalFileSystem fs = FileSystem.getLocal(conf);
        Path path = new Path(folder.newFile("testing").toURI());
        ModelOutput<StringOption> out = format.codec(new DefaultCodec())
            .createOutput(StringOption.class, fs, path, new Counter());
        try {
            out.write(new StringOption("Hello, world!"));
        } finally {
            out.close();
        }

        SequenceFile.Reader reader = new SequenceFile.Reader(fs, path, conf);
View Full Code Here

        LocalFileSystem fs = FileSystem.getLocal(conf);
        Path path = new Path(folder.newFile("testing.gz").toURI());
        ModelOutput<StringOption> out = format.codec(null)
            .createOutput(StringOption.class, fs, path, new Counter());
        try {
            out.write(new StringOption("Hello, world!"));
        } finally {
            out.close();
        }

        SequenceFile.Reader reader = new SequenceFile.Reader(fs, path, conf);
View Full Code Here

        LocalFileSystem fs = FileSystem.getLocal(conf);
        Path path = new Path(folder.newFile("testing").toURI());
        format.getConf().set(SequenceFileFormat.KEY_COMPRESSION_CODEC, DefaultCodec.class.getName());
        ModelOutput<StringOption> out = format.createOutput(StringOption.class, fs, path, new Counter());
        try {
            out.write(new StringOption("Hello, world!"));
        } finally {
            out.close();
        }

        SequenceFile.Reader reader = new SequenceFile.Reader(fs, path, conf);
View Full Code Here

        LocalFileSystem fs = FileSystem.getLocal(conf);
        Path path = new Path(folder.newFile("testing").toURI());
        format.getConf().set(SequenceFileFormat.KEY_COMPRESSION_CODEC, "__INVALID__");
        ModelOutput<StringOption> out = format.createOutput(StringOption.class, fs, path, new Counter());
        try {
            out.write(new StringOption("Hello, world!"));
        } finally {
            out.close();
        }

        SequenceFile.Reader reader = new SequenceFile.Reader(fs, path, conf);
View Full Code Here

        assertThat(parser.next(), is(true));
        try {
            assertFill(parser, "a");
            assertFill(parser, "b");
            assertFill(parser, "c");
            parser.fill(new StringOption());
            parser.endRecord();
            fail();
        } catch (CsvFormatException e) {
            assertThat(e.getStatus().getReason(), is(Reason.TOO_SHORT_RECORD));
        }
View Full Code Here

            return;
        }
    }

    private void assertFill(CsvParser parser, String expect) throws CsvFormatException, IOException {
        StringOption buffer = new StringOption();
        parser.fill(buffer);
        assertThat(buffer.toString(), buffer.has(expect), is(true));
    }
View Full Code Here

TOP

Related Classes of com.asakusafw.runtime.value.StringOption

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.