Skip to content
This repository has been archived by the owner on Feb 21, 2019. It is now read-only.

Commit

Permalink
It works. Something about "static" subclasses was necessary.
Browse files Browse the repository at this point in the history
  • Loading branch information
bsmedberg committed Aug 14, 2012
1 parent 75bb999 commit f066071
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
31 changes: 23 additions & 8 deletions src/main/java/com/mozilla/pig/eval/Example.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@
* of that bag. It is intended for use when grouping a set of results and * of that bag. It is intended for use when grouping a set of results and
* you want a single example item in the final result set. * you want a single example item in the final result set.
*/ */
public final class Example extends EvalFunc<Tuple> implements Algebraic { public final class Example extends EvalFunc<Tuple> implements Algebraic

{
@Override static private Tuple realexec(Tuple input) throws IOException
public Tuple exec(Tuple input) throws IOException
{ {
DataBag bag = (DataBag) input.get(0); DataBag bag = (DataBag) input.get(0);
Iterator<Tuple> it = bag.iterator(); Iterator<Tuple> it = bag.iterator();
Expand All @@ -52,7 +51,23 @@ public Tuple exec(Tuple input) throws IOException
} }


@Override @Override
public Schema outputSchema(Schema input) { public Tuple exec(Tuple input) throws IOException
{
return realexec(input);
}

static public class Sub extends EvalFunc<Tuple>
{
@Override
public Tuple exec(Tuple input) throws IOException
{
return realexec(input);
}
}

@Override
public Schema outputSchema(Schema input)
{
try { try {
if (input.size() != 1) { if (input.size() != 1) {
return null; return null;
Expand All @@ -73,7 +88,7 @@ public Schema outputSchema(Schema input) {


// We can use the same class in all cases since the input schema is the // We can use the same class in all cases since the input schema is the
// same. // same.
public String getInitial() { return this.getClass().getName(); } public String getInitial() { return Sub.class.getName(); }
public String getIntermed() { return this.getClass().getName(); } public String getIntermed() { return Sub.class.getName(); }
public String getFinal() { return this.getClass().getName(); } public String getFinal() { return Sub.class.getName(); }
} }
6 changes: 1 addition & 5 deletions src/test/java/com/mozilla/pig/eval/ExampleTest.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ public class ExampleTest {
private BagFactory bagFactory = BagFactory.getInstance(); private BagFactory bagFactory = BagFactory.getInstance();


@Test @Test
public void testConstructor() throws IOException { public void testInstantiate() throws IOException {
Example e = new Example(); Example e = new Example();
} }

@Test
public void testExec2() throws IOException {
}
} }

0 comments on commit f066071

Please sign in to comment.