aboutsummaryrefslogtreecommitdiff
path: root/app/services
diff options
context:
space:
mode:
Diffstat (limited to 'app/services')
-rw-r--r--app/services/color-service.ts50
-rw-r--r--app/services/help-service.ts27
-rw-r--r--app/services/plan-service.ts8
3 files changed, 84 insertions, 1 deletions
diff --git a/app/services/color-service.ts b/app/services/color-service.ts
new file mode 100644
index 0000000..37183c0
--- /dev/null
+++ b/app/services/color-service.ts
@@ -0,0 +1,50 @@
+export class ColorService {
+ /**
+ * http://stackoverflow.com/questions/2353211/hsl-to-rgb-color-conversion
+ *
+ * Converts an HSL color value to RGB. Conversion formula
+ * adapted from http://en.wikipedia.org/wiki/HSL_color_space.
+ * Assumes h, s, and l are contained in the set [0, 1] and
+ * returns r, g, and b in the set [0, 255].
+ *
+ * @param Number h The hue
+ * @param Number s The saturation
+ * @param Number l The lightness
+ * @return Array The RGB representation
+ */
+ hslToRgb(h, s, l) {
+ var r, g, b;
+
+ if (s == 0) {
+ r = g = b = l; // achromatic
+ } else {
+ function hue2rgb(p, q, t) {
+ if (t < 0) t += 1;
+ if (t > 1) t -= 1;
+ if (t < 1 / 6) return p + (q - p) * 6 * t;
+ if (t < 1 / 2) return q;
+ if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
+ return p;
+ }
+
+ var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
+ var p = 2 * l - q;
+ r = hue2rgb(p, q, h + 1 / 3);
+ g = hue2rgb(p, q, h);
+ b = hue2rgb(p, q, h - 1 / 3);
+ }
+
+ return [Math.floor(r * 255), Math.floor(g * 255), Math.floor(b * 255)];
+ }
+
+ // convert a number to a color using hsl
+ numberToColorHsl(i) {
+ // as the function expects a value between 0 and 1, and red = 0° and green = 120°
+ // we convert the input to the appropriate hue value
+ var hue = i * 100 * 1.2 / 360;
+ // we convert hsl to rgb (saturation 100%, lightness 50%)
+ var rgb = this.hslToRgb(hue, .9, .4);
+ // we format to css value and return
+ return 'rgb(' + rgb[0] + ',' + rgb[1] + ',' + rgb[2] + ')';
+ }
+}
diff --git a/app/services/help-service.ts b/app/services/help-service.ts
new file mode 100644
index 0000000..11bb4c0
--- /dev/null
+++ b/app/services/help-service.ts
@@ -0,0 +1,27 @@
+/// <reference path="lodash.d.ts" />
+
+export class HelpService {
+ getNodeTypeDescription(nodeType: string) {
+ return NODE_DESCRIPTIONS[nodeType.toUpperCase()];
+ }
+}
+
+export var NODE_DESCRIPTIONS = {
+ "LIMIT":"returns a specified number of rows from a record set.",
+ "SORT": "sorts a record set based on the specified sort key.",
+ "NESTED LOOP": `merges two record sets by looping through every record in the first set and
+ tries to find a match in the second set. All matching records are returned.`,
+ "MERGE JOIN": `merges two record sets by first sorting them on a <strong>join key</strong>.`,
+ "AGGREGATE": `groups records together based on a GROUP BY or aggregate function (like <code>sum()</code>).`,
+ "HASHAGGREGATE": `groups records together based on a GROUP BY or aggregate function (like sum()). Hash Aggregate uses
+ a hash to first organize the records by a key.`,
+ "SEQ SCAN": `finds relevant records by sequentially scanning the table. Seq Scans perform a single read operation
+ (only the table is read).`,
+ "INDEX SCAN": `finds relevant records based on an <strong>Index</strong>. Index Scans perform 2 read operations: one to
+ read the index and another to read the actual value from the table.`,
+ "INDEX ONLY SCAN": `finds relevant records based on an <strong>Index</strong>. Index Only Scans perform a single read operation
+ from the index and do not read from the corresponding table.`,
+ "BITMAP HEAP SCAN": "scans all pages returned by the <strong>Bitmap Index Scan</strong> for relevant rows.",
+ "BITMAP INDEX SCAN": `uses a <strong>Bitmap Index</strong> (index which uses 1 bit per page) to find all relevant pages.
+ Results of this node are fed to the <strong>Bitmap Heap Scan</strong>.`
+}
diff --git a/app/services/plan-service.ts b/app/services/plan-service.ts
index 5d7dc3c..2e56bac 100644
--- a/app/services/plan-service.ts
+++ b/app/services/plan-service.ts
@@ -12,7 +12,13 @@ export class PlanService {
ACTUAL_LOOPS_PROP: string = 'Actual Loops';
TOTAL_COST_PROP: string = 'Total Cost';
PLANS_PROP: string = 'Plans';
-
+ RELATION_NAME_PROP: string = 'Relation Name';
+ SCHEMA_PROP: string = 'Schema';
+ ALIAS_PROP: string = 'Alias';
+ GROUP_KEY_PROP: string = 'Group Key';
+ SORT_KEY_PROP: string = 'Sort Key';
+ JOIN_TYPE_PROP: string = 'Join Type';
+ INDEX_NAME_PROP: string = 'Index Name';
// computed by pev
COMPUTED_TAGS_PROP: string = "*Tags";