Pbxt.php 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <?php
  2. /**
  3. * The PBXT storage engine
  4. */
  5. declare(strict_types=1);
  6. namespace PhpMyAdmin\Engines;
  7. use PhpMyAdmin\Core;
  8. use PhpMyAdmin\StorageEngine;
  9. use PhpMyAdmin\Util;
  10. use function is_string;
  11. use function preg_match;
  12. use function sprintf;
  13. /**
  14. * The PBXT storage engine
  15. */
  16. class Pbxt extends StorageEngine
  17. {
  18. /**
  19. * Returns array with variable names dedicated to PBXT storage engine
  20. *
  21. * @return array variable names
  22. */
  23. public function getVariables()
  24. {
  25. return [
  26. 'pbxt_index_cache_size' => [
  27. 'title' => __('Index cache size'),
  28. 'desc' => __(
  29. 'This is the amount of memory allocated to the'
  30. . ' index cache. Default value is 32MB. The memory'
  31. . ' allocated here is used only for caching index pages.'
  32. ),
  33. 'type' => PMA_ENGINE_DETAILS_TYPE_SIZE,
  34. ],
  35. 'pbxt_record_cache_size' => [
  36. 'title' => __('Record cache size'),
  37. 'desc' => __(
  38. 'This is the amount of memory allocated to the'
  39. . ' record cache used to cache table data. The default'
  40. . ' value is 32MB. This memory is used to cache changes to'
  41. . ' the handle data (.xtd) and row pointer (.xtr) files.'
  42. ),
  43. 'type' => PMA_ENGINE_DETAILS_TYPE_SIZE,
  44. ],
  45. 'pbxt_log_cache_size' => [
  46. 'title' => __('Log cache size'),
  47. 'desc' => __(
  48. 'The amount of memory allocated to the'
  49. . ' transaction log cache used to cache on transaction log'
  50. . ' data. The default is 16MB.'
  51. ),
  52. 'type' => PMA_ENGINE_DETAILS_TYPE_SIZE,
  53. ],
  54. 'pbxt_log_file_threshold' => [
  55. 'title' => __('Log file threshold'),
  56. 'desc' => __(
  57. 'The size of a transaction log before rollover,'
  58. . ' and a new log is created. The default value is 16MB.'
  59. ),
  60. 'type' => PMA_ENGINE_DETAILS_TYPE_SIZE,
  61. ],
  62. 'pbxt_transaction_buffer_size' => [
  63. 'title' => __('Transaction buffer size'),
  64. 'desc' => __(
  65. 'The size of the global transaction log buffer'
  66. . ' (the engine allocates 2 buffers of this size).'
  67. . ' The default is 1MB.'
  68. ),
  69. 'type' => PMA_ENGINE_DETAILS_TYPE_SIZE,
  70. ],
  71. 'pbxt_checkpoint_frequency' => [
  72. 'title' => __('Checkpoint frequency'),
  73. 'desc' => __(
  74. 'The amount of data written to the transaction'
  75. . ' log before a checkpoint is performed.'
  76. . ' The default value is 24MB.'
  77. ),
  78. 'type' => PMA_ENGINE_DETAILS_TYPE_SIZE,
  79. ],
  80. 'pbxt_data_log_threshold' => [
  81. 'title' => __('Data log threshold'),
  82. 'desc' => __(
  83. 'The maximum size of a data log file. The default'
  84. . ' value is 64MB. PBXT can create a maximum of 32000 data'
  85. . ' logs, which are used by all tables. So the value of'
  86. . ' this variable can be increased to increase the total'
  87. . ' amount of data that can be stored in the database.'
  88. ),
  89. 'type' => PMA_ENGINE_DETAILS_TYPE_SIZE,
  90. ],
  91. 'pbxt_garbage_threshold' => [
  92. 'title' => __('Garbage threshold'),
  93. 'desc' => __(
  94. 'The percentage of garbage in a data log file'
  95. . ' before it is compacted. This is a value between 1 and'
  96. . ' 99. The default is 50.'
  97. ),
  98. 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
  99. ],
  100. 'pbxt_log_buffer_size' => [
  101. 'title' => __('Log buffer size'),
  102. 'desc' => __(
  103. 'The size of the buffer used when writing a data'
  104. . ' log. The default is 256MB. The engine allocates one'
  105. . ' buffer per thread, but only if the thread is required'
  106. . ' to write a data log.'
  107. ),
  108. 'type' => PMA_ENGINE_DETAILS_TYPE_SIZE,
  109. ],
  110. 'pbxt_data_file_grow_size' => [
  111. 'title' => __('Data file grow size'),
  112. 'desc' => __('The grow size of the handle data (.xtd) files.'),
  113. 'type' => PMA_ENGINE_DETAILS_TYPE_SIZE,
  114. ],
  115. 'pbxt_row_file_grow_size' => [
  116. 'title' => __('Row file grow size'),
  117. 'desc' => __('The grow size of the row pointer (.xtr) files.'),
  118. 'type' => PMA_ENGINE_DETAILS_TYPE_SIZE,
  119. ],
  120. 'pbxt_log_file_count' => [
  121. 'title' => __('Log file count'),
  122. 'desc' => __(
  123. 'This is the number of transaction log files'
  124. . ' (pbxt/system/xlog*.xt) the system will maintain. If the'
  125. . ' number of logs exceeds this value then old logs will be'
  126. . ' deleted, otherwise they are renamed and given the next'
  127. . ' highest number.'
  128. ),
  129. 'type' => PMA_ENGINE_DETAILS_TYPE_NUMERIC,
  130. ],
  131. ];
  132. }
  133. /**
  134. * returns the pbxt engine specific handling for
  135. * PMA_ENGINE_DETAILS_TYPE_SIZE variables.
  136. *
  137. * @param int|string $formatted_size the size expression (for example 8MB)
  138. *
  139. * @return array the formatted value and its unit
  140. */
  141. public function resolveTypeSize($formatted_size)
  142. {
  143. if (is_string($formatted_size) && preg_match('/^[0-9]+[a-zA-Z]+$/', $formatted_size)) {
  144. $value = Util::extractValueFromFormattedSize(
  145. $formatted_size
  146. );
  147. } else {
  148. $value = $formatted_size;
  149. }
  150. return Util::formatByteDown($value);
  151. }
  152. //--------------------
  153. /**
  154. * Get information about pages
  155. *
  156. * @return array Information about pages
  157. */
  158. public function getInfoPages()
  159. {
  160. $pages = [];
  161. $pages['Documentation'] = __('Documentation');
  162. return $pages;
  163. }
  164. //--------------------
  165. /**
  166. * Get content of documentation page
  167. *
  168. * @return string
  169. */
  170. public function getPageDocumentation()
  171. {
  172. return '<p>' . sprintf(
  173. __(
  174. 'Documentation and further information about PBXT'
  175. . ' can be found on the %sPrimeBase XT Home Page%s.'
  176. ),
  177. '<a href="' . Core::linkURL('https://mariadb.com/kb/en/mariadb/about-pbxt/')
  178. . '" rel="noopener noreferrer" target="_blank">',
  179. '</a>'
  180. )
  181. . '</p>' . "\n";
  182. }
  183. }