Examples of MongoCompareOp


Examples of org.apache.drill.exec.store.mongo.common.MongoCompareOp

  private MongoScanSpec createMongoScanSpec(String functionName,
      SchemaPath field, Object fieldValue) throws ClassNotFoundException,
      IOException {
    // extract the field name
    String fieldName = field.getAsUnescapedPath();
    MongoCompareOp compareOp = null;
    switch (functionName) {
    case "equal":
      compareOp = MongoCompareOp.EQUAL;
      break;
    case "not_equal":
      compareOp = MongoCompareOp.NOT_EQUAL;
      break;
    case "greater_than_or_equal_to":
      compareOp = MongoCompareOp.GREATER_OR_EQUAL;
      break;
    case "greater_than":
      compareOp = MongoCompareOp.GREATER;
      break;
    case "less_than_or_equal_to":
      compareOp = MongoCompareOp.LESS_OR_EQUAL;
      break;
    case "less_than":
      compareOp = MongoCompareOp.LESS;
      break;
    case "isnull":
    case "isNull":
    case "is null":
      compareOp = MongoCompareOp.IFNULL;
      break;
    case "isnotnull":
    case "isNotNull":
    case "is not null":
      compareOp = MongoCompareOp.IFNOTNULL;
      break;
    }

    if (compareOp != null) {
      BasicDBObject queryFilter = new BasicDBObject();
      if (compareOp == MongoCompareOp.IFNULL) {
        queryFilter.put(fieldName,
            new BasicDBObject(MongoCompareOp.EQUAL.getCompareOp(), null));
      } else if (compareOp == MongoCompareOp.IFNOTNULL) {
        queryFilter.put(fieldName,
            new BasicDBObject(MongoCompareOp.NOT_EQUAL.getCompareOp(), null));
      } else {
        queryFilter.put(fieldName, new BasicDBObject(compareOp.getCompareOp(),
            fieldValue));
      }
      return new MongoScanSpec(groupScan.getScanSpec().getDbName(), groupScan
          .getScanSpec().getCollectionName(), queryFilter);
    }
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.