Package org.apache.pig.backend

Examples of org.apache.pig.backend.BackendException


  protected void setKeyValueTypes(Class<?> keyClass, Class<?> valueClass) throws BackendException {
    this.keyType |= inferPigDataType(keyClass);
    this.valType |= inferPigDataType(valueClass);
    if (keyType == DataType.ERROR) {
      LOG.warn("Unable to translate key "+key.getClass()+" to a Pig datatype");
      throw new BackendException("Unable to translate "+key.getClass()+" to a Pig datatype");
    }
    if (valType == DataType.ERROR) {
      LOG.warn("Unable to translate value "+value.getClass()+" to a Pig datatype");
      throw new BackendException("Unable to translate "+value.getClass()+" to a Pig datatype");
    }

  }
View Full Code Here


  protected void setKeyType(Class<?> keyClass) throws BackendException {
    this.keyType |= inferPigDataType(keyClass);
    if (keyType == DataType.ERROR) {
      LOG.warn("Unable to translate key "+key.getClass()+" to a Pig datatype");
      throw new BackendException("Unable to translate "+key.getClass()+" to a Pig datatype");
    }
  }
View Full Code Here

 
  protected void setValueType(Class<?> valueClass) throws BackendException {
    this.valType |= inferPigDataType(valueClass);
    if (keyType == DataType.ERROR) {
      LOG.warn("Unable to translate key "+key.getClass()+" to a Pig datatype");
      throw new BackendException("Unable to translate "+key.getClass()+" to a Pig datatype");
    }
  }
View Full Code Here

      outgoing.add(getJavaObj(tuple.get(i++), fSchema));
    }
    try {
      writer.write(null, new DefaultHowlRecord(outgoing));
    } catch (InterruptedException e) {
      throw new BackendException("Error while writing tuple: "+tuple, PigHowlUtil.PIG_EXCEPTION_CODE, e);
    }
  }
View Full Code Here

      outgoing.add(getJavaObj(tuple.get(i++), fSchema));
    }
    try {
      writer.write(null, new DefaultHCatRecord(outgoing));
    } catch (InterruptedException e) {
      throw new BackendException("Error while writing tuple: " + tuple, PigHCatUtil.PIG_EXCEPTION_CODE, e);
    }
  }
View Full Code Here

      case SMALLINT:
        if (pigObj == null) {
          return null;
        }
        if ((Integer) pigObj < Short.MIN_VALUE || (Integer) pigObj > Short.MAX_VALUE) {
          throw new BackendException("Value " + pigObj + " is outside the bounds of column " +
            hcatFS.getName() + " with type " + hcatFS.getType(), PigHCatUtil.PIG_EXCEPTION_CODE);
        }
        return ((Integer) pigObj).shortValue();
      case TINYINT:
        if (pigObj == null) {
          return null;
        }
        if ((Integer) pigObj < Byte.MIN_VALUE || (Integer) pigObj > Byte.MAX_VALUE) {
          throw new BackendException("Value " + pigObj + " is outside the bounds of column " +
            hcatFS.getName() + " with type " + hcatFS.getType(), PigHCatUtil.PIG_EXCEPTION_CODE);
        }
        return ((Integer) pigObj).byteValue();
      case BOOLEAN:
        if (pigObj == null) {
          LOG.debug( "HCatBaseStorer.getJavaObj(BOOLEAN): obj null, bailing early" );
          return null;
        }

        if( pigObj instanceof String ) {
          if( ((String)pigObj).trim().compareTo("0") == 0 ) {
            return Boolean.FALSE;
          }
          if( ((String)pigObj).trim().compareTo("1") == 0 ) {
            return Boolean.TRUE;
          }

          throw new BackendException(
            "Unexpected type " + type + " for value " + pigObj
            + (pigObj == null ? "" : " of class "
            + pigObj.getClass().getName()), PigHCatUtil.PIG_EXCEPTION_CODE);
        }

        return Boolean.parseBoolean( pigObj.toString() );
      default:
        throw new BackendException("Unexpected type " + type + " for value " + pigObj
          + (pigObj == null ? "" : " of class "
          + pigObj.getClass().getName()), PigHCatUtil.PIG_EXCEPTION_CODE);
      }
    } catch (BackendException e) {
      // provide the path to the field in the error message
      throw new BackendException(
        (hcatFS.getName() == null ? " " : hcatFS.getName() + ".") + e.getMessage(),
        e.getCause() == null ? e : e.getCause());
    }
  }
View Full Code Here

      outgoing.add(getJavaObj(tuple.get(i++), fSchema));
    }
    try {
      writer.write(null, new DefaultHCatRecord(outgoing));
    } catch (InterruptedException e) {
      throw new BackendException("Error while writing tuple: "+tuple, PigHCatUtil.PIG_EXCEPTION_CODE, e);
    }
  }
View Full Code Here

            outgoing.add(getJavaObj(tuple.get(i++), fSchema));
        }
        try {
            writer.write(null, new DefaultHCatRecord(outgoing));
        } catch (InterruptedException e) {
            throw new BackendException("Error while writing tuple: " + tuple, PigHCatUtil.PIG_EXCEPTION_CODE, e);
        }
    }
View Full Code Here

            case SMALLINT:
                if (pigObj == null) {
                    return null;
                }
                if ((Integer) pigObj < Short.MIN_VALUE || (Integer) pigObj > Short.MAX_VALUE) {
                    throw new BackendException("Value " + pigObj + " is outside the bounds of column " +
                        hcatFS.getName() + " with type " + hcatFS.getType(), PigHCatUtil.PIG_EXCEPTION_CODE);
                }
                return ((Integer) pigObj).shortValue();
            case TINYINT:
                if (pigObj == null) {
                    return null;
                }
                if ((Integer) pigObj < Byte.MIN_VALUE || (Integer) pigObj > Byte.MAX_VALUE) {
                    throw new BackendException("Value " + pigObj + " is outside the bounds of column " +
                        hcatFS.getName() + " with type " + hcatFS.getType(), PigHCatUtil.PIG_EXCEPTION_CODE);
                }
                return ((Integer) pigObj).byteValue();
            case BOOLEAN:
                // would not pass schema validation anyway
                throw new BackendException("Incompatible type " + type + " found in hcat table schema: " + hcatFS, PigHCatUtil.PIG_EXCEPTION_CODE);
            default:
                throw new BackendException("Unexpected type " + type + " for value " + pigObj + (pigObj == null ? "" : " of class " + pigObj.getClass().getName()), PigHCatUtil.PIG_EXCEPTION_CODE);
            }
        } catch (BackendException e) {
            // provide the path to the field in the error message
            throw new BackendException(
                (hcatFS.getName() == null ? " " : hcatFS.getName() + ".") + e.getMessage(),
                e.getCause() == null ? e : e.getCause());
        }
    }
View Full Code Here

    public void kill() throws BackendException {
        if (runningJob != null) {
            try {
                runningJob.killJob();
            } catch (Exception e) {
                throw new BackendException(e);
            }
        }
        destroy();
    }
View Full Code Here

TOP

Related Classes of org.apache.pig.backend.BackendException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.