test_class.declarator: metaStoreHelper
test_class.modifier: private
test_class.original_string: private MetaStoreHelper metaStoreHelper;
test_class.type: MetaStoreHelper
test_class.var_name: metaStoreHelper
test_class.declarator: adapter
test_class.modifier: private
test_class.original_string: private MetaStore adapter;
test_class.type: MetaStore
test_class.var_name: adapter
test_class.file: smart-engine/src/test/java/org/smartdata/server/engine/rule/TestRuleExecutor.java
test_class.identifier: TestRuleExecutor
test_class.superclass: extends TestDaoUtil
test_case.body: @Test
    public void generateSQL() throws Exception {
      String countFilter = "";
      String newTable = "test";
      List<String> tableNames = new ArrayList<>();
      tableNames.add("blank_access_count_info");
      String sql;
      /*sql = "CREATE TABLE actual as SELECT fid, SUM(count)" +
          " as count FROM (SELECT * FROM blank_access_count_info " +
          "UNION ALL SELECT * FROM blank_access_count_info " +
          "UNION ALL SELECT * FROM blank_access_count_info) as tmp GROUP BY fid";
      metaStoreHelper.execute(sql);
      metaStoreHelper.dropTable("actual");*/
      // Test single element
      sql = RuleExecutor.generateSQL(tableNames, newTable, countFilter, adapter);
      try {
        metaStoreHelper.execute(sql);
        metaStoreHelper.dropTable(newTable);
      } catch (Exception e) {
        Assert.assertTrue(false);
      }
      // Test multiple elements
      tableNames.add("blank_access_count_info");
      sql = RuleExecutor.generateSQL(tableNames, newTable, countFilter, adapter);
      try {
        metaStoreHelper.execute(sql);
        metaStoreHelper.dropTable(newTable);
      } catch (Exception e) {
        Assert.assertTrue(false);
      }
    }
test_case.class_method_signature: TestRuleExecutor.generateSQL()
test_case.full_signature: @Test public void generateSQL()
test_case.identifier: generateSQL
test_case.invocations: add generateSQL execute dropTable assertTrue add generateSQL execute dropTable assertTrue
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void generateSQL()
focal_class.declarator: ruleManager
focal_class.modifier: private
focal_class.original_string: private RuleManager ruleManager;
focal_class.type: RuleManager
focal_class.var_name: ruleManager
focal_class.declarator: tr
focal_class.modifier: private
focal_class.original_string: private TranslateResult tr;
focal_class.type: TranslateResult
focal_class.var_name: tr
focal_class.declarator: ctx
focal_class.modifier: private
focal_class.original_string: private ExecutionContext ctx;
focal_class.type: ExecutionContext
focal_class.var_name: ctx
focal_class.declarator: adapter
focal_class.modifier: private
focal_class.original_string: private MetaStore adapter;
focal_class.type: MetaStore
focal_class.var_name: adapter
focal_class.declarator: exited = false
focal_class.modifier: private volatile
focal_class.original_string: private volatile boolean exited = false;
focal_class.type: boolean
focal_class.var_name: exited
focal_class.declarator: exitTime
focal_class.modifier: private
focal_class.original_string: private long exitTime;
focal_class.type: long
focal_class.var_name: exitTime
focal_class.declarator: dynamicCleanups = new Stack<>()
focal_class.modifier: private
focal_class.original_string: private Stack<String> dynamicCleanups = new Stack<>();
focal_class.type: Stack<String>
focal_class.var_name: dynamicCleanups
focal_class.declarator: LOG = LoggerFactory.getLogger(RuleExecutor.class.getName())
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOG = LoggerFactory.getLogger(RuleExecutor.class.getName());
focal_class.type: Logger
focal_class.var_name: LOG
focal_class.declarator: varPattern = Pattern.compile("\\$([a-zA-Z_]+[a-zA-Z0-9_]*)")
focal_class.modifier: private static
focal_class.original_string: private static Pattern varPattern = Pattern.compile("\\$([a-zA-Z_]+[a-zA-Z0-9_]*)");
focal_class.type: Pattern
focal_class.var_name: varPattern
focal_class.declarator: callPattern =
        Pattern.compile("\\$@([a-zA-Z_]+[a-zA-Z0-9_]*)\\(([a-zA-Z_][a-zA-Z0-9_]*)?\\)")
