当前位置: 首页>>代码示例>>Java>>正文


Java MVMap.keySet方法代码示例

本文整理汇总了Java中org.h2.mvstore.MVMap.keySet方法的典型用法代码示例。如果您正苦于以下问题:Java MVMap.keySet方法的具体用法?Java MVMap.keySet怎么用?Java MVMap.keySet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.h2.mvstore.MVMap的用法示例。


在下文中一共展示了MVMap.keySet方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPostContingencyLoadflowConvergence

import org.h2.mvstore.MVMap; //导入方法依赖的package包/类
@Override
public Map<Integer, Boolean> getPostContingencyLoadflowConvergence(String workflowId, String contingencyId) {
    if (isWorkflowStored(workflowId)) {
        Map<Integer, Boolean> loadflowConvergence = new HashMap<Integer, Boolean>();
        MVStore wfMVStore = getStore(workflowId);
        if (wfMVStore.getMapNames().contains(STORED_PC_LOADFLOW_CONTINGENCIES_MAP_NAME)) {
            Map<String, String> storedStatesMap = wfMVStore.openMap(STORED_PC_LOADFLOW_CONTINGENCIES_MAP_NAME, mapBuilder);
            if (storedStatesMap.containsKey(contingencyId)) {
                MVMap<String, String> contingencyStateMap = wfMVStore.openMap(contingencyId + STORED_PC_LOADFLOW_STATES_MAP_SUFFIX, mapBuilder);
                for (String stateId : contingencyStateMap.keySet()) {
                    loadflowConvergence.put(Integer.valueOf(stateId), Boolean.valueOf(contingencyStateMap.get(stateId)));
                }
                return loadflowConvergence;
            } else {
                LOGGER.warn("No post contingency loadflow data for contingency {} in wf {}", contingencyId, workflowId);
                return null;
            }
        } else {
            LOGGER.warn("No post contingency loadflow data in wf {}", workflowId);
            return null;
        }
    } else {
        LOGGER.warn("No data about wf {}", workflowId);
        return null;
    }
}
 
开发者ID:itesla,项目名称:ipst,代码行数:27,代码来源:OnlineDbMVStore.java

示例2: exportStoredMapContent

import org.h2.mvstore.MVMap; //导入方法依赖的package包/类
public String exportStoredMapContent(String workflowId, String mapName) {
    Objects.requireNonNull(workflowId, "workflow id is null");
    Objects.requireNonNull(mapName, "map name id is null");
    LOGGER.info("Exporting content of stored map {}  of wf {}", mapName, workflowId);
    if (isWorkflowStored(workflowId)) {
        MVStore wfMVStore = getStore(workflowId);
        if (wfMVStore.hasMap(mapName)) {
            StringBuffer storedMapContent = new StringBuffer();
            storedMapContent.append("Map " + mapName + "\n");
            MVMap<String, String> storedMap = wfMVStore.openMap(mapName, mapBuilder);
            for (String key : storedMap.keySet()) {
                storedMapContent.append(key + " = " + storedMap.get(key) + "\n");
            }
            return storedMapContent.toString();
        } else {
            LOGGER.warn("No {} map in wf {}", mapName, workflowId);
            return null;
        }
    } else {
        LOGGER.warn("No data about wf {}", workflowId);
        return null;
    }
}
 
开发者ID:itesla,项目名称:ipst,代码行数:24,代码来源:OnlineDbMVStore.java

示例3: getWcaResults

