List of usage examples for org.apache.hadoop.io NullWritable get
public static NullWritable get()
From source file:com.asakusafw.example.direct.seqfile.jobflow.format.SalesDetailSeqFileFormat.java
License:Apache License
@Override protected NullWritable createKeyObject() { return NullWritable.get(); }
From source file:com.asakusafw.runtime.flow.ResultOutput.java
License:Apache License
/** * Returns a key for the value. * @param result target value * @return a corresponded key */ protected Object getKey(T result) { return NullWritable.get(); }
From source file:com.asakusafw.runtime.io.sequencefile.SequenceFileModelInput.java
License:Apache License
@Override public boolean readTo(T model) throws IOException { return reader.next(NullWritable.get(), model); }
From source file:com.asakusafw.runtime.io.sequencefile.SequenceFileModelOutput.java
License:Apache License
@Override public void write(T model) throws IOException { writer.append(NullWritable.get(), model); }
From source file:com.asakusafw.runtime.stage.temporary.TemporaryFileTest.java
License:Apache License
/** * Writes {@link NullWritable}s.// www .j a va 2 s .c om * @throws Exception if failed */ @Test public void null_entry() throws Exception { // eagerly initializes snappy Snappy.getNativeLibraryVersion(); File file = folder.newFile(); try (ModelOutput<NullWritable> out = new TemporaryFileOutput<>( new BufferedOutputStream(new FileOutputStream(file)), NullWritable.class.getName(), 1024, 256 * 1024)) { out.write(NullWritable.get()); out.write(NullWritable.get()); out.write(NullWritable.get()); } try (TemporaryFileInput<NullWritable> in = new TemporaryFileInput<>( new BufferedInputStream(new FileInputStream(file)), 0)) { assertThat(in.readTo(NullWritable.get()), is(true)); assertThat(in.readTo(NullWritable.get()), is(true)); assertThat(in.readTo(NullWritable.get()), is(true)); assertThat(in.readTo(NullWritable.get()), is(false)); } }
From source file:com.asakusafw.testdriver.file.FileDeployer.java
License:Apache License
/** * Opens output for the specified {@link OutputFormat}. * @param <V> value type// www .j a v a 2 s . c o m * @param definition target model definition * @param destination output location * @param output format * @return the opened {@link ModelOutput} * @throws IOException if failed to open the target output * @throws IllegalArgumentException if some parameters were {@code null} */ public <V> ModelOutput<V> openOutput(DataModelDefinition<V> definition, final String destination, FileOutputFormat<? super NullWritable, ? super V> output) throws IOException { assert destination != null; assert output != null; LOG.debug("Opening {} using {}", destination, output.getClass().getName()); Job job = Job.getInstance(configuration); job.setOutputKeyClass(NullWritable.class); job.setOutputValueClass(definition.getModelClass()); final File temporaryDir = File.createTempFile("asakusa", ".tempdir"); if (temporaryDir.delete() == false || temporaryDir.mkdirs() == false) { throw new IOException("Failed to create temporary directory"); } LOG.debug("Using staging deploy target: {}", temporaryDir); URI uri = temporaryDir.toURI(); FileOutputFormat.setOutputPath(job, new Path(uri)); TaskAttemptContext context = new TaskAttemptContextImpl(job.getConfiguration(), new TaskAttemptID(new TaskID(new JobID(), TaskType.MAP, 0), 0)); FileOutputFormatDriver<V> result = new FileOutputFormatDriver<V>(context, output, NullWritable.get()) { @Override public void close() throws IOException { super.close(); deploy(destination, temporaryDir); } }; return result; }
From source file:com.asakusafw.testdriver.file.FileExporterRetrieverTest.java
License:Apache License
private void putTextSequenceFile(String path, String... lines) throws IOException { try (SequenceFile.Writer writer = SequenceFile.createWriter(factory.newInstance(), SequenceFile.Writer.file(fileSystem.makeQualified(new Path(path))), SequenceFile.Writer.keyClass(NullWritable.class), SequenceFile.Writer.valueClass(Text.class))) { for (String s : lines) { writer.append(NullWritable.get(), new Text(s)); }/*from www.j a v a 2s.c o m*/ } }
From source file:com.asakusafw.testdriver.file.FileImporterPreparatorTest.java
License:Apache License
/** * sequence file./*from w w w. ja va2 s . co m*/ * @throws Exception if test was failed */ @Test public void sequenceFile() throws Exception { FileImporterPreparator target = new FileImporterPreparator(factory); try (ModelOutput<Text> open = target.createOutput(new MockTextDefinition(), new MockFileImporter(Text.class, SequenceFileInputFormat.class, "target/testing/input"), EMPTY)) { open.write(new Text("Hello, world!")); open.write(new Text("This is a test.")); } try (SequenceFile.Reader reader = new SequenceFile.Reader(factory.newInstance(), SequenceFile.Reader.file(fileSystem.makeQualified(new Path("target/testing/input"))))) { Text text = new Text(); assertThat(reader.next(NullWritable.get(), text), is(true)); assertThat(text.toString(), is("Hello, world!")); assertThat(reader.next(NullWritable.get(), text), is(true)); assertThat(text.toString(), is("This is a test.")); assertThat(reader.next(NullWritable.get(), text), is(false)); } }
From source file:com.asakusafw.testtools.TestDataHolder.java
License:Apache License
/** * ??/* w w w . ja v a2 s . c o m*/ * @param reader ?? * @throws IOException ?????? * @deprecated Use {@link #load(ModelInput)} instead */ @Deprecated public void load(SequenceFile.Reader reader) throws IOException { NullWritable key = NullWritable.get(); for (;;) { Writable model; try { model = modelClass.newInstance(); } catch (InstantiationException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } if (reader.next(key, model)) { actual.add(model); } else { break; } } }
From source file:com.bah.culvert.hive.CulvertRecordReader.java
License:Apache License
@Override public NullWritable createKey() { return NullWritable.get(); }