Top Fields Constructors Methods
org.postgresql.util

public Class PGPropertyMaxResultBufferParser

extends Object
Class Inheritance
Imports
org.checkerframework.checker.nullness.qual.Nullable, java.lang.management.ManagementFactory, java.util.logging.Level, .Logger

Field Summary

Modifier and TypeField and Description
private static final Logger
private static final String[]

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static long

Returns:

Adjusted size (original size or 90% of max heap memory)
adjustResultSize
(long
Size to be adjusted.
value
)

Method to adjust result memory limit size.

private static long

Returns:

Size of byte buffer based on percent of max heap memory.
calculatePercentOfMemory
(String
String which contains percent + percent phrase which gonna be used during calculations.
value
,
int
Length of percent phrase inside given value.
percentPhraseLength
)

Method to calculate percent of given max heap memory.

private static boolean

Returns:

Result if value contains percent.
checkIfValueContainsPercent
(String
Value to check.
value
)

Method to check if given value can contain percent declaration of size of max result buffer.

private static int

Returns:

Length of phrase inside string, returns -1 when no phrase found.
getPercentPhraseLengthIfContains
(String
String which is gonna be checked if contains percent phrase.
valueToCheck
)

Method to get length of percent phrase existing in given string, only if one of phrases exist on the length of string.

private static int

Returns:

Length of phrase inside string, returns -1 when phrase wasn't found.
getPhraseLengthIfContains
(String
String which gonna be checked if contains phrase.
valueToCheck
,
String
Phrase to be looked for on the end of given string.
phrase
)

Method to get length of given phrase in given string to check, method checks if phrase exist on the end of given string.

private static long

Returns:

percent value of max result buffer size.
parseBytePercentValue
(String
string containing percent used to define max result buffer.
value
)

Method to get percent value of max result buffer size dependable on actual free memory.

private static long

Returns:

Size based on given string.
parseByteValue
(String
Given string to be parsed.
value
)

Method to get size based on given string value.

public static long

Returns:

value of max result buffer size.
parseProperty
(@Nullable String
string containing size of bytes with optional multiplier (T, G, M or K) or percent value to declare max percent of heap memory to use.
value
)

Method to parse value of max result buffer size.

private static void
throwExceptionAboutParsingError(String
Message to be added to exception.
message
,
Object...
Values to be put inside exception message.
values
)

Method to throw message for parsing MaxResultBuffer.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

LOGGERback to summary
private static final Logger LOGGER
PERCENT_PHRASESback to summary
private static final String[] PERCENT_PHRASES

Constructor Detail

PGPropertyMaxResultBufferParserback to summary
public PGPropertyMaxResultBufferParser()

Method Detail

adjustResultSizeback to summary
private static long adjustResultSize(long value)

Method to adjust result memory limit size. If given memory is larger than 90% of max heap memory then it gonna be reduced to 90% of max heap memory.

Parameters
value:long

Size to be adjusted.

Returns:long

Adjusted size (original size or 90% of max heap memory)

calculatePercentOfMemoryback to summary
private static long calculatePercentOfMemory(String value, int percentPhraseLength)

Method to calculate percent of given max heap memory.

Parameters
value:String

String which contains percent + percent phrase which gonna be used during calculations.

percentPhraseLength:int

Length of percent phrase inside given value.

Returns:long

Size of byte buffer based on percent of max heap memory.

checkIfValueContainsPercentback to summary
private static boolean checkIfValueContainsPercent(String value)

Method to check if given value can contain percent declaration of size of max result buffer.

Parameters
value:String

Value to check.

Returns:boolean

Result if value contains percent.

getPercentPhraseLengthIfContainsback to summary
private static int getPercentPhraseLengthIfContains(String valueToCheck)

Method to get length of percent phrase existing in given string, only if one of phrases exist on the length of string.

Parameters
valueToCheck:String

String which is gonna be checked if contains percent phrase.

Returns:int

Length of phrase inside string, returns -1 when no phrase found.

getPhraseLengthIfContainsback to summary
private static int getPhraseLengthIfContains(String valueToCheck, String phrase)

Method to get length of given phrase in given string to check, method checks if phrase exist on the end of given string.

Parameters
valueToCheck:String

String which gonna be checked if contains phrase.

phrase:String

Phrase to be looked for on the end of given string.

Returns:int

Length of phrase inside string, returns -1 when phrase wasn't found.

parseBytePercentValueback to summary
private static long parseBytePercentValue(String value) throws PSQLException

Method to get percent value of max result buffer size dependable on actual free memory. This method doesn't check other possibilities of value declaration.

Parameters
value:String

string containing percent used to define max result buffer.

Returns:long

percent value of max result buffer size.

Exceptions
PSQLException:
Exception when given value can't be parsed.
parseByteValueback to summary
private static long parseByteValue(String value) throws PSQLException

Method to get size based on given string value. String can contains just a number or number + multiplier sign (like T, G, M or K).

Parameters
value:String

Given string to be parsed.

Returns:long

Size based on given string.

Exceptions
PSQLException:
Exception when given value can't be parsed.
parsePropertyback to summary
public static long parseProperty(@Nullable String value) throws PSQLException

Method to parse value of max result buffer size.

Parameters
value:@Nullable String

string containing size of bytes with optional multiplier (T, G, M or K) or percent value to declare max percent of heap memory to use.

Returns:long

value of max result buffer size.

Exceptions
PSQLException:
Exception when given value can't be parsed.
throwExceptionAboutParsingErrorback to summary
private static void throwExceptionAboutParsingError(String message, Object... values) throws PSQLException

Method to throw message for parsing MaxResultBuffer.

Parameters
message:String

Message to be added to exception.

values:Object[]

Values to be put inside exception message.

Exceptions
PSQLException:
Exception when given value can't be parsed.