コード例 #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;
            }
コード例 #2
0
 public static int heapSize(Class primitiveType) {
   if (!primitiveType.isPrimitive()) throw new IllegalArgumentException();
   return (int) BYTES.alignAndConvert(HEAP_SIZE_MAP.get(primitiveType), BITS);
 }
コード例 #3
0
ファイル: SizeUnit.java プロジェクト: philipjameson/buck
 public long toBytes(double size) {
   return multiplyByByteOrderOfMagnitude(size, getOrdinal() - BYTES.getOrdinal());
 }
コード例 #4
0
ファイル: SizeUnit.java プロジェクト: NZKoz/dropwizard
 public long toBytes(long l) {
   return BYTES.convert(l, this);
 }