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

Method getInstance

src/org/apache/pig/data/BagFactory.java:52–85  ·  view source on GitHub ↗

Get a reference to the singleton factory. @return BagFactory

()

Source from the content-addressed store, hash-verified

50 * @return BagFactory
51 */
52 public static BagFactory getInstance() {
53 if (gSelf == null) {
54 String factoryName =
55 System.getProperty("pig.data.bag.factory.name");
56 String factoryJar =
57 System.getProperty("pig.data.bag.factory.jar");
58 if (factoryName != null && factoryJar != null) {
59 try {
60 URL[] urls = new URL[1];
61 urls[0] = new URL(factoryJar);
62 ClassLoader loader = new URLClassLoader(urls,
63 BagFactory.class.getClassLoader());
64 Class c = Class.forName(factoryName, true, loader);
65 Object o = c.newInstance();
66 if (!(o instanceof BagFactory)) {
67 throw new RuntimeException("Provided factory " +
68 factoryName + " does not extend BagFactory!");
69 }
70 gSelf = (BagFactory)o;
71 } catch (Exception e) {
72 if (e instanceof RuntimeException) {
73 // We just threw this
74 RuntimeException re = (RuntimeException)e;
75 throw re;
76 }
77 throw new RuntimeException("Unable to instantiate "
78 + "bag factory " + factoryName, e);
79 }
80 } else {
81 gSelf = new DefaultBagFactory();
82 }
83 }
84 return gSelf;
85 }
86
87 /**
88 * Get a default (unordered, not distinct) data bag.

Callers 15

testMinMethod · 0.95
testMaxMethod · 0.95
testMaxComplexKeyMethod · 0.95
testMinComplexKeyMethod · 0.95
testMinStringeyMethod · 0.95
testBiggerBagMethod · 0.95
testBiggerTupleMethod · 0.95
testBadInputMethod · 0.95
testBagFuncMethod · 0.95
testCountNoWindowMethod · 0.95

Calls 2

getPropertyMethod · 0.80
getClassLoaderMethod · 0.80

Tested by 15

testMinMethod · 0.76
testMaxMethod · 0.76
testMaxComplexKeyMethod · 0.76
testMinComplexKeyMethod · 0.76
testMinStringeyMethod · 0.76
testBiggerBagMethod · 0.76
testBiggerTupleMethod · 0.76
testBadInputMethod · 0.76
testBagFuncMethod · 0.76
testCountNoWindowMethod · 0.76