import org.h2.mvstore.MVMap; //导入方法依赖的package包/类
@Override
public OnlineWorkflowWcaResults getWcaResults(String workflowId) {
    Objects.requireNonNull(workflowId, "workflow id is null");
    LOGGER.info("Getting WCA results of wf {}", workflowId);
    if (isWorkflowStored(workflowId)) {
        MVStore wfMVStore = getStore(workflowId);
        if (wfMVStore.hasMap(STORED_WCA_RESULTS_MAP_NAME)) {
            MVMap<String, String> storedRulesResultsMap = wfMVStore.openMap(STORED_WCA_RESULTS_MAP_NAME, mapBuilder);
            // create workflow rules results
            OnlineWorkflowWcaResultsImpl wfWcaResults = new OnlineWorkflowWcaResultsImpl(
                    workflowId,
                    TimeHorizon.valueOf(storedRulesResultsMap.get(STORED_RESULTS_TIMEHORIZON_KEY)));
            // add classification of contingencies in clusters
            MVMap<String, String> storedClustersMap = wfMVStore.openMap(STORED_WCA_RESULTS_CLUSTERS_MAP_NAME, mapBuilder);
            MVMap<String, String> storedCausesMap = wfMVStore.openMap(STORED_WCA_RESULTS_CAUSES_MAP_NAME, mapBuilder);
            for (String contingencyId : storedClustersMap.keySet()) {
                String cause = storedCausesMap.get(contingencyId);
                wfWcaResults.addContingencyWithCluster(contingencyId,
                        Integer.valueOf(storedClustersMap.get(contingencyId)),
                        cause != null ? Arrays.asList(cause) : null);
            }
            return wfWcaResults;
        } else {
            LOGGER.warn("No WCA results of wf {} stored in online db", workflowId);
            return null;
        }
    } else {
        LOGGER.warn("No data about wf {}", workflowId);
        return null;
    }
}
 
开发者ID:itesla,项目名称:ipst,代码行数:32,代码来源:OnlineDbMVStore.java

示例4: getStatesProcessingStatus

import org.h2.mvstore.MVMap; //导入方法依赖的package包/类
@Override
public Map<Integer, ? extends StateProcessingStatus> getStatesProcessingStatus(String workflowId) {
    Objects.requireNonNull(workflowId, "workflow id is null");
    LOGGER.info("Getting states processing status of wf {}", workflowId);
    if (isWorkflowStored(workflowId)) {
        MVStore wfMVStore = getStore(workflowId);
        if (wfMVStore.hasMap(STORED_STATES_PROCESSING_STATUS_MAP_NAME)) {
            MVMap<String, String> statesProcessingStatusMap = wfMVStore.openMap(STORED_STATES_PROCESSING_STATUS_MAP_NAME, mapBuilder);
            // create states processing status
            Map<Integer, StateProcessingStatus> statesProcessingStatus = new HashMap<Integer, StateProcessingStatus>();
            // add processing status for states
            Collection<Integer> stateWithProcessingStatus = OnlineDbMVStoreUtils.jsonToStatesIds(statesProcessingStatusMap.get(STORED_STATES_LIST_KEY));
            for (Integer stateId : stateWithProcessingStatus) {
                MVMap<String, String> stateProcessingStatusMap = wfMVStore.openMap(stateId + STORED_STATE_PROCESSING_STATUS_MAP_SUFFIX, mapBuilder);
                Map<String, String> processingStatus = new HashMap<String, String>();
                for (String step : stateProcessingStatusMap.keySet()) {
                    if (!step.equals(STORED_STATES_STATE_DETAILS_KEY)) {
                        processingStatus.put(step, stateProcessingStatusMap.get(step));
                    }
                }
                statesProcessingStatus.put(stateId, new StateProcessingStatusImpl(processingStatus, stateProcessingStatusMap.get(STORED_STATES_STATE_DETAILS_KEY)));
            }
            return statesProcessingStatus;
        } else {
            LOGGER.warn("No states processing status of wf {} stored in online db", workflowId);
            return null;
        }
    } else {
        LOGGER.warn("No data about wf {}", workflowId);
        return null;
    }
}
 
开发者ID:itesla,项目名称:ipst,代码行数:33,代码来源:OnlineDbMVStore.java

示例5: getViolations