focal_class.modifier: private static
focal_class.original_string: private static Pattern callPattern =
        Pattern.compile("\\$@([a-zA-Z_]+[a-zA-Z0-9_]*)\\(([a-zA-Z_][a-zA-Z0-9_]*)?\\)");
focal_class.type: Pattern
focal_class.var_name: callPattern
focal_class.file: smart-engine/src/main/java/org/smartdata/server/engine/rule/RuleExecutor.java
focal_class.identifier: RuleExecutor
focal_class.interfaces: implements Runnable
focal_class.class_method_signature: RuleExecutor.RuleExecutor(
        RuleManager ruleManager, ExecutionContext ctx, TranslateResult tr, MetaStore adapter)
focal_class.full_signature: public  RuleExecutor(
        RuleManager ruleManager, ExecutionContext ctx, TranslateResult tr, MetaStore adapter)
focal_class.identifier: RuleExecutor
focal_class.modifiers: public
focal_class.parameters: (
        RuleManager ruleManager, ExecutionContext ctx, TranslateResult tr, MetaStore adapter)
focal_class.signature:  RuleExecutor(
        RuleManager ruleManager, ExecutionContext ctx, TranslateResult tr, MetaStore adapter)
focal_class.class_method_signature: RuleExecutor.getTranslateResult()
focal_class.full_signature: public TranslateResult getTranslateResult()
focal_class.identifier: getTranslateResult
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: TranslateResult
focal_class.signature: TranslateResult getTranslateResult()
focal_class.class_method_signature: RuleExecutor.unfoldSqlStatement(String sql)
focal_class.full_signature: private String unfoldSqlStatement(String sql)
focal_class.identifier: unfoldSqlStatement
focal_class.modifiers: private
focal_class.parameters: (String sql)
focal_class.return: String
focal_class.signature: String unfoldSqlStatement(String sql)
focal_class.class_method_signature: RuleExecutor.unfoldVariables(String sql)
focal_class.full_signature: private String unfoldVariables(String sql)
focal_class.identifier: unfoldVariables
focal_class.modifiers: private
focal_class.parameters: (String sql)
focal_class.return: String
focal_class.signature: String unfoldVariables(String sql)
focal_class.class_method_signature: RuleExecutor.unfoldFunctionCalls(String sql)
focal_class.full_signature: private String unfoldFunctionCalls(String sql)
focal_class.identifier: unfoldFunctionCalls
focal_class.modifiers: private
focal_class.parameters: (String sql)
focal_class.return: String
focal_class.signature: String unfoldFunctionCalls(String sql)
focal_class.class_method_signature: RuleExecutor.executeFileRuleQuery()
focal_class.full_signature: public List<String> executeFileRuleQuery()
focal_class.identifier: executeFileRuleQuery
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: List<String>
focal_class.signature: List<String> executeFileRuleQuery()
focal_class.class_method_signature: RuleExecutor.callFunction(String funcName, List<Object> parameters)
focal_class.full_signature: public String callFunction(String funcName, List<Object> parameters)
focal_class.identifier: callFunction
focal_class.modifiers: public
focal_class.parameters: (String funcName, List<Object> parameters)
focal_class.return: String
focal_class.signature: String callFunction(String funcName, List<Object> parameters)
focal_class.class_method_signature: RuleExecutor.genVirtualAccessCountTableTopValue(List<Object> parameters)
focal_class.full_signature: public String genVirtualAccessCountTableTopValue(List<Object> parameters)
focal_class.identifier: genVirtualAccessCountTableTopValue
focal_class.modifiers: public
focal_class.parameters: (List<Object> parameters)
focal_class.return: String
focal_class.signature: String genVirtualAccessCountTableTopValue(List<Object> parameters)
focal_class.class_method_signature: RuleExecutor.genVirtualAccessCountTableBottomValue(List<Object> parameters)
focal_class.full_signature: public String genVirtualAccessCountTableBottomValue(List<Object> parameters)
focal_class.identifier: genVirtualAccessCountTableBottomValue
focal_class.modifiers: public
focal_class.parameters: (List<Object> parameters)
focal_class.return: String
focal_class.signature: String genVirtualAccessCountTableBottomValue(List<Object> parameters)
focal_class.class_method_signature: RuleExecutor.genVirtualAccessCountTableValue(List<Object> parameters, boolean top)
focal_class.full_signature: private void genVirtualAccessCountTableValue(List<Object> parameters, boolean top)
focal_class.identifier: genVirtualAccessCountTableValue
focal_class.modifiers: private
focal_class.parameters: (List<Object> parameters, boolean top)
focal_class.return: void
focal_class.signature: void genVirtualAccessCountTableValue(List<Object> parameters, boolean top)
focal_class.class_method_signature: RuleExecutor.genVirtualAccessCountTableTopValueOnStoragePolicy(List<Object> parameters)
focal_class.full_signature: public String genVirtualAccessCountTableTopValueOnStoragePolicy(List<Object> parameters)
focal_class.identifier: genVirtualAccessCountTableTopValueOnStoragePolicy
focal_class.modifiers: public
focal_class.parameters: (List<Object> parameters)
focal_class.return: String
focal_class.signature: String genVirtualAccessCountTableTopValueOnStoragePolicy(List<Object> parameters)
focal_class.class_method_signature: RuleExecutor.genVirtualAccessCountTableBottomValueOnStoragePolicy(List<Object> parameters)
focal_class.full_signature: public String genVirtualAccessCountTableBottomValueOnStoragePolicy(List<Object> parameters)
focal_class.identifier: genVirtualAccessCountTableBottomValueOnStoragePolicy
focal_class.modifiers: public
focal_class.parameters: (List<Object> parameters)
focal_class.return: String
focal_class.signature: String genVirtualAccessCountTableBottomValueOnStoragePolicy(List<Object> parameters)
focal_class.class_method_signature: RuleExecutor.genVirtualAccessCountTableValueOnStoragePolicy(List<Object> parameters,
        boolean top)
