23
23
import ml .combust .mleap .runtime .frame .DefaultLeapFrame ;
24
24
import ml .combust .mleap .runtime .frame .Row ;
25
25
import ml .combust .mleap .runtime .frame .Transformer ;
26
+ import ml .combust .mleap .runtime .javadsl .LeapFrameSupport ;
26
27
import org .apache .commons .lang3 .StringUtils ;
27
28
import scala .collection .JavaConverters ;
28
- import scala .collection .Seq ;
29
29
30
30
/**
31
31
* Utility class for dealing with Scala to Java conversion related issues. These functionalities are moved to this
32
32
* class so that they can be easily mocked out by PowerMockito.mockStatic while testing the actual classes.
33
33
*/
34
34
public class ScalaUtils {
35
35
36
+ private final static LeapFrameSupport leapFrameSupport = new LeapFrameSupport ();
37
+
36
38
/**
37
39
* Invokes MLeap transformer object with DefaultLeapFrame and returns DefaultLeapFrame from MLeap helper Try Monad
38
40
*
@@ -53,9 +55,7 @@ public static DefaultLeapFrame transformLeapFrame(final Transformer transformer,
53
55
* @return the DefaultLeapFrame in helper
54
56
*/
55
57
public static DefaultLeapFrame selectFromLeapFrame (final DefaultLeapFrame leapFrame , final String key ) {
56
- final Seq <String > predictionColumnSelectionArgs = JavaConverters
57
- .asScalaIteratorConverter (Collections .singletonList (key ).iterator ()).asScala ().toSeq ();
58
- return leapFrame .select (predictionColumnSelectionArgs ).get ();
58
+ return leapFrameSupport .select (leapFrame , Collections .singletonList (key ));
59
59
}
60
60
61
61
/**
@@ -66,8 +66,7 @@ public static DefaultLeapFrame selectFromLeapFrame(final DefaultLeapFrame leapFr
66
66
* @return ArrayRow which can be used to retrieve the original output
67
67
*/
68
68
public static ArrayRow getOutputArrayRow (final DefaultLeapFrame leapFrame ) {
69
- final Iterator <Row > rowIterator = JavaConverters .asJavaIterableConverter (leapFrame .collect ()).asJava ()
70
- .iterator ();
69
+ final Iterator <Row > rowIterator = leapFrameSupport .collect (leapFrame ).iterator ();
71
70
// SageMaker input structure only allows to call MLeap transformer for single data point
72
71
return (ArrayRow ) (rowIterator .next ());
73
72
}
0 commit comments