Package dovetaildb.api

Examples of dovetaildb.api.ApiException


  }

  @Override
  public synchronized long commit(long fromTxnId, Map<String, ApiBuffer> batch) {
    if (subService.getHighestCompletedTxnId()+spaceStart+1 >= spaceEnd) {
      throw new ApiException("TxnSpaceFull", "No more transactions are allowed in the current space");
    }
    return subService.commit(fromTxnId-spaceStart, batch) + spaceStart;
  }
View Full Code Here


      if (factory != null) return factory;
      Class<? extends ScoreComponentFactory> clas;
      try {
        clas = Class.forName(opName).asSubclass(ScoreComponentFactory.class);
      } catch (ClassNotFoundException e) {
        throw new ApiException("UnknownScorerFactory", "This scorer factory class was not found: \""+opName+"\"");
      }
      try {
        factory = clas.newInstance();
      } catch (InstantiationException e) {
        throw new ApiException("InvalidScorerFactory", "This scorer factory class could not be instanciated: \""+opName+"\"", e);
      } catch (IllegalAccessException e) {
        throw new ApiException("InvalidScorerFactory", "This scorer factory class could not be instanciated: \""+opName+"\"", e);
      }
      directory.put(opName, factory);
    }
    return factory;
  }
View Full Code Here

    double maxScore = Double.POSITIVE_INFINITY;
    String secondaryField = "id";
    Object secondaryValue = null;
    if (bookmark != null) {
      String[] bookmarkParts = bookmark.split(",");
      if (bookmarkParts.length != 3) throw new ApiException("InvalidBookmark","Bookmark must have three elements, seperated by commas, instead we found: \""+bookmark+"\"");
      String maxScoreString = bookmarkParts[0];
      if (maxScoreString.length() > 0) {
        try {
          maxScore = Double.parseDouble(maxScoreString);
        } catch(NumberFormatException e) {
          throw new ApiException("InvalidBookmark","Uparsable max score in \""+bookmark+"\"");
        }
      }
      secondaryField = bookmarkParts[1];
      try {
        secondaryValue = Util.jsonDecode(bookmarkParts[2]);
      } catch(Util.JsonParseRuntimeException e) {
        throw new ApiException("InvalidBookmark", "Invalid compare JSON value in bookmark: "+e.getMessage());
      }
    }
    Object scorePattern = options.get("score");
    Iter iter = subService.query(bag, txnId, query, options);
    if (scorePattern == null) {
View Full Code Here

    @Override
    public LeafScoreComponent make(List<Object> scoringOperation) {
      NumericScoreComponent component = new NumericScoreComponent();
      switch(scoringOperation.size()) {
      default:
        throw new ApiException("InvalidScorer", "Invalid number of parameters in this scorer: "+scoringOperation);
      case 4:
        component.ub = ((Number)scoringOperation.get(3)).doubleValue();
      case 3:
        component.lb = ((Number)scoringOperation.get(2)).doubleValue();
      case 2:
View Full Code Here

    public LeafScoreComponent make(List<Object> scoringOperation) {
      List<Object> points = (List<Object>) scoringOperation.get(1);
      double defaultScore = Double.NaN;
      switch(scoringOperation.size()) {
      default:
        throw new ApiException("InvalidScorer", "Invalid number of parameters in this scorer: "+scoringOperation);
      case 3:
        Number defaultNumber = (Number)scoringOperation.get(2);
        if (defaultNumber != null) {
          defaultScore = ((Number)scoringOperation.get(2)).doubleValue();
        }
View Full Code Here

      values = new Object[count];
      scores = new double[count];
      int i=0;
      for(Object pointObj : points) {
        if (pointObj == null || !(pointObj instanceof List))
          throw new ApiException("InvalidScoringPoint", "Invalid score point: \""+pointObj+"\"; must instead be a list of size 2, containing X and Y coordinates");
        List<Object> pair = (List<Object>)pointObj;
        Object valObj = pair.get(0);
        Object scoreObj = pair.get(1);
        if (scoreObj == null || !(scoreObj instanceof Number))
          throw new ApiException("InvalidScoringPoint", "Invalid score point: \""+pair+"\"; Y coordinate must be a number");
        values[i] = valObj;
        DbResultAtom atom = new DbResultAtom(values[i]);
        char type = atom.type;
        if (type == DbServiceUtil.TYPE_CHAR_MAP || type == DbServiceUtil.TYPE_CHAR_LIST)
          throw new ApiException("InvalidScoringPoint", "Invalid score point: \""+pair+"\"; X coordinate must be an atomic type");
        if (i > 0) {
          if (atom.compareTo(values[i-1]) < 0) {
            throw new ApiException("InvalidScoringPoint", "X coordinates must be in increasing order, but '"+values[i-1]+"' > '"+values[i]+"'");
          }
        }
        double score = ((Number)scoreObj).doubleValue();
        scores[i] = score;
        if (score < lb) lb = score;
View Full Code Here

  public static class LinearlyInterpolatedScoreComponent extends LookupTableScoreComponent {
    public LinearlyInterpolatedScoreComponent(List<Object> points, double defaultScore) {
      super(points, defaultScore);
      for(Object val : values) {
        if (DbServiceUtil.typeOfObject(val) != DbServiceUtil.TYPE_CHAR_NUMBER)
          throw new ApiException("InvalidScoringPoint", "Numeric X coordinate required; found this: '"+val+"'");
      }
    }
View Full Code Here

    @Override
    public ScoreComponent make(List<Object> scoringOperation, Bytes prefix) {
      MultipliedScoreComponent component = new MultipliedScoreComponent();
      switch(scoringOperation.size()) {
      default:
        throw new ApiException("InvalidScorer", "Invalid number of parameters in this scorer: "+scoringOperation);
      case 3:
        component.multiplier = ((Number)scoringOperation.get(1)).doubleValue();
        if (component.multiplier < 0.0)
          throw new ApiException("InvalidScorer", "Only positive multipliers are allowed: "+scoringOperation);
      }
      component.inner = parseScorePattern(scoringOperation.get(2), prefix);
      return component;
    }
View Full Code Here

    @Override
    public ScoreComponent make(List<Object> scoringOperation, Bytes prefix) {
      ReverseScoreComponent component = new ReverseScoreComponent();
      switch(scoringOperation.size()) {
      default:
        throw new ApiException("InvalidScorer", "Invalid number of parameters in this scorer: "+scoringOperation);
      case 2:
      }
      component.inner = parseScorePattern(scoringOperation.get(1), prefix);
      return component;
    }
View Full Code Here

    protected boolean isOperationLead(String op) {
      return true;
    }
    @Override
    public void handleAtomic(Bytes prefix, Bytes suffix, Object val) {
      throw new ApiException("InvalidScorePattern", "Atomic value not allowed in scoring pattern: \""+val+"\"");
    }
View Full Code Here

TOP

Related Classes of dovetaildb.api.ApiException

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.