List of usage examples for org.apache.hadoop.io BooleanWritable BooleanWritable
public BooleanWritable()
From source file:inflater.datatypes.writable.MessageWritable.java
License:MIT License
public MessageWritable() { this(new LongWritable(), new CoordinateWritable(), new BooleanWritable()); }
From source file:it.crs4.pydoop.mapreduce.pipes.PipeReducerStub.java
License:Apache License
public void binaryProtocolStub() { try {// w w w. j a v a2s . c o m initSoket(); //should be 5 //RUN_REDUCE boolean WritableUtils.readVInt(dataInput); WritableUtils.readVInt(dataInput); int intValue = WritableUtils.readVInt(dataInput); System.out.println("getIsJavaRecordWriter:" + intValue); // reduce key WritableUtils.readVInt(dataInput); // value of reduce key BooleanWritable value = new BooleanWritable(); readObject(value, dataInput); System.out.println("reducer key :" + value); // reduce value code: // reduce values while ((intValue = WritableUtils.readVInt(dataInput)) == 7) { Text txt = new Text(); // value readObject(txt, dataInput); System.out.println("reduce value :" + txt); } // done WritableUtils.writeVInt(dataOut, 54); dataOut.flush(); dataOut.close(); } catch (Exception x) { x.printStackTrace(); } finally { closeSoket(); } }
From source file:ml.grafos.okapi.clustering.ap.APVertexValue.java
License:Apache License
public APVertexValue() { exemplar = new LongWritable(); weights = new MapWritable(); lastSentMessages = new MapWritable(); lastReceivedMessages = new MapWritable(); converged = new BooleanWritable(); exemplarCalc = new BooleanWritable(); }
From source file:nl.tudelft.graphalytics.giraph.algorithms.cdlp.CommunityDetectionLPComputationTest.java
License:Apache License
@Override public CommunityDetectionLPOutput executeDirectedCommunityDetection(GraphStructure graph, CommunityDetectionLPParameters parameters) throws Exception { GiraphConfiguration configuration = configurationFromParameters( DirectedCommunityDetectionLPComputation.class, parameters); TestGraph<LongWritable, LongWritable, BooleanWritable> inputGraph = GiraphTestGraphLoader .createGraph(configuration, graph, new LongWritable(), new BooleanWritable()); TestGraph<LongWritable, LongWritable, BooleanWritable> result = InternalVertexRunner .runWithInMemoryOutput(configuration, inputGraph); return outputFromResultGraph(result); }
From source file:org.apache.camel.component.hdfs.HdfsConsumerTest.java
License:Apache License
@Test public void testReadBoolean() throws Exception { if (!canTest()) { return;/*w w w . jav a 2s .c o m*/ } final Path file = new Path(new File("target/test/test-camel-boolean").getAbsolutePath()); Configuration conf = new Configuration(); FileSystem fs1 = FileSystem.get(file.toUri(), conf); SequenceFile.Writer writer = createWriter(fs1, conf, file, NullWritable.class, BooleanWritable.class); NullWritable keyWritable = NullWritable.get(); BooleanWritable valueWritable = new BooleanWritable(); valueWritable.set(true); writer.append(keyWritable, valueWritable); writer.sync(); writer.close(); context.addRoutes(new RouteBuilder() { public void configure() { from("hdfs:///" + file.toUri() + "?fileSystemType=LOCAL&fileType=SEQUENCE_FILE&initialDelay=0") .to("mock:result"); } }); context.start(); MockEndpoint resultEndpoint = context.getEndpoint("mock:result", MockEndpoint.class); resultEndpoint.expectedMessageCount(1); resultEndpoint.assertIsSatisfied(); }
From source file:org.apache.camel.component.hdfs2.HdfsConsumerTest.java
License:Apache License
@Test public void testReadBoolean() throws Exception { if (!canTest()) { return;/* w w w . j a v a2s . c o m*/ } final Path file = new Path(new File("target/test/test-camel-boolean").getAbsolutePath()); Configuration conf = new Configuration(); SequenceFile.Writer writer = createWriter(conf, file, NullWritable.class, BooleanWritable.class); NullWritable keyWritable = NullWritable.get(); BooleanWritable valueWritable = new BooleanWritable(); valueWritable.set(true); writer.append(keyWritable, valueWritable); writer.sync(); writer.close(); context.addRoutes(new RouteBuilder() { public void configure() { from("hdfs2:///" + file.toUri() + "?fileSystemType=LOCAL&fileType=SEQUENCE_FILE&initialDelay=0") .to("mock:result"); } }); context.start(); MockEndpoint resultEndpoint = context.getEndpoint("mock:result", MockEndpoint.class); resultEndpoint.expectedMessageCount(1); resultEndpoint.assertIsSatisfied(); }
From source file:org.apache.giraph.block_app.framework.BlockExecutionTest.java
License:Apache License
@Test public void testMessageSending() { TestGraph<LongWritable, LongWritable, NullWritable> graph = createTestGraph(); LocalBlockRunner.runBlock(graph,/*from ww w. j a va 2 s . c o m*/ new Piece<WritableComparable, LongWritable, Writable, BooleanWritable, Object>() { @Override public VertexSender<WritableComparable, LongWritable, Writable> getVertexSender( final BlockWorkerSendApi<WritableComparable, LongWritable, Writable, BooleanWritable> workerApi, Object executionStage) { return new InnerVertexSender() { @Override public void vertexSend(Vertex<WritableComparable, LongWritable, Writable> vertex) { workerApi.sendMessageToAllEdges(vertex, new BooleanWritable()); } }; } @Override public VertexReceiver<WritableComparable, LongWritable, Writable, BooleanWritable> getVertexReceiver( BlockWorkerReceiveApi<WritableComparable> workerApi, Object executionStage) { return new InnerVertexReceiver() { @Override public void vertexReceive(Vertex<WritableComparable, LongWritable, Writable> vertex, Iterable<BooleanWritable> messages) { vertex.getValue().set(Iterables.size(messages)); } }; } @Override protected Class<BooleanWritable> getMessageClass() { return BooleanWritable.class; } }, new Object()); Assert.assertEquals(1, graph.getVertex(new LongWritable(1)).getValue().get()); Assert.assertEquals(2, graph.getVertex(new LongWritable(2)).getValue().get()); Assert.assertEquals(1, graph.getVertex(new LongWritable(3)).getValue().get()); Assert.assertEquals(0, graph.getVertex(new LongWritable(4)).getValue().get()); }
From source file:org.apache.giraph.types.ops.BooleanTypeOps.java
License:Apache License
@Override public BooleanWritable create() { return new BooleanWritable(); }
From source file:org.apache.orc.mapred.OrcMapredRecordReader.java
License:Apache License
static BooleanWritable nextBoolean(ColumnVector vector, int row, Object previous) { if (vector.isRepeating) { row = 0;//from w ww . j a v a 2 s . c o m } if (vector.noNulls || !vector.isNull[row]) { BooleanWritable result; if (previous == null || previous.getClass() != BooleanWritable.class) { result = new BooleanWritable(); } else { result = (BooleanWritable) previous; } result.set(((LongColumnVector) vector).vector[row] != 0); return result; } else { return null; } }
From source file:org.apache.orc.mapred.OrcStruct.java
License:Apache License
public static WritableComparable createValue(TypeDescription type) { switch (type.getCategory()) { case BOOLEAN: return new BooleanWritable(); case BYTE://from w ww . ja v a 2s. c o m return new ByteWritable(); case SHORT: return new ShortWritable(); case INT: return new IntWritable(); case LONG: return new LongWritable(); case FLOAT: return new FloatWritable(); case DOUBLE: return new DoubleWritable(); case BINARY: return new BytesWritable(); case CHAR: case VARCHAR: case STRING: return new Text(); case DATE: return new DateWritable(); case TIMESTAMP: return new OrcTimestamp(); case DECIMAL: return new HiveDecimalWritable(); case STRUCT: { OrcStruct result = new OrcStruct(type); int c = 0; for (TypeDescription child : type.getChildren()) { result.setFieldValue(c++, createValue(child)); } return result; } case UNION: return new OrcUnion(type); case LIST: return new OrcList(type); case MAP: return new OrcMap(type); default: throw new IllegalArgumentException("Unknown type " + type); } }