List of usage examples for org.apache.hadoop.io ByteWritable set
public void set(byte value)
From source file:org.apache.camel.component.hdfs.HdfsConsumerTest.java
License:Apache License
@Test public void testReadByte() throws Exception { if (!canTest()) { return;/*w w w . jav a 2 s . c o m*/ } final Path file = new Path(new File("target/test/test-camel-byte").getAbsolutePath()); Configuration conf = new Configuration(); FileSystem fs1 = FileSystem.get(file.toUri(), conf); SequenceFile.Writer writer = createWriter(fs1, conf, file, NullWritable.class, ByteWritable.class); NullWritable keyWritable = NullWritable.get(); ByteWritable valueWritable = new ByteWritable(); byte value = 3; valueWritable.set(value); writer.append(keyWritable, valueWritable); writer.sync(); writer.close(); MockEndpoint resultEndpoint = context.getEndpoint("mock:result", MockEndpoint.class); resultEndpoint.expectedMessageCount(1); resultEndpoint.message(0).body(byte.class).isEqualTo(3); context.addRoutes(new RouteBuilder() { public void configure() { from("hdfs:///" + file.toUri() + "?fileSystemType=LOCAL&fileType=SEQUENCE_FILE&initialDelay=0") .to("mock:result"); } }); context.start(); resultEndpoint.assertIsSatisfied(); }
From source file:org.apache.camel.component.hdfs2.HdfsConsumerTest.java
License:Apache License
@Test public void testReadByte() throws Exception { if (!canTest()) { return;/*from w w w . j a v a2 s . c om*/ } final Path file = new Path(new File("target/test/test-camel-byte").getAbsolutePath()); Configuration conf = new Configuration(); SequenceFile.Writer writer = createWriter(conf, file, NullWritable.class, ByteWritable.class); NullWritable keyWritable = NullWritable.get(); ByteWritable valueWritable = new ByteWritable(); byte value = 3; valueWritable.set(value); writer.append(keyWritable, valueWritable); writer.sync(); writer.close(); MockEndpoint resultEndpoint = context.getEndpoint("mock:result", MockEndpoint.class); resultEndpoint.expectedMessageCount(1); resultEndpoint.message(0).body(byte.class).isEqualTo(3); context.addRoutes(new RouteBuilder() { public void configure() { from("hdfs2:///" + file.toUri() + "?fileSystemType=LOCAL&fileType=SEQUENCE_FILE&initialDelay=0") .to("mock:result"); } }); context.start(); resultEndpoint.assertIsSatisfied(); }
From source file:org.apache.giraph.hive.input.mapping.examples.LongByteHiveToMapping.java
License:Apache License
@Override public ByteWritable getMappingTarget(HiveReadableRecord record) { ByteWritable reusableTarget = getReusableMappingTarget(); reusableTarget.set(record.getByte(1)); return reusableTarget; }
From source file:org.apache.giraph.hive.input.mapping.examples.LongInt2ByteHiveToMapping.java
License:Apache License
@Override public ByteWritable getMappingTarget(HiveReadableRecord record) { int target = record.getInt(1); ByteWritable reusableTarget = getReusableMappingTarget(); int bVal = target % numWorkers; if ((bVal >>> 8) != 0) { throw new IllegalStateException("target % numWorkers overflows " + "byte range"); }/*from w ww . j a va2 s.c o m*/ reusableTarget.set((byte) bVal); return reusableTarget; }
From source file:org.apache.giraph.mapping.LongByteMappingStore.java
License:Apache License
@Override public ByteWritable getTarget(LongWritable vertexId, ByteWritable target) { Byte bval = getByteTarget(vertexId); if (bval == -1) { // worker not assigned by mapping return null; }//from ww w . jav a 2 s . c om target.set(bval); return target; }
From source file:org.apache.giraph.types.ByteToByteWritableWrapper.java
License:Apache License
@Override public void wrap(Byte javaValue, ByteWritable writableValue) { writableValue.set(javaValue); }
From source file:org.apache.giraph.types.ops.ByteTypeOps.java
License:Apache License
@Override public void set(ByteWritable to, ByteWritable from) { to.set(from.get()); }
From source file:org.apache.giraph.types.ops.collections.array.WByteArrayList.java
License:Apache License
@Override public void getIntoW(int index, ByteWritable to) { to.set(getByte(index)); }
From source file:org.apache.giraph.types.ops.collections.array.WByteArrayList.java
License:Apache License
@Override public void popIntoW(ByteWritable to) { to.set(popByte()); }
From source file:org.apache.orc.mapred.OrcMapredRecordReader.java
License:Apache License
static ByteWritable nextByte(ColumnVector vector, int row, Object previous) { if (vector.isRepeating) { row = 0;/* www .jav a 2 s .com*/ } if (vector.noNulls || !vector.isNull[row]) { ByteWritable result; if (previous == null || previous.getClass() != ByteWritable.class) { result = new ByteWritable(); } else { result = (ByteWritable) previous; } result.set((byte) ((LongColumnVector) vector).vector[row]); return result; } else { return null; } }