Package org.apache.drill.exec.ref.exceptions

Examples of org.apache.drill.exec.ref.exceptions.RecordException


public abstract class BaseMapValue extends BaseDataValue implements ContainerValue,
    Iterable<Map.Entry<CharSequence, DataValue>> {

  @Override
  public void addValue(PathSegment segment, DataValue v) {
    if(v == null) throw new RecordException("You attempted to add a null value to a map.", null);
    if (segment.isArray())
      throw new RecordException(
          "You're attempted to save something at a particular array location while the location of that setting was a Map.", null);

    CharSequence name = segment.getNameSegment().getPath();
    DataValue current = getByNameNoNulls(name);
    if (!segment.isLastPath() && current != DataValue.NULL_VALUE) {
View Full Code Here


  }

  @Override
  public void removeValue(PathSegment segment) {
    if (segment.isArray())
      throw new RecordException(
          "You're attempted to remove something at a particular array location while the location of that setting was a Map.", null);

    CharSequence name = segment.getNameSegment().getPath();
    DataValue current = getByNameNoNulls(name);
    if (!segment.isLastPath() && current != DataValue.NULL_VALUE) {
View Full Code Here

    case SKIP:
      return oldValue;
    case REPLACE:
      return newValue;
    case FAIL:
      throw new RecordException("Failure while doing query.  The destination specified already contains a value and no collision behavior was provdied.", null);
    case OBJECTIFY:
      SimpleMapValue n = new SimpleMapValue();
      n.setByName("old", oldValue);
      n.setByName("new",  newValue);
      return n;
    case ARRAYIFY:
      SimpleArrayValue a = new SimpleArrayValue();
      a.addToArray(0, oldValue);
      a.addToArray(1, newValue);
      return a;
    case MERGE_OVERRIDE:
      MajorType oldT = oldValue.getDataType();
      MajorType newT = newValue.getDataType();
      if(oldT.getMinorType() == MinorType.REPEATMAP && newT.getMinorType() == MinorType.REPEATMAP){
        oldValue.getAsContainer().getAsMap().merge(newValue.getAsContainer().getAsMap());
        return oldValue;
      }else if(oldT.getMode() == DataMode.REPEATED && newT.getMode() == DataMode.REPEATED){
        logger.debug("Merging two arrays. {} and {}", oldValue, newValue);
        oldValue.getAsContainer().getAsArray().append(newValue.getAsContainer().getAsArray());
        return oldValue;
      }else if(oldT.getMode() == DataMode.REPEATED || newT.getMode() == DataMode.REPEATED || oldT.getMinorType() == MinorType.REPEATMAP || newT.getMinorType() == MinorType.REPEATMAP){
        throw new RecordException(String.format("Failure while doing query.  You requested a merge of values that were incompatibile.  Examples include merging an array and a map or merging a map/array with a scalar.  Merge Types were %s and %s.", oldT, newT), null);
      }else{
        // scalar type, just override the value.
        return newValue;
      }
    default:
View Full Code Here

          }else{
            l *= n.getAsLong();
          }
         
        }else{
          throw new RecordException(String.format("Unable to multiply a value of  %s.", v), null);
        }
      }
     
      NumericValue out = null;
      if(isFloating){
View Full Code Here

     
      if(isComparable(a, b)){
        int i = ((ComparableValue)a).compareTo(b);
        return new BooleanScalar(valid( i));
      }else{
        throw new RecordException(String.format("Values cannot be compared.  A %s cannot be compared to a %s.", a, b), null);
      }
    }
View Full Code Here

  private HashMap<CharSequence, DataValue> map = new HashMap<CharSequence, DataValue>();

 
  @Override
  public void setByName(CharSequence name, DataValue v) {
    if( v== null) throw new RecordException(String.format("You attempted to write a null value with the map key of %s.", name), null);
    map.put(name, v);
  }
View Full Code Here

//        logger.debug("Record found, returning new json record.");
        record.setClearAndSetRoot(rootPath, convert(n));
        // todo, add schema checking here.
        return NextOutcome.INCREMENTED_SCHEMA_CHANGED;
      } catch (IOException e) {
        throw new RecordException("Failure while reading record", null, e);
      }
    }
View Full Code Here

TOP

Related Classes of org.apache.drill.exec.ref.exceptions.RecordException

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.