You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pig.apache.org by da...@apache.org on 2014/02/05 02:26:20 UTC

svn commit: r1564603 - /pig/trunk/src/org/apache/pig/OverwritableStoreFunc.java

Author: daijy
Date: Wed Feb  5 01:26:19 2014
New Revision: 1564603

URL: http://svn.apache.org/r1564603
Log:
PIG-259: allow store to overwrite existing directroy (PIG-259.9.patch)

Added:
    pig/trunk/src/org/apache/pig/OverwritableStoreFunc.java

Added: pig/trunk/src/org/apache/pig/OverwritableStoreFunc.java
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/OverwritableStoreFunc.java?rev=1564603&view=auto
==============================================================================
--- pig/trunk/src/org/apache/pig/OverwritableStoreFunc.java (added)
+++ pig/trunk/src/org/apache/pig/OverwritableStoreFunc.java Wed Feb  5 01:26:19 2014
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pig;
+
+import java.io.IOException;
+
+import org.apache.hadoop.mapreduce.Job;
+import org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.PigOutputFormat;
+import org.apache.pig.backend.hadoop.executionengine.physicalLayer.relationalOperators.POStore;
+import org.apache.pig.newplan.logical.rules.InputOutputFileValidator;
+
+/**
+ * A {@link StoreFunc} should implement this interface to enable overwriting its
+ * store/output location if it already exists.
+ */
+public interface OverwritableStoreFunc {
+    /**
+     * This method is called by the Pig runtime to determine whether to ignore output validation problems
+     * (see {@link PigOutputFormat#checkOutputSpecs} and {@link InputOutputFileValidator#validate}) and to delete the existing output.
+     * @return whether to overwrite the store/output location of this {@link StoreFunc}.
+     */
+    public boolean shouldOverwrite();
+
+    /**
+     * This method is called to cleanup the store/output location of this {@link StoreFunc}.
+     * 
+     * @param store The {@link POStore} object to get info about the store
+     * operator for this store function.
+     * @param job The {@link Job} object to get job related information.
+     * @throws IOException if an exception occurs during the cleanup.
+     */    
+    public void cleanupOutput(POStore store, Job job) throws IOException;
+}