(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(require("apache-arrow"));
else if(typeof define === 'function' && define.amd)
define(["apache-arrow"], factory);
else {
var a = typeof exports === 'object' ? factory(require("apache-arrow")) : factory(root["Arrow"]);
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
}
})(this, function(__WEBPACK_EXTERNAL_MODULE__2003__) {
return /******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({
/***/ 2190:
/***/ ((module) => {
/**
* Array#filter.
*
* @param {Array} arr
* @param {Function} fn
* @param {Object=} self
* @return {Array}
* @throw TypeError
*/
module.exports = function (arr, fn, self) {
if (arr.filter) return arr.filter(fn, self);
if (void 0 === arr || null === arr) throw new TypeError;
if ('function' != typeof fn) throw new TypeError;
var ret = [];
for (var i = 0; i < arr.length; i++) {
if (!hasOwn.call(arr, i)) continue;
var val = arr[i];
if (fn.call(self, val, i, arr)) ret.push(val);
}
return ret;
};
var hasOwn = Object.prototype.hasOwnProperty;
/***/ }),
/***/ 6314:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
"use strict";
var filter = __webpack_require__(2190);
module.exports = function availableTypedArrays() {
return filter([
'BigInt64Array',
'BigUint64Array',
'Float32Array',
'Float64Array',
'Int16Array',
'Int32Array',
'Int8Array',
'Uint16Array',
'Uint32Array',
'Uint8Array',
'Uint8ClampedArray'
], function (typedArray) {
return typeof __webpack_require__.g[typedArray] === 'function';
});
};
/***/ }),
/***/ 7123:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "DbCon": () => /* binding */ DbCon,
/* harmony export */ "default": () => __WEBPACK_DEFAULT_EXPORT__,
/* harmony export */ "Client": () => /* reexport safe */ _thrift_Heavy_js__WEBPACK_IMPORTED_MODULE_5__.Client,
/* harmony export */ "Processor": () => /* reexport safe */ _thrift_Heavy_js__WEBPACK_IMPORTED_MODULE_5__.Processor
/* harmony export */ });
/* harmony import */ var eventemitter3__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(6729);
/* harmony import */ var eventemitter3__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(eventemitter3__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var apache_arrow__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2003);
/* harmony import */ var apache_arrow__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(apache_arrow__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var util__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(9539);
/* harmony import */ var util__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(util__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _thrift_common_types_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(2818);
/* harmony import */ var _thrift_common_types_js__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_thrift_common_types_js__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _thrift_heavy_types_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(2607);
/* harmony import */ var _thrift_heavy_types_js__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_thrift_heavy_types_js__WEBPACK_IMPORTED_MODULE_4__);
/* harmony import */ var _thrift_Heavy_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(4221);
/* harmony import */ var thrift__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(9262);
/* harmony import */ var _process_query_results__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(5141);
/* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(2033);
/* harmony reexport (unknown) */ var __WEBPACK_REEXPORT_OBJECT__ = {};
/* harmony reexport (unknown) */ for(const __WEBPACK_IMPORT_KEY__ in _thrift_common_types_js__WEBPACK_IMPORTED_MODULE_3__) if(["default","DbCon","Client","Processor"].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = () => _thrift_common_types_js__WEBPACK_IMPORTED_MODULE_3__[__WEBPACK_IMPORT_KEY__]
/* harmony reexport (unknown) */ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
/* harmony import */ var _thrift_completion_hints_types__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(4494);
/* harmony import */ var _thrift_completion_hints_types__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(_thrift_completion_hints_types__WEBPACK_IMPORTED_MODULE_9__);
/* harmony reexport (unknown) */ var __WEBPACK_REEXPORT_OBJECT__ = {};
/* harmony reexport (unknown) */ for(const __WEBPACK_IMPORT_KEY__ in _thrift_completion_hints_types__WEBPACK_IMPORTED_MODULE_9__) if(["default","DbCon","Client","Processor"].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = () => _thrift_completion_hints_types__WEBPACK_IMPORTED_MODULE_9__[__WEBPACK_IMPORT_KEY__]
/* harmony reexport (unknown) */ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
/* harmony import */ var _thrift_extension_functions_types__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(1396);
/* harmony import */ var _thrift_extension_functions_types__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(_thrift_extension_functions_types__WEBPACK_IMPORTED_MODULE_10__);
/* harmony reexport (unknown) */ var __WEBPACK_REEXPORT_OBJECT__ = {};
/* harmony reexport (unknown) */ for(const __WEBPACK_IMPORT_KEY__ in _thrift_extension_functions_types__WEBPACK_IMPORTED_MODULE_10__) if(["default","DbCon","Client","Processor"].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = () => _thrift_extension_functions_types__WEBPACK_IMPORTED_MODULE_10__[__WEBPACK_IMPORT_KEY__]
/* harmony reexport (unknown) */ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
/* harmony reexport (unknown) */ var __WEBPACK_REEXPORT_OBJECT__ = {};
/* harmony reexport (unknown) */ for(const __WEBPACK_IMPORT_KEY__ in _thrift_heavy_types_js__WEBPACK_IMPORTED_MODULE_4__) if(["default","DbCon","Client","Processor"].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = () => _thrift_heavy_types_js__WEBPACK_IMPORTED_MODULE_4__[__WEBPACK_IMPORT_KEY__]
/* harmony reexport (unknown) */ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
/* harmony import */ var _thrift_serialized_result_set_types__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(3962);
/* harmony import */ var _thrift_serialized_result_set_types__WEBPACK_IMPORTED_MODULE_11___default = /*#__PURE__*/__webpack_require__.n(_thrift_serialized_result_set_types__WEBPACK_IMPORTED_MODULE_11__);
/* harmony reexport (unknown) */ var __WEBPACK_REEXPORT_OBJECT__ = {};
/* harmony reexport (unknown) */ for(const __WEBPACK_IMPORT_KEY__ in _thrift_serialized_result_set_types__WEBPACK_IMPORTED_MODULE_11__) if(["default","DbCon","Client","Processor"].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = () => _thrift_serialized_result_set_types__WEBPACK_IMPORTED_MODULE_11__[__WEBPACK_IMPORT_KEY__]
/* harmony reexport (unknown) */ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
/* provided dependency */ var Buffer = __webpack_require__(8764)["Buffer"];
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var COMPRESSION_LEVEL_DEFAULT = 3;
function arrayify(maybeArray) {
return Array.isArray(maybeArray) ? maybeArray : [maybeArray];
} // custom version of XHRConnection which can set `withCredentials` for CORS
function CustomXHRConnection(host, port, opts) {
var _this = this;
thrift__WEBPACK_IMPORTED_MODULE_6__.XHRConnection.call(this, host, port, opts);
if (opts.headers["Content-Type"] === "application/vnd.apache.thrift.binary") {
// this is copy/paste from thrift with the noted changes below
this.flush = function () {
if (_this.url === undefined || _this.url === "") {
return _this.send_buf;
}
var xreq = _this.getXmlHttpRequestObject(); // removed overrideMimeType since we're expecting binary data
// added responseType
xreq.responseType = "arraybuffer";
xreq.onreadystatechange = function () {
if (xreq.readyState === 4 && xreq.status === 200) {
// changed responseText -> response
_this.setRecvBuffer(xreq.response);
}
};
xreq.open("POST", _this.url, true);
Object.keys(_this.headers).forEach(function (headerKey) {
xreq.setRequestHeader(headerKey, _this.headers[headerKey]);
});
xreq.send(_this.send_buf);
};
}
}
util__WEBPACK_IMPORTED_MODULE_2___default().inherits(CustomXHRConnection, thrift__WEBPACK_IMPORTED_MODULE_6__.XHRConnection);
CustomXHRConnection.prototype.getXmlHttpRequestObject = function () {
var obj = thrift__WEBPACK_IMPORTED_MODULE_6__.XHRConnection.prototype.getXmlHttpRequestObject.call(this);
obj.withCredentials = CustomXHRConnection.withCredentials;
return obj;
}; // Custom version of TJSONProtocol - thrift 0.14.0 throws an exception if
// anything other than a string or Buffer is passed to writeString. For
// example: we use a number for a nonce that is defined as a string type. So,
// let's just coerce things to a string.
function CustomTJSONProtocol() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
thrift__WEBPACK_IMPORTED_MODULE_6__.TJSONProtocol.apply(this, args);
}
util__WEBPACK_IMPORTED_MODULE_2___default().inherits(CustomTJSONProtocol, thrift__WEBPACK_IMPORTED_MODULE_6__.TJSONProtocol);
CustomTJSONProtocol.prototype.writeString = function (arg) {
if (!(arg instanceof Buffer)) {
arg = String(arg);
}
return thrift__WEBPACK_IMPORTED_MODULE_6__.TJSONProtocol.prototype.writeString.call(this, arg);
}; // Additionally, the browser version of connector relied on thrift's old
// behavior of returning a Number for a 64-bit int. Technically, javascript
// does not have 64-bits of precision in a Number, so this can end up giving
// incorrect results.
//
// Lastly, the browser version relied on thrift returning a string from a
// binary type.
if (true) {
CustomTJSONProtocol.prototype.readI64 = function () {
var n = thrift__WEBPACK_IMPORTED_MODULE_6__.TJSONProtocol.prototype.readI64.call(this);
return n.toNumber(true);
};
CustomTJSONProtocol.prototype.readBinary = function () {
return thrift__WEBPACK_IMPORTED_MODULE_6__.TJSONProtocol.prototype.readString.call(this);
};
} // Custom version of the binary protocol to override writeString, readI64, and
// readBinary as above.
function CustomBinaryProtocol() {
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
thrift__WEBPACK_IMPORTED_MODULE_6__.TBinaryProtocol.apply(this, args);
}
util__WEBPACK_IMPORTED_MODULE_2___default().inherits(CustomBinaryProtocol, thrift__WEBPACK_IMPORTED_MODULE_6__.TBinaryProtocol);
CustomBinaryProtocol.prototype.writeString = function (arg) {
if (!(arg instanceof Buffer)) {
arg = String(arg);
}
return thrift__WEBPACK_IMPORTED_MODULE_6__.TBinaryProtocol.prototype.writeString.call(this, arg);
};
if (true) {
CustomBinaryProtocol.prototype.readI64 = function () {
var n = thrift__WEBPACK_IMPORTED_MODULE_6__.TBinaryProtocol.prototype.readI64.call(this);
return n.toNumber(true);
};
CustomBinaryProtocol.prototype.readBinary = function () {
return thrift__WEBPACK_IMPORTED_MODULE_6__.TBinaryProtocol.prototype.readBinary.call(this).toString("base64");
};
}
function buildClient(url, useBinaryProtocol) {
var urlObj = new URL(url);
var protocol = urlObj.protocol;
var hostname = urlObj.hostname;
var port = urlObj.port;
if (port === "") {
port = protocol === "https:" ? "443" : "80";
}
var client = null;
if (false) { var connection; } else {
var _connection = new CustomXHRConnection(hostname, port, {
transport: thrift__WEBPACK_IMPORTED_MODULE_6__.TBufferedTransport,
protocol: useBinaryProtocol ? CustomBinaryProtocol : CustomTJSONProtocol,
path: "/",
headers: {
"Content-Type": "application/vnd.apache.thrift.".concat(useBinaryProtocol ? "binary" : "json")
},
https: protocol === "https:"
});
_connection.on("error", console.error); // eslint-disable-line no-console
client = (0,thrift__WEBPACK_IMPORTED_MODULE_6__.createXHRClient)(_thrift_Heavy_js__WEBPACK_IMPORTED_MODULE_5__, _connection);
}
return client;
}
var DbCon = /*#__PURE__*/function () {
function DbCon() {
var _this2 = this;
_classCallCheck(this, DbCon);
_defineProperty(this, "updateQueryTimes", function (conId, queryId, estimatedQueryTime, execution_time_ms) {
_this2.queryTimes[queryId] = execution_time_ms;
});
_defineProperty(this, "events", new (eventemitter3__WEBPACK_IMPORTED_MODULE_0___default())());
_defineProperty(this, "EVENT_NAMES", {
ERROR: "error",
METHOD_CALLED: "method-called"
});
_defineProperty(this, "handleErrors", function (method) {
return function () {
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
args[_key3] = arguments[_key3];
}
return method.apply(_this2, args)["catch"](function (error) {
_this2.events.emit(_this2.EVENT_NAMES.ERROR, error);
throw error;
});
};
});
_defineProperty(this, "callbackify", function (method, arity) {
return function () {
var callback = null;
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
args[_key4] = arguments[_key4];
}
if (args.length === arity + 1) {
callback = args.pop();
}
var promise = _this2[method].apply(_this2, args);
if (callback) {
promise["catch"](function (err) {
return callback(err);
}).then(function (res) {
return callback(null, res);
});
}
return promise;
};
});
_defineProperty(this, "overSingleClient", "SINGLE_CLIENT");
_defineProperty(this, "overAllClients", "ALL_CLIENTS");
_defineProperty(this, "wrapThrift", function (methodName, overClients, processArgs) {
return function () {
if (_this2._sessionId) {
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
args[_key5] = arguments[_key5];
}
var processedArgs = processArgs(args);
if (true) {
_this2.events.emit(_this2.EVENT_NAMES.METHOD_CALLED, methodName);
}
if (overClients === _this2.overSingleClient) {
return _this2._client[0][methodName].apply(_this2._client[0], [_this2._sessionId[0]].concat(processedArgs));
} else {
return Promise.all(_this2._client.map(function (client, index) {
return client[methodName].apply(client, [_this2._sessionId[index]].concat(processedArgs));
}));
}
} else {
return Promise.reject(new Error("You are not connected to a server. Try running the connect method first."));
}
};
});
_defineProperty(this, "connect", this.callbackify("connectAsync", 0));
_defineProperty(this, "disconnectAsync", this.handleErrors(function () {
return Promise.all(_this2._client.map(function (client, c) {
return client.disconnect(_this2._sessionId[c])["catch"](function (error) {
// ignore timeout errors
if (error && !_this2.isTimeoutError(error)) {
throw error;
}
});
})).then(function () {
_this2._sessionId = null;
_this2._client = null;
_this2._numConnections = 0;
_this2.serverPingTimes = null;
return _this2;
});
}));
_defineProperty(this, "disconnect", this.callbackify("disconnectAsync", 0));
_defineProperty(this, "getStatusAsync", this.handleErrors(this.wrapThrift("get_status", this.overSingleClient, function (args) {
return args;
})));
_defineProperty(this, "getStatus", this.callbackify("getStatusAsync", 0));
_defineProperty(this, "getHardwareInfoAsync", this.handleErrors(this.wrapThrift("get_hardware_info", this.overSingleClient, function (args) {
return args;
})));
_defineProperty(this, "getHardwareInfo", this.callbackify("getHardwareInfoAsync", 0));
_defineProperty(this, "getFirstGeoFileInArchiveAsync", this.handleErrors(this.wrapThrift("get_first_geo_file_in_archive", this.overSingleClient, function (args) {
return args;
})));
_defineProperty(this, "getFilesInArchiveAsync", this.handleErrors(this.wrapThrift("get_all_files_in_archive", this.overSingleClient, function (args) {
return args;
})));
_defineProperty(this, "getUsersAsync", this.handleErrors(this.wrapThrift("get_users", this.overSingleClient, function (args) {
return args;
})));
_defineProperty(this, "importTableStatusAsync", this.handleErrors(this.wrapThrift("import_table_status", this.overSingleClient, function (args) {
return args;
})));
_defineProperty(this, "getRolesAsync", this.handleErrors(this.wrapThrift("get_roles", this.overSingleClient, function (args) {
return args;
})));
_defineProperty(this, "getDashboardsAsync", this.handleErrors(this.wrapThrift("get_dashboards", this.overSingleClient, function (args) {
return args;
})));
_defineProperty(this, "getDashboardAsync", this.handleErrors(this.wrapThrift("get_dashboard", this.overSingleClient, function (args) {
return args;
})));
_defineProperty(this, "createDashboardAsync", this.handleErrors(this.wrapThrift("create_dashboard", this.overAllClients, function (args) {
return args;
})));
_defineProperty(this, "replaceDashboardAsync", this.handleErrors(this.wrapThrift("replace_dashboard", this.overAllClients, function (args) {
return args;
})));
_defineProperty(this, "deleteDashboardAsync", this.handleErrors(this.wrapThrift("delete_dashboard", this.overAllClients, function (args) {
return args;
})));
_defineProperty(this, "deleteDashboardsAsync", this.handleErrors(this.wrapThrift("delete_dashboards", this.overAllClients, function (args) {
return args;
})));
_defineProperty(this, "shareDashboardAsync", this.handleErrors(this.wrapThrift("share_dashboard", this.overAllClients, function (_ref) {
var _ref2 = _slicedToArray(_ref, 4),
dashboardId = _ref2[0],
groups = _ref2[1],
objects = _ref2[2],
permissions = _ref2[3];
return [dashboardId, groups, objects, new _thrift_heavy_types_js__WEBPACK_IMPORTED_MODULE_4__.TDashboardPermissions(permissions)];
})));
_defineProperty(this, "shareDashboardsAsync", this.handleErrors(this.wrapThrift("share_dashboards", this.overAllClients, function (_ref3) {
var _ref4 = _slicedToArray(_ref3, 3),
dashboardIds = _ref4[0],
groups = _ref4[1],
permissions = _ref4[2];
return [dashboardIds, groups, new _thrift_heavy_types_js__WEBPACK_IMPORTED_MODULE_4__.TDashboardPermissions(permissions)];
})));
_defineProperty(this, "unshareDashboardAsync", this.handleErrors(this.wrapThrift("unshare_dashboard", this.overAllClients, function (_ref5) {
var _ref6 = _slicedToArray(_ref5, 4),
dashboardId = _ref6[0],
groups = _ref6[1],
objects = _ref6[2],
permissions = _ref6[3];
return [dashboardId, groups, objects, new _thrift_heavy_types_js__WEBPACK_IMPORTED_MODULE_4__.TDashboardPermissions(permissions)];
})));
_defineProperty(this, "unshareDashboardsAsync", this.handleErrors(this.wrapThrift("unshare_dashboards", this.overAllClients, function (_ref7) {
var _ref8 = _slicedToArray(_ref7, 3),
dashboardIds = _ref8[0],
groups = _ref8[1],
permissions = _ref8[2];
return [dashboardIds, groups, new _thrift_heavy_types_js__WEBPACK_IMPORTED_MODULE_4__.TDashboardPermissions(permissions)];
})));
_defineProperty(this, "getDashboardGranteesAsync", this.handleErrors(this.wrapThrift("get_dashboard_grantees", this.overSingleClient, function (args) {
return args;
})));
_defineProperty(this, "getDbObjectsForGranteeAsync", this.handleErrors(this.wrapThrift("get_db_objects_for_grantee", this.overSingleClient, function (args) {
return args;
})));
_defineProperty(this, "getDbObjectPrivsAsync", this.handleErrors(this.wrapThrift("get_db_object_privs", this.overSingleClient, function (_ref9) {
var _ref10 = _slicedToArray(_ref9, 2),
objectName = _ref10[0],
type = _ref10[1];
return [objectName, _thrift_heavy_types_js__WEBPACK_IMPORTED_MODULE_4__.TDBObjectType[type]];
})));
_defineProperty(this, "getAllRolesForUserAsync", this.handleErrors(this.wrapThrift("get_all_roles_for_user", this.overSingleClient, function (args) {
return args;
})));
_defineProperty(this, "getAllEffectiveRolesForUserAsync", this.handleErrors(this.wrapThrift("get_all_effective_roles_for_user", this.overSingleClient, function (args) {
return args;
})));
_defineProperty(this, "hasObjectPrivilegesAsync", this.handleErrors(this.wrapThrift("has_object_privilege", this.overSingleClient, function (args) {
return args;
})));
_defineProperty(this, "hasDbPrivilegesAsync", function (granteeName, dbName, dbPrivs) {
return _this2.hasObjectPrivilegesAsync(granteeName, dbName, _thrift_heavy_types_js__WEBPACK_IMPORTED_MODULE_4__.TDBObjectType.DatabaseDBObjectType, new _thrift_heavy_types_js__WEBPACK_IMPORTED_MODULE_4__.TDBObjectPermissions({
database_permissions_: new _thrift_heavy_types_js__WEBPACK_IMPORTED_MODULE_4__.TDatabasePermissions(dbPrivs)
}));
});
_defineProperty(this, "getSessionInfoAsync", this.handleErrors(this.wrapThrift("get_session_info", this.overSingleClient, function (args) {
return args;
})));
_defineProperty(this, "createCustomExpressionAsync", this.handleErrors(this.wrapThrift("create_custom_expression", this.overSingleClient, function (args) {
return args;
})));
_defineProperty(this, "getCustomExpressionsAsync", this.handleErrors(this.wrapThrift("get_custom_expressions", this.overSingleClient, function (args) {
return args;
})));
_defineProperty(this, "updateCustomExpressionAsync", this.handleErrors(this.wrapThrift("update_custom_expression", this.overSingleClient, function (args) {
return args;
})));
_defineProperty(this, "deleteCustomExpressionsAsync", this.handleErrors(this.wrapThrift("delete_custom_expressions", this.overSingleClient, function (args) {
return args;
})));
_defineProperty(this, "detectColumnTypesAsync", this.handleErrors(function (filename, copyParams) {
var detectColumnTypes = _this2.wrapThrift("detect_column_types", _this2.overSingleClient, function () {
return [filename, _helpers__WEBPACK_IMPORTED_MODULE_8__/* .convertObjectToThriftCopyParams */ .Dq(copyParams)];
});
return detectColumnTypes().then(function (res) {
_this2.importerRowDesc = res.row_set.row_desc;
return res;
});
}));
_defineProperty(this, "queryAsync", this.handleErrors(function (query, options) {
var columnarResults = true;
var eliminateNullRows = false;
var queryId = null;
var returnTiming = false;
var limit = -1;
var curNonce = (_this2._nonce++).toString();
if (options) {
columnarResults = options.hasOwnProperty("columnarResults") ? options.columnarResults : columnarResults;
eliminateNullRows = options.hasOwnProperty("eliminateNullRows") ? options.eliminateNullRows : eliminateNullRows;
queryId = options.hasOwnProperty("queryId") ? options.queryId : queryId;
returnTiming = options.hasOwnProperty("returnTiming") ? options.returnTiming : returnTiming;
limit = options.hasOwnProperty("limit") ? options.limit : limit;
curNonce = options.hasOwnProperty("logValues") ? _typeof(options.logValues) === "object" ? JSON.stringify(options.logValues) : options.logValues : curNonce;
}
var lastQueryTime = queryId in _this2.queryTimes ? _this2.queryTimes[queryId] : _this2.DEFAULT_QUERY_TIME;
var conId = 0;
var processResultsOptions = {
returnTiming: returnTiming,
eliminateNullRows: eliminateNullRows,
query: query,
queryId: queryId,
conId: conId,
estimatedQueryTime: lastQueryTime,
startTime: Date.now()
};
var AT_MOST_N = -1;
var sqlExecute = _this2.wrapThrift("sql_execute", _this2.overSingleClient, function (args) {
return args;
});
var runQuery = function runQuery() {
return sqlExecute(query, columnarResults, curNonce, limit, AT_MOST_N)["catch"](function (err) {
if (err.name === "NetworkError") {
_this2.removeConnection(0);
if (_this2._numConnections === 0) {
err.msg = "No remaining database connections";
throw err;
}
return runQuery();
}
throw err;
});
};
return _this2.processResults(processResultsOptions, runQuery());
}));
_defineProperty(this, "query", this.callbackify("queryAsync", 2));
_defineProperty(this, "queryDFAsync", this.handleErrors(function (query, options) {
var deviceId = 0;
var limit = -1;
var sqlExecuteDF = _this2.wrapThrift("sql_execute_df", _this2.overSingleClient, function () {
return [query, _thrift_common_types_js__WEBPACK_IMPORTED_MODULE_3__.TDeviceType.CPU, deviceId, limit, _thrift_heavy_types_js__WEBPACK_IMPORTED_MODULE_4__.TArrowTransport.WIRE];
});
return sqlExecuteDF().then(function (data) {
if (_this2._logging) {
// eslint-disable-next-line no-console
console.log(query, "on Server", 0, "- Execution Time:", data.execution_time_ms, "ms");
}
var buf = Buffer.from(data.df_buffer, "base64");
var results = (0,apache_arrow__WEBPACK_IMPORTED_MODULE_1__.tableFromIPC)(buf);
if (options && Boolean(options.returnTiming)) {
results = {
results: results,
timing: {
execution_time_ms: data.execution_time_ms
}
};
}
return results;
});
}));
_defineProperty(this, "queryDF", this.callbackify("queryDFAsync", 2));
_defineProperty(this, "validateQuery", this.handleErrors(function (query) {
var sqlValidate = _this2.wrapThrift("sql_validate", _this2.overSingleClient, function (args) {
return args;
});
return sqlValidate(query).then(function (fields) {
var rowDict = fields.reduce(function (accum, value) {
accum[value.col_name] = value;
return accum;
}, {});
return _this2.convertFromThriftTypes(rowDict);
});
}));
_defineProperty(this, "getTablesAsync", this.handleErrors(function () {
var getTables = _this2.wrapThrift("get_tables", _this2.overSingleClient, function (args) {
return args;
});
return getTables().then(function (tables) {
return tables.map(function (table) {
return {
name: table,
label: "obs"
};
});
});
}));
_defineProperty(this, "getTables", this.callbackify("getTablesAsync", 0));
_defineProperty(this, "getTablesWithMetaAsync", this.handleErrors(function () {
var getTablesMeta = _this2.wrapThrift("get_tables_meta", _this2.overSingleClient, function (args) {
return args;
});
return getTablesMeta().then(function (tables) {
return tables.map(function (table) {
return {
name: table.table_name,
num_cols: Number(table.num_cols.toString()),
col_datum_types: table.col_types.map(function (type) {
return _this2._datumEnum[type.type];
}),
is_view: table.is_view,
is_replicated: table.is_replicated,
shard_count: Number(table.shard_count.toString()),
max_rows: isFinite(table.max_rows) ? Number(table.max_rows.toString()) : -1
};
});
});
}));
_defineProperty(this, "getTablesWithMeta", this.callbackify("getTablesWithMetaAsync", 0));
_defineProperty(this, "getTablesMetaAsync", this.handleErrors(this.wrapThrift("get_tables_meta", this.overSingleClient, function (args) {
return args;
})));
_defineProperty(this, "getTablesMeta", this.callbackify("getTablesMetaAsync", 0));
_defineProperty(this, "getTableEpochByNameAsync", this.handleErrors(this.wrapThrift("get_table_epoch_by_name", this.overSingleClient, function (args) {
return args;
})));
_defineProperty(this, "getTableEpochByName", this.callbackify("getTableEpochByNameAsync", 0));
_defineProperty(this, "getTableFunctionNamesAsync", this.handleErrors(this.wrapThrift("get_table_function_names", this.overSingleClient, function (args) {
return args;
})));
_defineProperty(this, "getTableFunctionNames", this.callbackify("getTableFunctionNamesAsync", 0));
_defineProperty(this, "getRuntimeTableFunctionNamesAsync", this.handleErrors(this.wrapThrift("get_runtime_table_function_names", this.overSingleClient, function (args) {
return args;
})));
_defineProperty(this, "getRuntimeTableFunctionNames", this.callbackify("getRuntimeTableFunctionNamesAsync", 0));
_defineProperty(this, "getTableFunctionDetailsAsync", this.handleErrors(this.wrapThrift("get_table_function_details", this.overSingleClient, function (args) {
return args;
})));
_defineProperty(this, "getTableFunctionDetails", this.callbackify("getTableFunctionDetailsAsync", 0));
_defineProperty(this, "getCompletionHintsAsync", this.handleErrors(this.wrapThrift("get_completion_hints", this.overSingleClient, function (_ref11) {
var _ref12 = _slicedToArray(_ref11, 2),
queryString = _ref12[0],
cursor = _ref12[1].cursor;
return [queryString, cursor];
})));
_defineProperty(this, "getCompletionHints", this.callbackify("getCompletionHintsAsync", 2));
_defineProperty(this, "buildTFileTypeMap", function () {
for (var key in _thrift_heavy_types_js__WEBPACK_IMPORTED_MODULE_4__.TFileType) {
if (_thrift_heavy_types_js__WEBPACK_IMPORTED_MODULE_4__.TFileType.hasOwnProperty(key)) {
_this2.TFileTypeMap[_thrift_heavy_types_js__WEBPACK_IMPORTED_MODULE_4__.TFileType[key]] = key;
}
}
});
_defineProperty(this, "buildTImportHeaderRowMap", function () {
for (var key in _thrift_heavy_types_js__WEBPACK_IMPORTED_MODULE_4__.TImportHeaderRow) {
if (_thrift_heavy_types_js__WEBPACK_IMPORTED_MODULE_4__.TImportHeaderRow.hasOwnProperty(key)) {
_this2.TImportHeaderRowMap[_thrift_heavy_types_js__WEBPACK_IMPORTED_MODULE_4__.TImportHeaderRow[key]] = key;
}
}
});
_defineProperty(this, "buildTEncodingTypeMap", function () {
for (var encoding in _thrift_common_types_js__WEBPACK_IMPORTED_MODULE_3__.TEncodingType) {
if (_thrift_common_types_js__WEBPACK_IMPORTED_MODULE_3__.TEncodingType.hasOwnProperty(encoding)) {
_this2.TEncodingTypeMap[_thrift_common_types_js__WEBPACK_IMPORTED_MODULE_3__.TEncodingType[encoding]] = encoding;
}
}
});
_defineProperty(this, "buildTRasterPointTypeMap", function () {
for (var key in _thrift_heavy_types_js__WEBPACK_IMPORTED_MODULE_4__.TRasterPointType) {
if (_thrift_heavy_types_js__WEBPACK_IMPORTED_MODULE_4__.TRasterPointType.hasOwnProperty(key)) {
_this2.TRasterPointTypeMap[_thrift_heavy_types_js__WEBPACK_IMPORTED_MODULE_4__.TRasterPointType[key]] = key;
}
}
});
_defineProperty(this, "buildTRasterPointTransformMap", function () {
for (var key in _thrift_heavy_types_js__WEBPACK_IMPORTED_MODULE_4__.TRasterPointTransform) {
if (_thrift_heavy_types_js__WEBPACK_IMPORTED_MODULE_4__.TRasterPointTransform.hasOwnProperty(key)) {
_this2.TRasterPointTransformMap[_thrift_heavy_types_js__WEBPACK_IMPORTED_MODULE_4__.TRasterPointTransform[key]] = key;
}
}
});
_defineProperty(this, "buildTSourceTypeMap", function () {
for (var key in _thrift_heavy_types_js__WEBPACK_IMPORTED_MODULE_4__.TSourceType) {
if (_thrift_heavy_types_js__WEBPACK_IMPORTED_MODULE_4__.TSourceType.hasOwnProperty(key)) {
_this2.TSourceTypeMap[_thrift_heavy_types_js__WEBPACK_IMPORTED_MODULE_4__.TSourceType[key]] = key;
}
}
});
_defineProperty(this, "getFieldsAsync", this.handleErrors(function (tableName) {
var getTableDetails = _this2.wrapThrift("get_table_details", _this2.overSingleClient, function (args) {
return args;
});
return getTableDetails(tableName).then(function (fields) {
if (fields) {
var rowDict = fields.row_desc.reduce(function (accum, value) {
accum[value.col_name] = value;
return accum;
}, {});
return _objectSpread(_objectSpread({}, fields), {}, {
columns: _this2.convertFromThriftTypes(rowDict)
});
} else {
throw new Error("Table (".concat(tableName, ") not found"));
}
});
}));
_defineProperty(this, "getFields", this.callbackify("getFieldsAsync", 1));
_defineProperty(this, "createTableAsync", this.handleErrors(this.wrapThrift("create_table", this.overAllClients, function (_ref13) {
var _ref14 = _slicedToArray(_ref13, 4),
tableName = _ref14[0],
rowDescObj = _ref14[1],
createParams = _ref14[2],
options = _ref14[3];
return [tableName, (options === null || options === void 0 ? void 0 : options.useUnmodifiedRowDesc) ? rowDescObj : _helpers__WEBPACK_IMPORTED_MODULE_8__/* .mutateThriftRowDesc */ .HP(rowDescObj, _this2.importerRowDesc), createParams];
})));
_defineProperty(this, "createTable", this.callbackify("createTableAsync", 4));
_defineProperty(this, "importTableAsync", this.handleErrors(this.wrapThrift("import_table", this.overAllClients, function (_ref15) {
var _ref16 = _slicedToArray(_ref15, 3),
tableName = _ref16[0],
fileName = _ref16[1],
copyParams = _ref16[2];
return [tableName, fileName, _helpers__WEBPACK_IMPORTED_MODULE_8__/* .convertObjectToThriftCopyParams */ .Dq(copyParams)];
})));
_defineProperty(this, "importTableGeoAsync", this.handleErrors(this.wrapThrift("import_geo_table", this.overAllClients, function (_ref17) {
var _ref18 = _slicedToArray(_ref17, 4),
tableName = _ref18[0],
fileName = _ref18[1],
copyParams = _ref18[2],
rowDescObj = _ref18[3];
return [tableName, fileName, _helpers__WEBPACK_IMPORTED_MODULE_8__/* .convertObjectToThriftCopyParams */ .Dq(copyParams), _helpers__WEBPACK_IMPORTED_MODULE_8__/* .mutateThriftRowDesc */ .HP(rowDescObj, _this2.importerRowDesc), new _thrift_heavy_types_js__WEBPACK_IMPORTED_MODULE_4__.TCreateParams()];
})));
_defineProperty(this, "renderVegaAsync", this.handleErrors(function (widgetid, vega, options) {
var queryId = null;
var compressionLevel = COMPRESSION_LEVEL_DEFAULT;
if (options) {
queryId = options.hasOwnProperty("queryId") ? options.queryId : queryId;
compressionLevel = options.hasOwnProperty("compressionLevel") ? options.compressionLevel : compressionLevel;
}
var lastQueryTime = queryId in _this2.queryTimes ? _this2.queryTimes[queryId] : _this2.DEFAULT_QUERY_TIME;
var curNonce = (_this2._nonce++).toString();
if (options) {
curNonce = options.hasOwnProperty("logValues") ? _typeof(options.logValues) === "object" ? JSON.stringify(options.logValues) : options.logValues : curNonce;
}
var conId = 0;
_this2._lastRenderCon = conId;
var processResultsOptions = {
isImage: true,
query: "render: ".concat(vega),
queryId: queryId,
conId: conId,
estimatedQueryTime: lastQueryTime
};
var renderVega = _this2.wrapThrift("render_vega", _this2.overSingleClient, function (args) {
return args;
});
return _this2.processResults(processResultsOptions, renderVega(widgetid, vega, compressionLevel, curNonce));
}));
_defineProperty(this, "renderVega", this.callbackify("renderVegaAsync", 3));
_defineProperty(this, "getResultRowForPixelAsync", this.handleErrors(function (widgetId, pixel, tableColNamesMap) {
var pixelRadius = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 2;
if (!(pixel instanceof _thrift_heavy_types_js__WEBPACK_IMPORTED_MODULE_4__.TPixel)) {
pixel = new _thrift_heavy_types_js__WEBPACK_IMPORTED_MODULE_4__.TPixel(pixel);
}
var columnFormat = true; // BOOL
var curNonce = (_this2._nonce++).toString();
return _this2._client[_this2._lastRenderCon].get_result_row_for_pixel(_this2._sessionId[_this2._lastRenderCon], widgetId, pixel, tableColNamesMap, columnFormat, pixelRadius, curNonce).then(function (results) {
results = Array.isArray(results) ? results.pixel_rows : [results];
var processResultsOptions = {
isImage: false,
eliminateNullRows: false,
query: "pixel request",
queryId: -2
};
var processor = (0,_process_query_results__WEBPACK_IMPORTED_MODULE_7__/* .default */ .Z)(_this2._logging, _this2.updateQueryTimes);
var numPixels = results.length;
for (var p = 0; p < numPixels; p++) {
results[p].row_set = processor(processResultsOptions, _this2._datumEnum, results[p]);
}
return results;
});
}));
_defineProperty(this, "getResultRowForPixel", this.callbackify("getResultRowForPixelAsync", 4));
this._useBinaryProtocol = false;
this._host = null;
this._user = null;
this._password = null;
this._port = null;
this._dbName = null;
this._client = null;
this._sessionId = null;
this._protocol = null;
this._disableAutoReconnect = false;
this._datumEnum = {};
this.TFileTypeMap = {};
this.TEncodingTypeMap = {};
this.TImportHeaderRowMap = {};
this.TRasterPointTypeMap = {};
this.TRasterPointTransformMap = {};
this.TSourceTypeMap = {};
this._logging = false;
this._platform = "heavydb";
this._nonce = 0;
this._balanceStrategy = "adaptive";
this._numConnections = 0;
this._lastRenderCon = 0;
this.queryTimes = {};
this.serverQueueTimes = null;
this.serverPingTimes = null;
this.pingCount = null;
this.DEFAULT_QUERY_TIME = 50;
this.NUM_PINGS_PER_SERVER = 4;
this.importerRowDesc = null; // invoke initialization methods
this.invertDatumTypes();
this.buildTFileTypeMap();
this.buildTEncodingTypeMap();
this.buildTImportHeaderRowMap();
this.buildTRasterPointTypeMap();
this.buildTRasterPointTransformMap();
this.buildTSourceTypeMap();
this.processResults = function () {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var promise = arguments.length > 1 ? arguments[1] : undefined;
return promise["catch"](function (error) {
if (_this2._logging && options.query) {
// eslint-disable-next-line no-console
console.error(options.query, "\n", error);
}
throw error;
}).then(function (result) {
var processor = (0,_process_query_results__WEBPACK_IMPORTED_MODULE_7__/* .default */ .Z)(_this2._logging, _this2.updateQueryTimes);
var processResultsObject = processor(options, _this2._datumEnum, result);
return processResultsObject;
});
}; // return this to allow chaining off of instantiation
return this;
}
_createClass(DbCon, [{
key: "removeConnection",
value: function removeConnection(conId) {
if (conId < 0 || conId >= this.numConnections) {
var err = {
msg: "Remove connection id invalid"
};
throw err;
}
this._client.splice(conId, 1);
this._sessionId.splice(conId, 1);
this._numConnections--;
}
}, {
key: "xhrWithCredentials",
value: function xhrWithCredentials(enabled) {
CustomXHRConnection.withCredentials = Boolean(enabled);
}
/**
* Initializes the connector for use. This is similar to `connect()`, but stops short of
* actually connecting to the server.
*
* @return {DbCon} Object.
*/
}, {
key: "initClients",
value: function initClients() {
var allAreArrays = Array.isArray(this._host) && Array.isArray(this._port) && Array.isArray(this._dbName);
if (!allAreArrays) {
throw new Error("Host, port, and dbName must be arrays.");
}
this._client = [];
this._sessionId = [];
if (!this._host[0]) {
throw new Error("Please enter a host name.");
} else if (!this._port[0]) {
throw new Error("Please enter a port.");
} // now check to see if length of all arrays are the same and > 0
var hostLength = this._host.length;
if (hostLength < 1) {
throw new Error("Must have at least one server to connect to.");
}
if (hostLength !== this._port.length) {
throw new Error("Array connection parameters must be of equal length.");
}
if (!this._protocol) {
this._protocol = this._host.map(function () {
return true ? window.location.protocol.replace(":", "") : 0;
});
}
var transportUrls = this.getEndpoints();
var clients = [];
for (var h = 0; h < hostLength; h++) {
var client = buildClient(transportUrls[h], this._useBinaryProtocol);
clients.push(client);
}
this._client = clients;
this._numConnections = this._client.length;
return this;
}
/**
* Create a connection to the MapD server, generating a client and session ID.
* @return {Promise.DbCon} Object.
*
* @example
Connect to a MapD server:
* var con = new DbCon()
* .host('localhost')
* .port('8080')
* .dbName('myDatabase')
* .user('foo')
* .password('bar')
* .connect()
* .then((con) => console.log(con.sessionId()));
*
* // ["om9E9Ujgbhl6wIzWgLENncjWsaXRDYLy"]
*/
}, {
key: "connectAsync",
value: function connectAsync() {
var _this3 = this;
if (!Array.isArray(this._user) || !Array.isArray(this._password)) {
return Promise.reject("Username and password must be arrays.");
}
if (!this._dbName[0]) {
return Promise.reject("Please enter a database.");
} else if (!this._user[0]) {
return Promise.reject("Please enter a username.");
} else if (!this._password[0]) {
return Promise.reject("Please enter a password.");
} // now check to see if length of all arrays are the same and > 0
var hostLength = this._host.length;
if (hostLength < 1) {
return Promise.reject("Must have at least one server to connect to.");
}
if (hostLength !== this._port.length || hostLength !== this._user.length || hostLength !== this._password.length || hostLength !== this._dbName.length) {
return Promise.reject("Array connection parameters must be of equal length.");
}
var clients = [];
this.initClients();
clients = this._client; // Reset the client property, so we can add only the ones that we can connect to below
this._client = [];
return Promise.all(clients.map(function (client, h) {
return client.connect(_this3._user[h], _this3._password[h], _this3._dbName[h]).then(function (sessionId) {
_this3._client.push(client);
_this3._sessionId.push(sessionId);
return null;
});
})).then(function () {
return _this3;
});
}
/**
* Create a connection to the MapD server, generating a client and session ID.
* @param {Function} callback An optional callback that takes `(err, success)` as its signature. Returns con singleton if successful.
* @return {Promise.DbCon} Object.
*
* @example
Connect to a MapD server:
* var con = new DbCon()
* .host('localhost')
* .port('8080')
* .dbName('myDatabase')
* .user('foo')
* .password('bar')
* .connect((err, con) => console.log(con.sessionId()));
*
* // ["om9E9Ujgbhl6wIzWgLENncjWsaXRDYLy"]
*/
}, {
key: "convertFromThriftTypes",
value: function convertFromThriftTypes(fields) {
var fieldsArray = []; // silly to change this from map to array
// - then later it turns back to map
for (var key in fields) {
if (fields.hasOwnProperty(key)) {
fieldsArray.push({
name: key,
type: this._datumEnum[fields[key].col_type.type],
precision: fields[key].col_type.precision,
is_array: fields[key].col_type.is_array,
is_dict: fields[key].col_type.encoding === _thrift_common_types_js__WEBPACK_IMPORTED_MODULE_3__.TEncodingType.DICT // eslint-disable-line no-undef
});
}
}
return fieldsArray;
}
/**
* Disconnect from the server and then clear the client and session values.
* @return {Promise.DbCon} Object.
*
* @example
Disconnect from the server:
*
* con.disconnect()
*/
}, {
key: "invertDatumTypes",
/**
* Create an array-like object from {@link TDatumType} by
* changing the order of the string key and numerical value.
*
* @returns {Undefined} This function does not return anything.
*/
value: function invertDatumTypes() {
var datumType = _thrift_common_types_js__WEBPACK_IMPORTED_MODULE_3__.TDatumType; // eslint-disable-line no-undef
for (var key in datumType) {
if (datumType.hasOwnProperty(key)) {
this._datumEnum[datumType[key]] = key;
}
}
}
/**
* Get a list of field objects for a specified table.
* @param {String} tableName Name of table containing field names.
* @return {Promise.Array