focal_class.full_signature: private void genVirtualAccessCountTableValueOnStoragePolicy(List<Object> parameters,
        boolean top)
focal_class.identifier: genVirtualAccessCountTableValueOnStoragePolicy
focal_class.modifiers: private
focal_class.parameters: (List<Object> parameters,
        boolean top)
focal_class.return: void
focal_class.signature: void genVirtualAccessCountTableValueOnStoragePolicy(List<Object> parameters,
        boolean top)
focal_class.class_method_signature: RuleExecutor.genVirtualAccessCountTable(List<Object> parameters)
focal_class.full_signature: public String genVirtualAccessCountTable(List<Object> parameters)
focal_class.identifier: genVirtualAccessCountTable
focal_class.modifiers: public
focal_class.parameters: (List<Object> parameters)
focal_class.return: String
focal_class.signature: String genVirtualAccessCountTable(List<Object> parameters)
focal_class.class_method_signature: RuleExecutor.generateSQL(
        List<String> tableNames, String newTable, String countFilter, MetaStore adapter)
focal_class.full_signature: @VisibleForTesting static String generateSQL(
        List<String> tableNames, String newTable, String countFilter, MetaStore adapter)
focal_class.identifier: generateSQL
focal_class.modifiers: @VisibleForTesting static
focal_class.parameters: (
        List<String> tableNames, String newTable, String countFilter, MetaStore adapter)
focal_class.return: String
focal_class.signature: String generateSQL(
        List<String> tableNames, String newTable, String countFilter, MetaStore adapter)
