2 * Copyright (c) 2007 Yahoo! Inc. All rights reserved.
3 * See accompanying LICENSE file.
5 package com
.yahoo
.pig
.data
;
8 import java
.io
.IOException
;
10 public class BagFactory
{
12 private File tmpdir
= null;
13 private static BagFactory instance
= new BagFactory();
15 public static BagFactory
getInstance() {
19 private BagFactory() {
22 public static void init(File tmpdir
) {
23 instance
.setTmpDir(tmpdir
);
26 private void setTmpDir(File tmpdir
) {
31 // Get BigBag or Bag, depending on whether the temp directory has been set up
32 public DataBag
getNewBag() throws IOException
{
33 if (tmpdir
== null) return new DataBag();
34 else return getNewBigBag();
37 // Need a Big Bag, dammit!
38 public BigDataBag
getNewBigBag() throws IOException
{
39 if (tmpdir
== null) throw new IOException("No temp directory given for BigDataBag.");
40 else return new BigDataBag(tmpdir
);