本文整理汇总了Java中org.apache.giraph.io.EdgeReader类的典型用法代码示例。如果您正苦于以下问题:Java EdgeReader类的具体用法?Java EdgeReader怎么用?Java EdgeReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EdgeReader类属于org.apache.giraph.io包,在下文中一共展示了EdgeReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createEdgeReader
import org.apache.giraph.io.EdgeReader; //导入依赖的package包/类
@Override
public EdgeReader<I, E> createEdgeReader(InputSplit split,
TaskAttemptContext context)
throws IOException {
HiveEdgeReader<I, E> reader = new HiveEdgeReader<I, E>();
reader.setTableSchema(getTableSchema());
RecordReader<WritableComparable, HiveReadableRecord> baseReader;
try {
baseReader = hiveInputFormat.createRecordReader(split, context);
} catch (InterruptedException e) {
throw new IllegalStateException("Could not create edge record reader", e);
}
reader.setHiveRecordReader(baseReader);
return new EdgeReaderWrapper<I, E>(reader);
}
示例2: createEdgeReader
import org.apache.giraph.io.EdgeReader; //导入依赖的package包/类
@Override
public EdgeReader<I, E> createEdgeReader(InputSplit split,
TaskAttemptContext context)
throws IOException {
HiveEdgeReader<I, E> reader = new HiveEdgeReader<I, E>();
reader.setTableSchema(hiveInputFormat.getTableSchema(getConf()));
RecordReader<WritableComparable, HiveReadableRecord> baseReader;
try {
baseReader = hiveInputFormat.createRecordReader(split, context);
} catch (InterruptedException e) {
throw new IllegalStateException("Could not create edge record reader", e);
}
reader.setHiveRecordReader(baseReader);
return new EdgeReaderWrapper<I, E>(reader);
}
示例3: createEdgeReader
import org.apache.giraph.io.EdgeReader; //导入依赖的package包/类
@Override
public EdgeReader<IntWritable, IntWritable> createEdgeReader(
InputSplit split, TaskAttemptContext context) throws IOException {
String duplicator = this.getConf().get("io.edge.reverse.duplicator");
boolean useDuplicator = (null != duplicator) ? Boolean.parseBoolean(duplicator) : false;
EdgeReader<IntWritable,IntWritable> reader = (useDuplicator) ? new ReverseEdgeDuplicator<IntWritable, IntWritable>(new SBEdgeReader()) : new SBEdgeReader();
return reader;
}
示例4: createEdgeReader
import org.apache.giraph.io.EdgeReader; //导入依赖的package包/类
public EdgeReader<Text, Text> createEdgeReader(final RecordReader<LongWritable,Text> rr) throws IOException {
return new DGATextEdgeValueReader(){
@Override
protected RecordReader<LongWritable, Text> createLineRecordReader(InputSplit inputSplit, TaskAttemptContext context) throws IOException, InterruptedException {
return rr;
}
};
}
示例5: testInputParserWithDefaultWeight
import org.apache.giraph.io.EdgeReader; //导入依赖的package包/类
@Test
public void testInputParserWithDefaultWeight() throws IOException, InterruptedException {
String input = "1,2";
when(rr.getCurrentValue()).thenReturn(new Text(input));
EdgeReader ter = createEdgeReader(rr);
ter.setConf(conf);
ter.initialize(null, tac);
assertEquals(ter.getCurrentSourceId(), new Text("1"));
assertEquals(ter.getCurrentEdge().getTargetVertexId(), new Text("2"));
assertEquals(ter.getCurrentEdge().getValue(), new Text(""));
}
示例6: testInputParserWithDefaultWeightAndOverriddenSeparator
import org.apache.giraph.io.EdgeReader; //导入依赖的package包/类
@Test
public void testInputParserWithDefaultWeightAndOverriddenSeparator() throws IOException, InterruptedException {
String input = "1\t2";
when(rr.getCurrentValue()).thenReturn(new Text(input));
EdgeReader ter = createEdgeReader(rr);
conf.set(LINE_TOKENIZE_VALUE, "\t");
ter.setConf(conf);
ter.initialize(null, tac);
assertEquals(ter.getCurrentSourceId(), new Text("1"));
assertEquals(ter.getCurrentEdge().getTargetVertexId(), new Text("2"));
assertEquals(ter.getCurrentEdge().getValue(), new Text());
}
示例7: testInputParserWithCustomWeight
import org.apache.giraph.io.EdgeReader; //导入依赖的package包/类
@Test
public void testInputParserWithCustomWeight() throws IOException, InterruptedException {
String input = "1,2,10";
when(rr.getCurrentValue()).thenReturn(new Text(input));
EdgeReader ter = createEdgeReader(rr);
ter.setConf(conf);
ter.initialize(null, tac);
assertEquals(ter.getCurrentSourceId(), new Text("1"));
assertEquals(ter.getCurrentEdge().getTargetVertexId(), new Text("2"));
assertEquals(ter.getCurrentEdge().getValue(), new Text("10"));
}
示例8: testInputParserIgnoreWeight
import org.apache.giraph.io.EdgeReader; //导入依赖的package包/类
@Test
public void testInputParserIgnoreWeight() throws IOException, InterruptedException {
String input = "1,2,10";
conf.set(IO_IGNORE_THIRD, "true");
when(rr.getCurrentValue()).thenReturn(new Text(input));
EdgeReader ter = createEdgeReader(rr);
ter.setConf(conf);
ter.initialize(null, tac);
assertEquals(ter.getCurrentSourceId(), new Text("1"));
assertEquals(ter.getCurrentEdge().getTargetVertexId(), new Text("2"));
assertEquals(ter.getCurrentEdge().getValue(), new Text(""));
}
示例9: testInputParserWithCustomWeightAndOverriddenSeparator
import org.apache.giraph.io.EdgeReader; //导入依赖的package包/类
@Test
public void testInputParserWithCustomWeightAndOverriddenSeparator() throws IOException, InterruptedException {
String input = "1\t2\t10";
when(rr.getCurrentValue()).thenReturn(new Text(input));
EdgeReader ter = createEdgeReader(rr);
conf.set(LINE_TOKENIZE_VALUE, "\t");
ter.setConf(conf);
ter.initialize(null, tac);
assertEquals(ter.getCurrentSourceId(), new Text("1"));
assertEquals(ter.getCurrentEdge().getTargetVertexId(), new Text("2"));
assertEquals(ter.getCurrentEdge().getValue(), new Text("10"));
}
示例10: testInputParserWithDelimiterInData
import org.apache.giraph.io.EdgeReader; //导入依赖的package包/类
@Test
public void testInputParserWithDelimiterInData() throws IOException, InterruptedException {
String input = "te\\[email protected]\[email protected]\t10";
when(rr.getCurrentValue()).thenReturn(new Text(input));
EdgeReader ter = createEdgeReader(rr);
conf.set(LINE_TOKENIZE_VALUE, "\t");
ter.setConf(conf);
ter.initialize(null, tac);
assertEquals(ter.getCurrentSourceId(), new Text("te\\[email protected]"));
assertEquals(ter.getCurrentEdge().getTargetVertexId(), new Text("[email protected]"));
assertEquals(ter.getCurrentEdge().getValue(), new Text("10"));
}
示例11: testInputParserWithDelimiterInDataNoEscape
import org.apache.giraph.io.EdgeReader; //导入依赖的package包/类
@Test
public void testInputParserWithDelimiterInDataNoEscape() throws IOException, InterruptedException {
String input = "te\[email protected]\[email protected]\t10";
when(rr.getCurrentValue()).thenReturn(new Text(input));
EdgeReader ter = createEdgeReader(rr);
conf.set(LINE_TOKENIZE_VALUE, "\t");
ter.setConf(conf);
ter.initialize(null, tac);
assertEquals(ter.getCurrentSourceId(), new Text("te"));
assertEquals(ter.getCurrentEdge().getTargetVertexId(), new Text("[email protected]"));
assertEquals(ter.getCurrentEdge().getValue(), new Text("[email protected]"));
}
示例12: testInputParserWithMalformedLine
import org.apache.giraph.io.EdgeReader; //导入依赖的package包/类
@Test(expected=IOException.class)
public void testInputParserWithMalformedLine() throws IOException, InterruptedException {
String input = "1";
when(rr.getCurrentValue()).thenReturn(new Text(input));
EdgeReader ter = createEdgeReader(rr);
ter.setConf(conf);
ter.initialize(null, tac);
assertEquals(ter.getCurrentSourceId(), new Text("1"));
assertEquals(ter.getCurrentEdge().getTargetVertexId(), new Text());
assertEquals(ter.getCurrentEdge().getValue(), new Text());
}
示例13: testInputParserWithMalformedLineAndDelimiter
import org.apache.giraph.io.EdgeReader; //导入依赖的package包/类
@Test(expected=IOException.class)
public void testInputParserWithMalformedLineAndDelimiter() throws IOException, InterruptedException {
String input = "1,";
when(rr.getCurrentValue()).thenReturn(new Text(input));
EdgeReader ter = createEdgeReader(rr);
ter.setConf(conf);
ter.initialize(null, tac);
assertEquals(ter.getCurrentSourceId(), new Text("1"));
assertEquals(ter.getCurrentEdge().getTargetVertexId(), new Text());
assertEquals(ter.getCurrentEdge().getValue(), new Text());
}
示例14: testInputParserWithMalformedLineAndDelimiterNoSource
import org.apache.giraph.io.EdgeReader; //导入依赖的package包/类
@Test(expected=IOException.class)
public void testInputParserWithMalformedLineAndDelimiterNoSource() throws IOException, InterruptedException {
String input = ",1";
when(rr.getCurrentValue()).thenReturn(new Text(input));
EdgeReader ter = createEdgeReader(rr);
ter.setConf(conf);
ter.initialize(null, tac);
assertEquals(ter.getCurrentSourceId(), new Text());
assertEquals(ter.getCurrentEdge().getTargetVertexId(), new Text("1"));
assertEquals(ter.getCurrentEdge().getValue(), new Text());
}
示例15: createEdgeReader
import org.apache.giraph.io.EdgeReader; //导入依赖的package包/类
public EdgeReader<Text, LongWritable> createEdgeReader(final RecordReader<LongWritable,Text> rr) throws IOException {
return new DGALongEdgeValueReader(){
@Override
protected RecordReader<LongWritable, Text> createLineRecordReader(InputSplit inputSplit, TaskAttemptContext context) throws IOException, InterruptedException {
return rr;
}
};
}