update js

This commit is contained in:
HSunboy
2019-12-31 18:47:24 +08:00
parent 93125a715a
commit 62aa00ebf1
17 changed files with 40515 additions and 18176 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,84 @@
"use strict";
// Licensed to Cloudera, Inc. under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. Cloudera, Inc. licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
/* eslint-disable */
/**
* AUTOCOMPLETE_MODULES and SYNTAX_MODULES are generated, do not edit manually, see tools/jison/generateParsers.js
*/
const AUTOCOMPLETE_MODULES = {
calcite: require("calcite/calciteAutocompleteParser"),
druid: require("druid/druidAutocompleteParser"),
elasticsearch: require("elasticsearch/elasticsearchAutocompleteParser"),
flink: require("flink/flinkAutocompleteParser"),
generic: require("generic/genericAutocompleteParser"),
hive: require("hive/hiveAutocompleteParser"),
impala: require("impala/impalaAutocompleteParser"),
ksql: require("ksql/ksqlAutocompleteParser"),
phoenix: require("phoenix/phoenixAutocompleteParser"),
presto: require("presto/prestoAutocompleteParser")
};
const SYNTAX_MODULES = {
calcite: require("calcite/calciteSyntaxParser"),
druid: require("druid/druidSyntaxParser"),
elasticsearch: require("elasticsearch/elasticsearchSyntaxParser"),
flink: require("flink/flinkSyntaxParser"),
generic: require("generic/genericSyntaxParser"),
hive: require("hive/hiveSyntaxParser"),
impala: require("impala/impalaSyntaxParser"),
ksql: require("ksql/ksqlSyntaxParser"),
phoenix: require("phoenix/phoenixSyntaxParser"),
presto: require("presto/prestoSyntaxParser")
};
/* eslint-enable */
class SqlParserRepository {
constructor() {
this.modulePromises = {};
}
getParser(sourceType, parserType) {
return __awaiter(this, void 0, void 0, function* () {
if (!this.modulePromises[sourceType + parserType]) {
const modules = parserType === 'Autocomplete' ? AUTOCOMPLETE_MODULES : SYNTAX_MODULES;
this.modulePromises[sourceType + parserType] = new Promise((resolve, reject) => {
const targetModule = modules[sourceType] || modules.generic;
resolve(targetModule);
});
}
return this.modulePromises[sourceType + parserType];
});
}
getAutocompleter(sourceType) {
return __awaiter(this, void 0, void 0, function* () {
return this.getParser(sourceType, 'Autocomplete');
});
}
getSyntaxParser(sourceType) {
return __awaiter(this, void 0, void 0, function* () {
return this.getParser(sourceType, 'Syntax');
});
}
}
const sqlParserRepository = new SqlParserRepository();
exports.default = sqlParserRepository;

View File

@ -0,0 +1,75 @@
"use strict";
// Licensed to Cloudera, Inc. under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. Cloudera, Inc. licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Calculates the Optimal String Alignment distance between two strings. Returns 0 when the strings are equal and the
* distance when not, distances is less than or equal to the length of the longest string.
*
* @param strA
* @param strB
* @param [ignoreCase]
* @returns {number} The similarity
*/
const stringDistance = function (strA, strB, ignoreCase) {
if (ignoreCase) {
strA = strA.toLowerCase();
strB = strB.toLowerCase();
}
// TODO: Consider other algorithms for performance
const strALength = strA.length;
const strBLength = strB.length;
if (strALength === 0) {
return strBLength;
}
if (strBLength === 0) {
return strALength;
}
const distances = new Array(strALength);
let cost, deletion, insertion, substitution, transposition;
for (let i = 0; i <= strALength; i++) {
distances[i] = new Array(strBLength);
distances[i][0] = i;
for (let j = 1; j <= strBLength; j++) {
if (!i) {
distances[0][j] = j;
}
else {
cost = strA[i - 1] === strB[j - 1] ? 0 : 1;
deletion = distances[i - 1][j] + 1;
insertion = distances[i][j - 1] + 1;
substitution = distances[i - 1][j - 1] + cost;
if (deletion <= insertion && deletion <= substitution) {
distances[i][j] = deletion;
}
else if (insertion <= deletion && insertion <= substitution) {
distances[i][j] = insertion;
}
else {
distances[i][j] = substitution;
}
if (i > 1 && j > 1 && strA[i] === strB[j - 1] && strA[i - 1] === strB[j]) {
transposition = distances[i - 2][j - 2] + cost;
if (transposition < distances[i][j]) {
distances[i][j] = transposition;
}
}
}
}
}
return distances[strALength][strBLength];
};
exports.default = stringDistance;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long