Examples of RecordException


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

  }

  @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

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

    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

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

          }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

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

     
      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

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

  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

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

//        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

Examples of org.lilyproject.repository.api.RecordException

    }

    @Override
    public Record cloneRecord(IdentityRecordStack parentRecords) throws RecordException {
        if (parentRecords.contains(this)) {
            throw new RecordException("A record may not be nested in itself: " + id);
        }

        RecordImpl record = new RecordImpl();
        record.id = id;
        record.version = version;
View Full Code Here

Examples of org.lilyproject.repository.api.RecordException

    private Object tryCloneValue(final IdentityRecordStack parentRecords, final Entry<QName, Object> entry) throws RecordException {
        try {
            return cloneValue(entry.getValue(), parentRecords);
        } catch (CloneNotSupportedException e) {
            throw new RecordException("Failed to clone record", e);
        }
    }
View Full Code Here

Examples of org.lilyproject.repository.api.RecordException

        QName recordTypeName = getRecordTypeName();
        if (recordTypeName != null) {
            return new QName(recordTypeName.getNamespace(), name);
        }

        throw new RecordException("Namespace could not be resolved for name '" + name +
            "' since no default namespace was given and no record type is set.");
    }
View Full Code Here

Examples of org.lilyproject.repository.api.RecordException

        if (record.getId() == null) {
            // While we could generate an ID ourselves in this case, this would defeat partly the purpose of
            // createOrUpdate, which is that clients would be able to retry the operation (in case of IO exceptions)
            // without having to worry that more than one record might be created.
            throw new RecordException("Record ID is mandatory when using create-or-update.");
        }

        byte[] rowId = record.getId().toBytes();
        Get get = new Get(rowId);
        get.addColumn(RecordCf.DATA.bytes, RecordColumn.DELETED.bytes);

        int attempts;

        for (attempts = 0; attempts < 3; attempts++) {
            Result result;
            try {
                result = recordTable.get(get);
            } catch (IOException e) {
                throw new RecordException("Error reading record row for record id " + record.getId(), e);
            }

            byte[] deleted = recdec.getLatest(result, RecordCf.DATA.bytes, RecordColumn.DELETED.bytes);
            if ((deleted == null) || (Bytes.toBoolean(deleted))) {
                // do the create
                try {
                    return create(record);
                } catch (RecordExistsException e) {
                    // someone created the record since we checked, we will try again
                }
            } else {
                // do the update
                try {
                    record = update(record, false, useLatestRecordType);
                    return record;
                } catch (RecordNotFoundException e) {
                    // some deleted the record since we checked, we will try again
                }
            }
        }

        throw new RecordException("Create-or-update failed after " + attempts +
                " attempts, toggling between create and update mode.");
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.