import org.h2.mvstore.MVMap; //导入方法依赖的package包/类
@Override
public Map<OnlineStep, List<LimitViolation>> getViolations(String workflowId, Integer stateId) {
    String stateIdStr = Integer.toString(stateId);
    LOGGER.info("Getting violations for wf {} and state {}", workflowId, stateIdStr);
    if (isWorkflowStored(workflowId)) {
        MVStore wfMVStore = getStore(workflowId);
        // check if there are stored violations
        Map<String, String> storedStatesMap = wfMVStore.openMap(STORED_VIOLATIONS_STATES_MAP_NAME, mapBuilder);
        if (storedStatesMap.containsKey(stateIdStr)) {
            // load network: used to get equipment from equipment id, when creating limit violations
            Network network = getState(workflowId, 0);
            if (network != null) {
                Map<OnlineStep, List<LimitViolation>> stateViolations = new HashMap<OnlineStep, List<LimitViolation>>();
                MVMap<String, String> storedStepsMap = wfMVStore.openMap(stateIdStr + STORED_VIOLATIONS_STEPS_MAP_SUFFIX, mapBuilder);
                for (String stepName : storedStepsMap.keySet()) {
                    OnlineStep step = OnlineStep.valueOf(stepName);
                    List<LimitViolation> violations = getStoredViolations(workflowId, STORED_VIOLATIONS_MAP_PREFIX + step.name() + "_" + stateId, network);
                    if (violations != null) {
                        stateViolations.put(step, violations);
                    }
                }
                return stateViolations;
            } else {
                LOGGER.warn("No network data (states) stored for wf {}, cannot get violations", workflowId);
                return null;
            }
        } else {
            LOGGER.warn("No violations for wf {} and state {}", workflowId, stateIdStr);
            return null;
        }
    } else {
        LOGGER.warn("No data about wf {}", workflowId);
        return null;
    }
}
 
开发者ID:itesla,项目名称:ipst,代码行数:36,代码来源:OnlineDbMVStore.java

示例6: getPostContingencyViolations

import org.h2.mvstore.MVMap; //导入方法依赖的package包/类
@Override
public Map<String, List<LimitViolation>> getPostContingencyViolations(String workflowId, Integer stateId) {
    String stateIdStr = Integer.toString(stateId);
    LOGGER.info("Getting post contingency violations for wf {} and state {}", workflowId, stateIdStr);
    if (isWorkflowStored(workflowId)) {
        MVStore wfMVStore = getStore(workflowId);
        // check if there are stored violations
        Map<String, String> storedStatesMap = wfMVStore.openMap(STORED_PC_VIOLATIONS_STATES_MAP_NAME, mapBuilder);
        if (storedStatesMap.containsKey(stateIdStr)) {
            // load network: used to get equipment from equipment id, when creating limit violations
            Network network = getState(workflowId, 0);
            if (network != null) {
                Map<String, List<LimitViolation>> stateViolations = new HashMap<String, List<LimitViolation>>();
                MVMap<String, String> storedContingenciesMap = wfMVStore.openMap(stateIdStr + STORED_PC_VIOLATIONS_CONTINGENCIES_MAP_SUFFIX, mapBuilder);
                for (String contingencyId : storedContingenciesMap.keySet()) {
                    List<LimitViolation> violations = getStoredViolations(workflowId, STORED_PC_VIOLATIONS_MAP_PREFIX + contingencyId + "_" + stateId, network);
                    if (violations != null) {
                        stateViolations.put(contingencyId, violations);
                    }
                }
                return stateViolations;
            } else {
                LOGGER.warn("No network data (states) stored for wf {}, cannot get post contingency violations", workflowId);
                return null;
            }
        } else {
            LOGGER.warn("No post contingency violations for wf {} and state {}", workflowId, stateIdStr);
            return null;
        }
    } else {
        LOGGER.warn("No data about wf {}", workflowId);
        return null;
    }
}
 
