public long getBytes() { return unit.toBytes(size); }
/** * Sets the setting with the provided setting key and the size value. * * @param setting The setting key * @param value The size value * @return The builder */ public Builder put(String setting, long value, ByteSizeUnit sizeUnit) { put(setting, sizeUnit.toBytes(value) + "b"); return this; }
@Override public int hashCode() { return Long.hashCode(size * unit.toBytes(1)); }
public ByteSizeValue(long size, ByteSizeUnit unit) { if (size < -1 || (size == -1 && unit != ByteSizeUnit.BYTES)) { DEPRECATION_LOGGER.deprecated( "Values less than -1 bytes are deprecated and will not be supported in the next major version: [{}]", size + unit.getSuffix()); } if (size > Long.MAX_VALUE / unit.toBytes(1)) { throw new IllegalArgumentException( "Values greater than " + Long.MAX_VALUE + " bytes are not supported: " + size + unit.getSuffix()); } this.size = size; this.unit = unit; }
private static ByteSizeValue parse(final String initialInput, final String normalized, final String suffix, ByteSizeUnit unit, final String settingName) { final String s = normalized.substring(0, normalized.length() - suffix.length()).trim(); try { try { return new ByteSizeValue(Long.parseLong(s), unit); } catch (final NumberFormatException e) { try { final double doubleValue = Double.parseDouble(s); DEPRECATION_LOGGER.deprecated( "Fractional bytes values are deprecated. Use non-fractional bytes values instead: [{}] found for setting [{}]", initialInput, settingName); return new ByteSizeValue((long) (doubleValue * unit.toBytes(1))); } catch (final NumberFormatException ignored) { throw new ElasticsearchParseException("failed to parse [{}]", e, initialInput); } } } catch (IllegalArgumentException e) { throw new ElasticsearchParseException("failed to parse setting [{}] with value [{}] as a size in bytes", e, settingName, initialInput); } }
public long getBytes() { return unit.toBytes(size); }
public long getBytes() { return unit.toBytes(size); }
/** * Sets the setting with the provided setting key and the size value. * * @param setting The setting key * @param value The size value * @return The builder */ public Builder put(String setting, long value, ByteSizeUnit sizeUnit) { put(setting, sizeUnit.toBytes(value) + "b"); return this; }
/** * Sets the setting with the provided setting key and the size value. * * @param setting The setting key * @param value The size value * @return The builder */ public Builder put(String setting, long value, ByteSizeUnit sizeUnit) { put(setting, sizeUnit.toBytes(value) + "b"); return this; }
/** * Sets the setting with the provided setting key and the size value. * * @param setting The setting key * @param value The size value * @return The builder */ public Builder put(String setting, long value, ByteSizeUnit sizeUnit) { put(setting, sizeUnit.toBytes(value) + "b"); return this; }
/** * Sets the setting with the provided setting key and the size value. * * @param setting The setting key * @param value The size value * @return The builder */ public Builder put(String setting, long value, ByteSizeUnit sizeUnit) { put(setting, sizeUnit.toBytes(value) + "b"); return this; }
@Override public int hashCode() { return Double.hashCode(((double) size) * unit.toBytes(1)); }
@Override public int hashCode() { return Long.hashCode(size * unit.toBytes(1)); }
@Override public int hashCode() { return Long.hashCode(size * unit.toBytes(1)); }
public ByteSizeValue(long size, ByteSizeUnit unit) { if (size < -1 || (size == -1 && unit != ByteSizeUnit.BYTES)) { DEPRECATION_LOGGER.deprecated( "Values less than -1 bytes are deprecated and will not be supported in the next major version: [{}]", size + unit.getSuffix()); } if (size > Long.MAX_VALUE / unit.toBytes(1)) { throw new IllegalArgumentException( "Values greater than " + Long.MAX_VALUE + " bytes are not supported: " + size + unit.getSuffix()); } this.size = size; this.unit = unit; }
public ByteSizeValue(long size, ByteSizeUnit unit) { if (size < -1 || (size == -1 && unit != ByteSizeUnit.BYTES)) { DEPRECATION_LOGGER.deprecated( "Values less than -1 bytes are deprecated and will not be supported in the next major version: [{}]", size + unit.getSuffix()); } if (size > Long.MAX_VALUE / unit.toBytes(1)) { throw new IllegalArgumentException( "Values greater than " + Long.MAX_VALUE + " bytes are not supported: " + size + unit.getSuffix()); } this.size = size; this.unit = unit; }