MCPcopy Create free account
hub / github.com/apache/pig / getInstance

Method getInstance

src/org/apache/pig/data/TupleFactory.java:47–98  ·  view source on GitHub ↗

Get a reference to the singleton factory. @return The TupleFactory to use to construct tuples.

()

Source from the content-addressed store, hash-verified

45 * @return The TupleFactory to use to construct tuples.
46 */
47 public static TupleFactory getInstance() {
48 if (gSelf == null) {
49 String factoryName =
50 System.getProperty("pig.data.tuple.factory.name");
51 String factoryJar =
52 System.getProperty("pig.data.tuple.factory.jar");
53 if (factoryName != null && factoryJar != null) {
54 try {
55 URL[] urls = new URL[1];
56 urls[0] = new URL(factoryJar);
57 ClassLoader loader = new URLClassLoader(urls,
58 TupleFactory.class.getClassLoader());
59 Class c = Class.forName(factoryName, true, loader);
60 Object o = c.newInstance();
61 if (!(o instanceof TupleFactory)) {
62 throw new RuntimeException("Provided factory " +
63 factoryName + " does not extend TupleFactory!");
64 }
65 gSelf = (TupleFactory)o;
66 } catch (Exception e) {
67 if (e instanceof RuntimeException) {
68 // We just threw this
69 RuntimeException re = (RuntimeException)e;
70 throw re;
71 }
72 throw new RuntimeException("Unable to instantiate "
73 + "tuple factory " + factoryName, e);
74 }
75 } else if (factoryName != null) {
76 try {
77 Class c = Class.forName(factoryName);
78 Object o = c.newInstance();
79 if (!(o instanceof TupleFactory)) {
80 throw new RuntimeException("Provided factory " +
81 factoryName + " does not extend TupleFactory!");
82 }
83 gSelf = (TupleFactory)o;
84 } catch (Exception e) {
85 if (e instanceof RuntimeException) {
86 // We just threw this
87 RuntimeException re = (RuntimeException)e;
88 throw re;
89 }
90 throw new RuntimeException("Unable to instantiate "
91 + "tuple factory " + factoryName, e);
92 }
93 } else {
94 gSelf = new BinSedesTupleFactory();
95 }
96 }
97 return gSelf;
98 }
99
100 /**
101 * Create an empty tuple. This should be used as infrequently as

Callers 15

testSeekMethod · 0.95
TestIsDoubleClass · 0.95
TestIsNumericClass · 0.95
TestIsLongClass · 0.95
TestIsIntClass · 0.95
TestIsFloatClass · 0.95
testMinMethod · 0.95
testMaxMethod · 0.95
testMaxComplexKeyMethod · 0.95
testMinComplexKeyMethod · 0.95
testMinStringeyMethod · 0.95

Calls 2

getPropertyMethod · 0.80
getClassLoaderMethod · 0.80

Tested by 15

testSeekMethod · 0.76
testMinMethod · 0.76
testMaxMethod · 0.76
testMaxComplexKeyMethod · 0.76
testMinComplexKeyMethod · 0.76
testMinStringeyMethod · 0.76
testBiggerBagMethod · 0.76
testBiggerTupleMethod · 0.76
testMaxAccumulatedMethod · 0.76
testDiffDateMethod · 0.76
testParseDateTime_UTCMethod · 0.76