开发者ID:itesla,项目名称:ipst,代码行数:35,代码来源:OnlineDbMVStore.java

示例7: testConcurrentOnlineBackup

import org.h2.mvstore.MVMap; //导入方法依赖的package包/类
private void testConcurrentOnlineBackup() throws Exception {
    String fileName = getBaseDir() + "/onlineBackup.h3";
    String fileNameRestore = getBaseDir() + "/onlineRestore.h3";
    final MVStore s = openStore(fileName);
    final MVMap<Integer, byte[]> map = s.openMap("test");
    final Random r = new Random();
    Task t = new Task() {
        @Override
        public void call() throws Exception {
            while (!stop) {
                for (int i = 0; i < 10; i++) {
                    map.put(i, new byte[100 * r.nextInt(100)]);
                }
                s.commit();
                map.clear();
                s.commit();
                long len = s.getFileStore().size();
                if (len > 1024 * 1024) {
                    // slow down writing a lot
                    Thread.sleep(200);
                } else if (len > 20 * 1024) {
                    // slow down writing
                    Thread.sleep(20);
                }
            }
        }
    };
    t.execute();
    for (int i = 0; i < 10; i++) {
        // System.out.println("test " + i);
        s.setReuseSpace(false);
        byte[] buff = readFileSlowly(s.getFileStore().getFile(),
                s.getFileStore().size());
        s.setReuseSpace(true);
        FileOutputStream out = new FileOutputStream(fileNameRestore);
        out.write(buff);
        out.close();
        MVStore s2 = openStore(fileNameRestore);
        MVMap<Integer, byte[]> test = s2.openMap("test");
        for (Integer k : test.keySet()) {
            test.get(k);
        }
        s2.close();
        // let it compact
        Thread.sleep(10);
    }
    t.get();
    s.close();
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:50,代码来源:TestConcurrent.java

示例8: getAllMetrics

import org.h2.mvstore.MVMap; //导入方法依赖的package包/类
@Override
public List<String[]> getAllMetrics(String workflowId, OnlineStep step) {
    LOGGER.info("Preparing CSV data for wf {} and step {}", workflowId, step.name());
    List<String[]> retTable = new ArrayList<>();
    if (isWorkflowStored(workflowId)) {
        try {
            MVStore wfMVStore = getStore(workflowId);
            // check if there are stored metrics
            Map<String, String> storedStepsMap = wfMVStore.openMap(STORED_METRICS_STEPS_MAP_NAME, mapBuilder);
            if (storedStepsMap.containsKey(step.name())) {
                MVMap<String, String> stepParamsMap = wfMVStore.openMap(step.name() + STORED_METRICS_PARAMS_MAP_SUFFIX, mapBuilder);
                MVMap<String, String> stepStatesMap = wfMVStore.openMap(step.name() + STORED_METRICS_STATES_MAP_SUFFIX, mapBuilder);
                // gets headers
                String[] headers = new String[stepParamsMap.keySet().size() + 1];
                headers[0] = "state";
                HashMap<String, Integer> paramsIndexes = new HashMap<>();
                int i = 1;
                for (String parameter : stepParamsMap.keySet()) {
                    headers[i] = parameter;
                    paramsIndexes.put(parameter, i);
                    i++;
                }
                retTable.add(headers);
                // gets step general metrics, if stored
                if (stepStatesMap.containsKey("_")) {
                    retTable.add(getStoredMapValues(wfMVStore, "_", step, stepParamsMap.keySet().size(), paramsIndexes));
                }
                // gets step metrics for each state, if stored
                stepStatesMap.keySet().stream()
                        .filter(x -> !"_".equals(x))
                        .sorted(Comparator.comparing(Integer::valueOf))
                        .forEach(stateId -> {
                            retTable.add(getStoredMapValues(wfMVStore, stateId, step, stepParamsMap.keySet().size(), paramsIndexes));
                        });
            }
        } catch (Exception e) {
            String errorMessage = "error getting cvs data for step " + step.name() + " and wf id " + workflowId;
            LOGGER.error(errorMessage);
            throw new RuntimeException(errorMessage, e);
        }
    } else {
        LOGGER.warn("No data about wf {}", workflowId);
    }
    return retTable;
}
 
开发者ID:itesla,项目名称:ipst,代码行数:46,代码来源:OnlineDbMVStore.java

示例9: getRulesResults

import org.h2.mvstore.MVMap; //导入方法依赖的package包/类
@Override
public OnlineWorkflowRulesResults getRulesResults(String workflowId) {
    Objects.requireNonNull(workflowId, "workflow id is null");
    LOGGER.info("Getting rules results of wf {}", workflowId);
    if (isWorkflowStored(workflowId)) {
        MVStore wfMVStore = getStore(workflowId);
        if (wfMVStore.hasMap(STORED_RULES_RESULTS_MAP_NAME)) {
            MVMap<String, String> storedRulesResultsMap = wfMVStore.openMap(STORED_RULES_RESULTS_MAP_NAME, mapBuilder);
            // create workflow rules results
            OnlineWorkflowRulesResultsImpl wfRulesResults = new OnlineWorkflowRulesResultsImpl(
                    workflowId,
                    TimeHorizon.valueOf(storedRulesResultsMap.get(STORED_RESULTS_TIMEHORIZON_KEY)));
            // add contingencies with rules results
            Collection<String> contingenciesWithRules = OnlineDbMVStoreUtils.jsonToContingenciesIds(
                    storedRulesResultsMap.get(STORED_RULES_RESULTS_CONTINGENCIES_WITH_RULES_KEY));
            for (String contingencyId : contingenciesWithRules) {
                MVMap<String, String> storedStateStatusMap = wfMVStore.openMap(contingencyId + STORED_RULES_RESULTS_STATE_STATUS_MAP_SUFFIX, mapBuilder);
                MVMap<String, String> storedStateResultsMap = wfMVStore.openMap(contingencyId + STORED_RULES_RESULTS_STATE_RESULTS_MAP_SUFFIX, mapBuilder);
                MVMap<String, String> storedStateAvailableRulesMap = wfMVStore.openMap(contingencyId + STORED_RULES_RESULTS_STATE_RULES_AVAILABLE_MAP_SUFFIX, mapBuilder);
                MVMap<String, String> storedStateInvalidRulesMap = wfMVStore.openMap(contingencyId + STORED_RULES_RESULTS_STATE_INVALID_RULES_MAP_SUFFIX, mapBuilder);
                for (String stateId : storedStateStatusMap.keySet()) {
                    Map<String, Boolean> stateResults = OnlineDbMVStoreUtils.jsonToIndexesData(storedStateResultsMap.get(stateId));
                    StateStatus stateStatus = StateStatus.valueOf(storedStateStatusMap.get(stateId));
                    boolean rulesAvailable = true;
                    if (storedStateAvailableRulesMap.containsKey(stateId)) {
                        rulesAvailable = Boolean.parseBoolean(storedStateAvailableRulesMap.get(stateId));
                    }
                    List<SecurityIndexType> invalidRules = new ArrayList<SecurityIndexType>();
                    if (storedStateInvalidRulesMap.containsKey(stateId)) {
                        invalidRules.addAll(OnlineDbMVStoreUtils.jsonToIndexesTypes(storedStateInvalidRulesMap.get(stateId)));
                    }
                    wfRulesResults.addContingencyWithSecurityRulesResults(contingencyId, Integer.parseInt(stateId), stateStatus, stateResults,
                            rulesAvailable, invalidRules);
                }
            }
            return wfRulesResults;
        } else {
            LOGGER.warn("No rules results of wf {} stored in online db", workflowId);
            return null;
        }
    } else {
        LOGGER.warn("No data about wf {}", workflowId);
        return null;
    }
}
 
开发者ID:itesla,项目名称:ipst,代码行数:46,代码来源:OnlineDbMVStore.java

示例10: getWcaRulesResults

import org.h2.mvstore.MVMap; //导入方法依赖的package包/类
@Override
public OnlineWorkflowRulesResults getWcaRulesResults(String workflowId) {
    Objects.requireNonNull(workflowId, "workflow id is null");
    LOGGER.info("Getting wca rules results of wf {}", workflowId);
    if (isWorkflowStored(workflowId)) {
        MVStore wfMVStore = getStore(workflowId);
        if (wfMVStore.hasMap(STORED_WCA_RULES_RESULTS_MAP_NAME)) {
            MVMap<String, String> storedRulesResultsMap = wfMVStore.openMap(STORED_WCA_RULES_RESULTS_MAP_NAME, mapBuilder);
            // create workflow rules results
            OnlineWorkflowRulesResultsImpl wfRulesResults = new OnlineWorkflowRulesResultsImpl(
                    workflowId,
                    TimeHorizon.valueOf(storedRulesResultsMap.get(STORED_RESULTS_TIMEHORIZON_KEY)));
            // add contingencies with rules results
            Collection<String> contingenciesWithRules = OnlineDbMVStoreUtils.jsonToContingenciesIds(
                    storedRulesResultsMap.get(STORED_RULES_RESULTS_CONTINGENCIES_WITH_RULES_KEY));
            for (String contingencyId : contingenciesWithRules) {
                MVMap<String, String> storedStateStatusMap = wfMVStore.openMap(contingencyId + STORED_WCA_RULES_RESULTS_STATE_STATUS_MAP_SUFFIX, mapBuilder);
                MVMap<String, String> storedStateResultsMap = wfMVStore.openMap(contingencyId + STORED_WCA_RULES_RESULTS_STATE_RESULTS_MAP_SUFFIX, mapBuilder);
                MVMap<String, String> storedStateAvailableRulesMap = wfMVStore.openMap(contingencyId + STORED_WCA_RULES_RESULTS_STATE_RULES_AVAILABLE_MAP_SUFFIX, mapBuilder);
                MVMap<String, String> storedStateInvalidRulesMap = wfMVStore.openMap(contingencyId + STORED_WCA_RULES_RESULTS_STATE_INVALID_RULES_MAP_SUFFIX, mapBuilder);
                for (String stateId : storedStateStatusMap.keySet()) {
                    Map<String, Boolean> stateResults = OnlineDbMVStoreUtils.jsonToIndexesData(storedStateResultsMap.get(stateId));
                    StateStatus stateStatus = StateStatus.valueOf(storedStateStatusMap.get(stateId));
                    boolean rulesAvailable = true;
                    if (storedStateAvailableRulesMap.containsKey(stateId)) {
                        rulesAvailable = Boolean.parseBoolean(storedStateAvailableRulesMap.get(stateId));
                    }
                    List<SecurityIndexType> invalidRules = new ArrayList<SecurityIndexType>();
                    if (storedStateInvalidRulesMap.containsKey(stateId)) {
                        invalidRules.addAll(OnlineDbMVStoreUtils.jsonToIndexesTypes(storedStateInvalidRulesMap.get(stateId)));
                    }
                    wfRulesResults.addContingencyWithSecurityRulesResults(contingencyId, Integer.parseInt(stateId), stateStatus, stateResults,
                            rulesAvailable, invalidRules);
                }
            }
            return wfRulesResults;
        } else {
            LOGGER.warn("No wca rules results of wf {} stored in online db", workflowId);
            return null;
        }
    } else {
        LOGGER.warn("No data about wf {}", workflowId);
        return null;
    }
}
 
开发者ID:itesla,项目名称:ipst,代码行数:46,代码来源:OnlineDbMVStore.java


注:本文中的org.h2.mvstore.MVMap.keySet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。