Java Code Examples for org.apache.pig.pigunit.PigTest#getAlias()

The following examples show how to use org.apache.pig.pigunit.PigTest#getAlias() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PigTests.java    From datafu with Apache License 2.0 6 votes vote down vote up
protected List<Tuple> getLinesForAlias(PigTest test, String alias, boolean logValues) throws IOException, ParseException
{
  Iterator<Tuple> tuplesIterator = test.getAlias(alias);
  List<Tuple> tuples = new ArrayList<Tuple>();
  if (logValues)
  {
    logger.info(String.format("Values for %s: ", alias));
  }
  while (tuplesIterator.hasNext())
  {
    Tuple tuple = tuplesIterator.next();
    if (logValues)
    {
      logger.info(tuple.toString());
    }
    tuples.add(tuple);
  }
  return tuples;
}
 
Example 2
Source File: MarkovPairTests.java    From datafu with Apache License 2.0 6 votes vote down vote up
@Test
public void markovPairDefaultTest() throws Exception
{
  PigTest test = createPigTestFromString(markovPairDefault,
                               "schema=(data: bag {t: tuple(val:int)})");
  
  writeLinesToFile("input", "{(10),(20),(30),(40),(50),(60)}");
  
  String[] expectedOutput = {
      "({((10),(20)),((20),(30)),((30),(40)),((40),(50)),((50),(60))})"
    };
  
  test.runScript();
  
  Iterator<Tuple> actualOutput = test.getAlias("data_out");
  
  assertTuplesMatch(expectedOutput, actualOutput);
}
 
Example 3
Source File: MarkovPairTests.java    From datafu with Apache License 2.0 6 votes vote down vote up
@Test
public void markovPairLookaheadTest() throws Exception
{
  PigTest test = createPigTestFromString(markovPairLookahead, 
                               "schema=(data: bag {t: tuple(val:int)})",
                               "lookahead=3");
  
  writeLinesToFile("input", "{(10),(20),(30),(40),(50)}");
  
  String[] expectedOutput = {
      "({((10),(20)),((10),(30)),((10),(40)),((20),(30)),((20),(40)),((20),(50)),((30),(40)),((30),(50)),((40),(50))})"
    };
  
  test.runScript();
  
  Iterator<Tuple> actualOutput = test.getAlias("data_out");
  
  assertTuplesMatch(expectedOutput, actualOutput);
}
 
Example 4
Source File: MarkovPairTests.java    From datafu with Apache License 2.0 4 votes vote down vote up
@Test
public void markovPairMultipleInput() throws Exception
{    
  PigTest test = createPigTestFromString(markovPairDefault,
                               "schema=(data: bag {t: tuple(val1:int,val2:int)})");
  
  writeLinesToFile("input", "{(10,100),(20,200),(30,300),(40,400),(50,500),(60,600)}");
  
  String[] expectedOutput = {
      "({((10,100),(20,200)),((20,200),(30,300)),((30,300),(40,400)),((40,400),(50,500)),((50,500),(60,600))})"
    };    
  
  
  test.runScript();
  
  Iterator<Tuple> actualOutput = test.getAlias("data_out");
  
  assertTuplesMatch(expectedOutput, actualOutput);
}