Skip to content

Commit

Permalink
WAL bytes are not kilobytes
Browse files Browse the repository at this point in the history
As opposed to 'sort space used'
  • Loading branch information
pgiraud committed Oct 13, 2020
1 parent 87da22d commit d8f3b5a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,16 @@ export enum NodeProp {
export enum PropType {
blocks,
boolean,
bytes,
cost,
duration,
estimateDirection,
factor,
increment,
json,
kilobytes,
list,
rows,
bytes,
}

export const nodePropTypes: any = {};
Expand All @@ -156,7 +157,7 @@ nodePropTypes[NodeProp.STARTUP_COST] = PropType.cost;
nodePropTypes[NodeProp.TOTAL_COST] = PropType.cost;
nodePropTypes[NodeProp.PARALLEL_AWARE] = PropType.boolean;
nodePropTypes[NodeProp.WORKERS] = PropType.json;
nodePropTypes[NodeProp.SORT_SPACE_USED] = PropType.bytes;
nodePropTypes[NodeProp.SORT_SPACE_USED] = PropType.kilobytes;
nodePropTypes[NodeProp.ROWS_REMOVED_BY_FILTER] = PropType.rows;
nodePropTypes[NodeProp.ROWS_REMOVED_BY_JOIN_FILTER] = PropType.rows;
nodePropTypes[NodeProp.HEAP_FETCHES] = PropType.rows;
Expand Down
8 changes: 7 additions & 1 deletion src/filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,14 @@ export function truncate(text: string, length: number, clamp: string): string {
return text.length > length ? text.slice(0, length) + clamp : text;
}

export function bytes(value: number): string {
export function kilobytes(value: number): string {
return formatBytes(value * 1024);
}

export function bytes(value: number): string {
return formatBytes(value);
}

export function formatBytes(value: number, decimals = 2) {
const k = 1024;
const dm = decimals < 0 ? 0 : decimals;
Expand Down Expand Up @@ -122,6 +126,8 @@ export function formatNodeProp(key: string, value: any, detail: boolean): string
return JSON.stringify(value, null, 2);
} else if (nodePropTypes[key] === PropType.bytes) {
return bytes(value);
} else if (nodePropTypes[key] === PropType.kilobytes) {
return kilobytes(value);
} else if (nodePropTypes[key] === PropType.blocks) {
return blocks(value);
} else if (nodePropTypes[key] === PropType.list) {
Expand Down

0 comments on commit d8f3b5a

Please sign in to comment.