focal_class.class_method_signature: RuleExecutor.getAccessCountTablesDuringLast(long lastInterval)
focal_class.full_signature: private List<String> getAccessCountTablesDuringLast(long lastInterval)
focal_class.identifier: getAccessCountTablesDuringLast
focal_class.modifiers: private
focal_class.parameters: (long lastInterval)
focal_class.return: List<String>
focal_class.signature: List<String> getAccessCountTablesDuringLast(long lastInterval)
focal_class.class_method_signature: RuleExecutor.run()
focal_class.full_signature: @Override public void run()
focal_class.identifier: run
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void run()
focal_class.class_method_signature: RuleExecutor.exitSchedule()
focal_class.full_signature: private void exitSchedule()
focal_class.identifier: exitSchedule
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void exitSchedule()
focal_class.class_method_signature: RuleExecutor.submitCmdlets(RuleInfo ruleInfo, List<String> files)
focal_class.full_signature: private int submitCmdlets(RuleInfo ruleInfo, List<String> files)
focal_class.identifier: submitCmdlets
focal_class.modifiers: private
focal_class.parameters: (RuleInfo ruleInfo, List<String> files)
focal_class.return: int
focal_class.signature: int submitCmdlets(RuleInfo ruleInfo, List<String> files)
focal_class.class_method_signature: RuleExecutor.isExited()
focal_class.full_signature: public boolean isExited()
focal_class.identifier: isExited
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean isExited()
focal_class.class_method_signature: RuleExecutor.setExited()
focal_class.full_signature: public void setExited()
focal_class.identifier: setExited
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void setExited()
focal_class.class_method_signature: RuleExecutor.getExitTime()
focal_class.full_signature: public long getExitTime()
focal_class.identifier: getExitTime
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: long
focal_class.signature: long getExitTime()
focal_method.body: @VisibleForTesting
    static String generateSQL(
        List<String> tableNames, String newTable, String countFilter, MetaStore adapter) {
      String sqlFinal, sqlCreate;
      if (tableNames.size() <= 1) {
        String tableName = tableNames.size() == 0 ? "blank_access_count_info" : tableNames.get(0);
        sqlCreate = "CREATE TABLE " + newTable + "(fid INTEGER NOT NULL, count INTEGER NOT NULL);";
        try {
          adapter.execute(sqlCreate);
        } catch (MetaStoreException e) {
          LOG.error("Cannot create table " + newTable, e);
        }
        sqlFinal = "INSERT INTO " + newTable + " SELECT * FROM " + tableName + ";";
      } else {
        String sqlPrefix = "SELECT fid, SUM(count) AS count FROM (\n";
        String sqlUnion = "SELECT fid, count FROM " + tableNames.get(0) + " \n";
        for (int i = 1; i < tableNames.size(); i++) {
          sqlUnion += "UNION ALL\n" + "SELECT fid, count FROM " + tableNames.get(i) + " \n";
        }
        String sqlSufix = ") as tmp GROUP BY fid ";
        String sqlCountFilter =
            (countFilter == null || countFilter.length() == 0)
                ? ""
                : "HAVING SUM(count) " + countFilter;
        String sqlRe = sqlPrefix + sqlUnion + sqlSufix + sqlCountFilter;
        sqlCreate = "CREATE TABLE " + newTable + "(fid INTEGER NOT NULL, count INTEGER NOT NULL);";
        try {
          adapter.execute(sqlCreate);
        } catch (MetaStoreException e) {
          LOG.error("Cannot create table " + newTable, e);
        }
        sqlFinal = "INSERT INTO " + newTable + " SELECT * FROM (" + sqlRe + ") temp;";
      }
      return sqlFinal;
    }
focal_method.class_method_signature: RuleExecutor.generateSQL(
        List<String> tableNames, String newTable, String countFilter, MetaStore adapter)
focal_method.full_signature: @VisibleForTesting static String generateSQL(
        List<String> tableNames, String newTable, String countFilter, MetaStore adapter)
focal_method.identifier: generateSQL
focal_method.invocations: size size get execute error get size get length execute error
focal_method.modifiers: @VisibleForTesting static
focal_method.parameters: (
        List<String> tableNames, String newTable, String countFilter, MetaStore adapter)
focal_method.return: String
focal_method.signature: String generateSQL(
        List<String> tableNames, String newTable, String countFilter, MetaStore adapter)