示例#1
0
            @Override
            public HPCMemoryConfig apply(
                HPCMemoryConfig basedOnRatio, Function<String, String> settings) {
              String explicitNodeCacheSize =
                  settings.apply(HighPerformanceCacheSettings.node_cache_size.name());
              String explicitRelCacheSize =
                  settings.apply(HighPerformanceCacheSettings.relationship_cache_size.name());
              String explicitNodeArrayFraction =
                  settings.apply(HighPerformanceCacheSettings.node_cache_array_fraction.name());
              String explicitRelArrayFraction =
                  settings.apply(
                      HighPerformanceCacheSettings.relationship_cache_array_fraction.name());

              if (explicitNodeCacheSize != null
                  || explicitRelCacheSize != null
                  || explicitNodeArrayFraction != null
                  || explicitRelArrayFraction != null) {
                // At least one explicit config set, swap to explicit mode
                long nodeCacheBytes =
                    explicitNodeCacheSize != null ? BYTES.apply(explicitNodeCacheSize) : heap() / 8;
                long relCacheBytes =
                    explicitRelCacheSize != null ? BYTES.apply(explicitRelCacheSize) : heap() / 8;
                float nodeArrRatio =
                    explicitNodeArrayFraction != null
                        ? FLOAT.apply(explicitNodeArrayFraction)
                        : 1.0f;
                float relArrRatio =
                    explicitRelArrayFraction != null ? FLOAT.apply(explicitRelArrayFraction) : 1.0f;

                // Figure out if user is inadvertently overwriting her own configuration
                HPCMemoryConfig.Source source =
                    basedOnRatio.source() == HPCMemoryConfig.Source.DEFAULT_MEMORY_RATIO
                        ? HPCMemoryConfig.Source.SPECIFIC
                        : HPCMemoryConfig.Source.SPECIFIC_OVERRIDING_RATIO;
                return new HPCMemoryConfig(
                    nodeCacheBytes, relCacheBytes, nodeArrRatio, relArrRatio, source);
              }

              return basedOnRatio;
            }
      public TO next() {
        FROM from = fromIterator.next();

        return function.map(from);
      }