src/main/java/org/apache/hadoop/hdfs/server/namenode/analytics/QueryChecker.java
public static void isValidQuery(
      String setType, String[] filters, String type, String sum, String[] filterOps, String find)
      throws MalformedURLException {
    errorMessages.clear();

    final EnumSet validSumOperands = sumMap.get(setType);
    final EnumSet validFilterOperands = filterMap.get(setType);
    final EnumSet validTypeOperands = typeMap.get(setType);
    final EnumSet validFindOperands = findMap.get(setType);

    Pair<Boolean, Pair<String, String>> typeCheck =
        isValidOperand(type, null, validTypeOperands, Operand.type.toString());
    if (!typeCheck.getFirst()) {
      errorMessages.add(
          "Please check /types. Your histogram type: "
              + typeCheck.getSecond().getFirst()
              + " is not valid for set type: "
              + setType
              + ".");
    }

    Pair<Boolean, Pair<String, String>> sumCheck =
        isValidOperand(sum, null, validSumOperands, Operand.sum.toString());
    if (!sumCheck.getFirst()) {
      errorMessages.add(
          "Please check /sums. Your sum type: "
              + sumCheck.getSecond().getFirst()
              + " is not valid for set type: "
              + setType
              + ".");
    }

    Pair<Boolean, Pair<String, String>> filterCheck =
        isValidOperand(filters, filterOps, validFilterOperands, Operand.filter.toString());
    if (!filterCheck.getFirst()) {
      Pair<String, String> result = filterCheck.getSecond();
      if (result.getFirst().length() > 0) {
        errorMessages.add(
            "Please check /filters. Your filter type: "
                + result.getFirst()
                + " is not valid for set type: "
                + setType
                + ".");
      }
      if (result.getSecond().length() > 0) {
        errorMessages.add("Please check /filterOps. " + "\n" + result.getSecond());
      }
    }

    Pair<Boolean, Pair<String, String>> findCheck =
        isValidOperand(find, null, validFindOperands, Operand.find.toString());
    if (!findCheck.getFirst()) {
      errorMessages.add(
          "Please check /finds. Your find type: "
              + findCheck.getSecond().getFirst()
              + " is not valid for set type: "
              + setType
              + ".");
    }

    if (!errorMessages.isEmpty()) {
      throw new MalformedURLException(getMessageText(errorMessages));
    }
  }
/**
   * Determines whether or not this query should work on NNA.
   *
   * @param setType inode type, files or dirs
   * @param filters the set of filters to pass
   * @param type the histogram type to group by
   * @param sum the summation type
   * @param filterOps the set of filter operations
   * @param find find a min, max, or avg
   * @throws MalformedURLException if it fails to pass the QueryChecker
   */
Determines whether or not this query should work on NNA.
Determines whether or not this query should work on NNA .
public static void isValidQuery(
      String setType, String[] filters, String type, String sum, String[] filterOps, String find)
      throws MalformedURLException {
    errorMessages.clear();
    final EnumSet validSumOperands = sumMap.get(setType);
    final EnumSet validFilterOperands = filterMap.get(setType);
    final EnumSet validTypeOperands = typeMap.get(setType);
    final EnumSet validFindOperands = findMap.get(setType);
    Pair<Boolean, Pair<String, String>> typeCheck =
        isValidOperand(type, null, validTypeOperands, Operand.type.toString());
    if (!typeCheck.getFirst()) {
      errorMessages.add(
          "Please check /types. Your histogram type: "
              + typeCheck.getSecond().getFirst()
              + " is not valid for set type: "
              + setType
              + ".");
    }
    Pair<Boolean, Pair<String, String>> sumCheck =
        isValidOperand(sum, null, validSumOperands, Operand.sum.toString());
    if (!sumCheck.getFirst()) {
      errorMessages.add(
          "Please check /sums. Your sum type: "
              + sumCheck.getSecond().getFirst()
              + " is not valid for set type: "
              + setType
              + ".");
    }
    Pair<Boolean, Pair<String, String>> filterCheck =
        isValidOperand(filters, filterOps, validFilterOperands, Operand.filter.toString());
    if (!filterCheck.getFirst()) {
      Pair<String, String> result = filterCheck.getSecond();
      if (result.getFirst().length() > 0) {
        errorMessages.add(
            "Please check /filters. Your filter type: "
                + result.getFirst()
                + " is not valid for set type: "
                + setType
                + ".");
      }
      if (result.getSecond().length() > 0) {
        errorMessages.add("Please check /filterOps. " + "\n" + result.getSecond());
      }
    }
    Pair<Boolean, Pair<String, String>> findCheck =
        isValidOperand(find, null, validFindOperands, Operand.find.toString());
    if (!findCheck.getFirst()) {
      errorMessages.add(
          "Please check /finds. Your find type: "
              + findCheck.getSecond().getFirst()
              + " is not valid for set type: "
              + setType
              + ".");
    }
    if (!errorMessages.isEmpty()) {
      throw new MalformedURLException(getMessageText(errorMessages));
    }
  }
public static void isValidQuery ( String setType , String [ ] filters , String type , String sum , String [ ] filterOps , String find ) throws MalformedURLException { errorMessages . clear ( ) ; final EnumSet validSumOperands = sumMap . get ( setType ) ; final EnumSet validFilterOperands = filterMap . get ( setType ) ; final EnumSet validTypeOperands = typeMap . get ( setType ) ; final EnumSet validFindOperands = findMap . get ( setType ) ; Pair < Boolean , Pair < String , String > > typeCheck = isValidOperand ( type , null , validTypeOperands , Operand . type . toString ( ) ) ; if ( ! typeCheck . getFirst ( ) ) { errorMessages . add ( "Please check /types. Your histogram type: " + typeCheck . getSecond ( ) . getFirst ( ) + " is not valid for set type: " + setType + "." ) ; } Pair < Boolean , Pair < String , String > > sumCheck = isValidOperand ( sum , null , validSumOperands , Operand . sum . toString ( ) ) ; if ( ! sumCheck . getFirst ( ) ) { errorMessages . add ( "Please check /sums. Your sum type: " + sumCheck . getSecond ( ) . getFirst ( ) + " is not valid for set type: " + setType + "." ) ; } Pair < Boolean , Pair < String , String > > filterCheck = isValidOperand ( filters , filterOps , validFilterOperands , Operand . filter . toString ( ) ) ; if ( ! filterCheck . getFirst ( ) ) { Pair < String , String > result = filterCheck . getSecond ( ) ; if ( result . getFirst ( ) . length ( ) > 0 ) { errorMessages . add ( "Please check /filters. Your filter type: " + result . getFirst ( ) + " is not valid for set type: " + setType + "." ) ; } if ( result . getSecond ( ) . length ( ) > 0 ) { errorMessages . add ( "Please check /filterOps. " + "\n" + result . getSecond ( ) ) ; } } Pair < Boolean , Pair < String , String > > findCheck = isValidOperand ( find , null , validFindOperands , Operand . find . toString ( ) ) ; if ( ! findCheck . getFirst ( ) ) { errorMessages . add ( "Please check /finds. Your find type: " + findCheck . getSecond ( ) . getFirst ( ) + " is not valid for set type: " + setType + "." ) ; } if ( ! errorMessages . isEmpty ( ) ) { throw new MalformedURLException ( getMessageText ( errorMessages ) ) ; } }
Determines whether or not this query should work on NNA.
Determines whether or not this query should work on NNA .