List of usage examples for org.apache.hadoop.io Text Text
public Text(byte[] utf8)
From source file:be.uantwerpen.adrem.bigfim.AprioriPhaseMapperTest.java
License:Apache License
@Test public void phase_2_With_Input() throws Exception { AprioriPhaseMapper.Context ctx = createMock(Mapper.Context.class); ctx.write(new Text("1"), new Text("2 1")); ctx.write(new Text("1"), new Text("3 4")); ctx.write(new Text("1"), new Text("4 3")); ctx.write(new Text("2"), new Text("3 2")); ctx.write(new Text("2"), new Text("5 1")); ctx.write(new Text("3"), new Text("4 5")); ctx.write(new Text("4"), new Text("5 2")); EasyMock.replay(ctx);/*ww w . j ava 2 s .c o m*/ AprioriPhaseMapper mapper = createMapper(2, create_Count_Trie_Not_Empty()); for (int i = 0; i < data.length; i++) { mapper.map(new LongWritable(i), new Text(data[i]), ctx); } mapper.cleanup(ctx); EasyMock.verify(ctx); }
From source file:be.uantwerpen.adrem.bigfim.AprioriPhaseMapperTest.java
License:Apache License
@Test public void phase_2_With_Input_Empty_Count_Trie() throws Exception { AprioriPhaseMapper.Context ctx = createMock(Mapper.Context.class); EasyMock.replay(ctx);/*w w w . jav a 2 s.c o m*/ AprioriPhaseMapper mapper = createMapper(2, create_Count_Trie_Empty()); for (int i = 0; i < data.length; i++) { mapper.map(new LongWritable(i), new Text(data[i]), ctx); } mapper.cleanup(ctx); EasyMock.verify(ctx); }
From source file:be.uantwerpen.adrem.bigfim.AprioriPhaseReducer.java
License:Apache License
private void writeTrieGroup(String prefix, Map<String, MutableInt> supports) throws IOException, InterruptedException { String baseOutputPath = createPath(baseDir, "tg" + aprioriPhase, "trieGroup-" + (prefix.isEmpty() ? 0 : getOutputDirIx(prefix, supports))); for (Entry<String, MutableInt> entry : supports.entrySet()) { String itemset = prefix.isEmpty() ? entry.getKey() : prefix + " " + entry.getKey(); mos.write(new Text(itemset), new Text(entry.getValue().intValue() + ""), baseOutputPath); }//from w w w . ja v a 2 s . c om }
From source file:be.uantwerpen.adrem.bigfim.AprioriPhaseReducer.java
License:Apache License
private void writeShortFis(String prefix, Map<String, MutableInt> supports) throws IOException, InterruptedException { StringBuilder builder = new StringBuilder(); if (!prefix.isEmpty()) { builder.append(prefix.replace(" ", valueOf(SEPARATOR))); builder.append(SEPARATOR);//from w w w .j av a2s . c o m } for (Entry<String, MutableInt> entry : supports.entrySet()) { builder.append(entry.getKey()); builder.append(OPENSUP); builder.append(entry.getValue().intValue()); builder.append(CLOSESUP); builder.append(SYMBOL); } mos.write(new Text("" + supports.size()), new Text(builder.substring(0, builder.length() - 1)), baseOutputPathFis); }
From source file:be.uantwerpen.adrem.bigfim.AprioriPhaseReducerTest.java
License:Apache License
private void addToOutput(MultipleOutputs<Text, Text> mos, String prefix, int support) throws IOException, InterruptedException { mos.write(new Text(prefix), new Text("" + support), "base/tg0/trieGroup-0"); mos.write(new Text(prefix), new Text("" + support), "fis"); }
From source file:be.uantwerpen.adrem.bigfim.AprioriPhaseReducerTest.java
License:Apache License
@Test public void reduce_With_Input_Empty_MinSup_1() throws Exception { AprioriPhaseReducer.Context ctx = createMock(Reducer.Context.class); AprioriPhaseReducer reducer = new AprioriPhaseReducer(); setField(reducer, "minSup", 1); EasyMock.replay(ctx);//from w w w . j a v a2s.com reducer.reduce(new Text(""), createList(new String[] {}), ctx); EasyMock.verify(ctx); }
From source file:be.uantwerpen.adrem.bigfim.AprioriPhaseReducerTest.java
License:Apache License
@Test public void reduce_With_Input_MinSup_1() throws Exception { AprioriPhaseReducer.Context ctx = createMock(Reducer.Context.class); AprioriPhaseReducer reducer = createAprioriPhaseReducer(1, createMultipleOutputsOnePrefix(1)); EasyMock.replay(ctx, createMultipleOutputsOnePrefix(1)); reducer.reduce(new Text(""), createReducerInput(), ctx); EasyMock.verify(ctx);//from w w w .j a va2 s. c o m }
From source file:be.uantwerpen.adrem.bigfim.AprioriPhaseReducerTest.java
License:Apache License
@Test public void reduce_With_Input_MinSup_5() throws Exception { AprioriPhaseReducer.Context ctx = createMock(Reducer.Context.class); AprioriPhaseReducer reducer = createAprioriPhaseReducer(5, createMultipleOutputsOnePrefix(5)); EasyMock.replay(ctx);/* w w w. j a va 2s . co m*/ reducer.reduce(new Text(""), createReducerInput(), ctx); EasyMock.verify(ctx); }
From source file:be.uantwerpen.adrem.bigfim.AprioriPhaseReducerTest.java
License:Apache License
private Iterable<Text> createList(String... ts) { List<Text> list = newArrayListWithCapacity(ts.length); for (String t : ts) { list.add(new Text(t)); }/*w w w.j a va 2 s. co m*/ return list; }
From source file:be.uantwerpen.adrem.bigfim.AprioriPhaseReducerTest.java
License:Apache License
@Test public void numberOfPGCounter_One_Group() throws IOException, InterruptedException, NoSuchFieldException, IllegalAccessException { AprioriPhaseReducer.Context ctx = createMock(Reducer.Context.class); Counter pgCounter = createMockCounter(1); EasyMock.expect(ctx.getCounter(COUNTER_GROUPNAME, COUNTER_NRPREFIXGROUPS)).andReturn(pgCounter).anyTimes(); EasyMock.expect(ctx.getCounter(COUNTER_GROUPNAME, COUNTER_NRLARGEPREFIXGROUPS)) .andReturn(new Counters().findCounter(COUNTER_GROUPNAME, COUNTER_NRLARGEPREFIXGROUPS)).anyTimes(); EasyMock.replay(ctx, pgCounter);/*from www . j a va 2 s .c o m*/ AprioriPhaseReducer reducer = createAprioriPhaseReducer(1, createMultipleOutputsOnePrefix(1)); reducer.reduce(new Text(""), createReducerInput(), ctx); reducer.cleanup(ctx); EasyMock.verify(ctx, pgCounter); }