-
Notifications
You must be signed in to change notification settings - Fork 548
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a7f55d1
commit 1eb5065
Showing
70 changed files
with
414 additions
and
272 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,13 +5,14 @@ import org.scalatest.BeforeAndAfterEach | |
import tech.mlsql.autosuggest.meta.{MetaProvider, MetaTable, MetaTableColumn, MetaTableKey} | ||
import tech.mlsql.autosuggest.statement.{LexerUtils, SuggestItem} | ||
import tech.mlsql.autosuggest.{DataType, SpecialTableConst, TokenPos, TokenPosType} | ||
import tech.mlsql.common.utils.log.Logging | ||
|
||
import scala.collection.JavaConverters._ | ||
|
||
/** | ||
* 2/6/2020 WilliamZhu([email protected]) | ||
*/ | ||
class AutoSuggestContextTest extends BaseTest with BeforeAndAfterEach { | ||
class AutoSuggestContextTest extends BaseTest with BeforeAndAfterEach with Logging { | ||
override def afterEach(): Unit = { | ||
// context.statements.clear() | ||
} | ||
|
@@ -44,8 +45,9 @@ class AutoSuggestContextTest extends BaseTest with BeforeAndAfterEach { | |
|
||
def printStatements(items: List[List[Token]]) = { | ||
items.foreach { item => | ||
println(item.map(_.getText).mkString(" ")) | ||
println() | ||
if (log.isInfoEnabled()) { | ||
log.info(item.map(_.getText).mkString(" ")) | ||
} | ||
} | ||
} | ||
|
||
|
@@ -84,7 +86,7 @@ class AutoSuggestContextTest extends BaseTest with BeforeAndAfterEach { | |
|SELECT CAST(25.65 AS int) from jack; | ||
|""".stripMargin).tokens.asScala.toList | ||
|
||
wow.foreach(item => println(s"${item.getText} ${item.getType}")) | ||
wow.foreach(item => log.info("{} {}", item.getText, item.getType)) | ||
} | ||
|
||
test("load/select 4/10 select ke[cursor] from") { | ||
|
@@ -150,7 +152,9 @@ class AutoSuggestContextTest extends BaseTest with BeforeAndAfterEach { | |
| select from table3 | ||
|""".stripMargin).tokens.asScala.toList | ||
val items = context.build(wow).suggest(5, 8) | ||
println(items) | ||
if (log.isInfoEnabled()) { | ||
log.info(items.toString()) | ||
} | ||
|
||
} | ||
|
||
|
@@ -178,7 +182,9 @@ class AutoSuggestContextTest extends BaseTest with BeforeAndAfterEach { | |
| select sum() from table3 | ||
|""".stripMargin | ||
val items = context.buildFromString(sql).suggest(5, 12) | ||
println(items) | ||
if (log.isInfoEnabled()) { | ||
log.info(items.toString()) | ||
} | ||
|
||
} | ||
test("table alias with temp table") { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,13 +2,14 @@ package com.intigua.antlr4.autosuggest | |
|
||
import tech.mlsql.autosuggest.statement.LoadSuggester | ||
import tech.mlsql.autosuggest.{TokenPos, TokenPosType} | ||
import tech.mlsql.common.utils.log.Logging | ||
|
||
import scala.collection.JavaConverters._ | ||
|
||
/** | ||
* 2/6/2020 WilliamZhu([email protected]) | ||
*/ | ||
class LoadSuggesterTest extends BaseTest { | ||
class LoadSuggesterTest extends BaseTest with Logging { | ||
test("load hiv[cursor]") { | ||
val wow = context.lexer.tokenizeNonDefaultChannel( | ||
""" | ||
|
@@ -26,7 +27,13 @@ class LoadSuggesterTest extends BaseTest { | |
| load | ||
|""".stripMargin).tokens.asScala.toList | ||
val loadSuggester = new LoadSuggester(context, wow, TokenPos(0, TokenPosType.NEXT, 0)).suggest() | ||
println(loadSuggester) | ||
if (log.isInfoEnabled()) { | ||
var loadSuggesterToString = ""; | ||
loadSuggester.foreach(i => | ||
loadSuggesterToString += ("name: " + i.name + ",") | ||
) | ||
log.info(loadSuggesterToString) | ||
} | ||
assert(loadSuggester.size > 1) | ||
} | ||
|
||
|
@@ -37,7 +44,9 @@ class LoadSuggesterTest extends BaseTest { | |
| load csv.`` where | ||
|""".stripMargin).tokens.asScala.toList | ||
val result = new LoadSuggester(context, wow, TokenPos(4, TokenPosType.NEXT, 0)).suggest() | ||
println(result) | ||
if (log.isInfoEnabled()) { | ||
log.info(result.toString()) | ||
} | ||
|
||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,13 +3,14 @@ package com.intigua.antlr4.autosuggest | |
import tech.mlsql.autosuggest.meta.{MetaProvider, MetaTable, MetaTableColumn, MetaTableKey} | ||
import tech.mlsql.autosuggest.statement.SelectSuggester | ||
import tech.mlsql.autosuggest.{DataType, MLSQLSQLFunction, TokenPos, TokenPosType} | ||
import tech.mlsql.common.utils.log.Logging | ||
|
||
import scala.collection.JavaConverters._ | ||
|
||
/** | ||
* 2/6/2020 WilliamZhu([email protected]) | ||
*/ | ||
class SelectSuggesterTest extends BaseTest { | ||
class SelectSuggesterTest extends BaseTest with Logging { | ||
|
||
def buildMetaProvider = { | ||
context.setUserDefinedMetaProvider(new MetaProvider { | ||
|
@@ -185,10 +186,14 @@ class SelectSuggesterTest extends BaseTest { | |
|""".stripMargin).tokens.asScala.toList | ||
|
||
val suggester = new SelectSuggester(context, wow2, TokenPos(0, TokenPosType.NEXT, 0)) | ||
println(suggester.sqlAST.printAsStr(suggester.tokens, 0)) | ||
if (log.isInfoEnabled()) { | ||
log.info(suggester.sqlAST.printAsStr(suggester.tokens, 0)) | ||
} | ||
suggester.table_info.foreach { case (level, item) => | ||
println(level + ":") | ||
println(item.map(_._1).toList) | ||
if (log.isInfoEnabled()) { | ||
log.info(level + ":") | ||
log.info(item.map(_._1).toList.toString()) | ||
} | ||
} | ||
assert(suggester.suggest().map(_.name) == List(("b"), ("keywords"), ("search_num"), ("rank"))) | ||
|
||
|
@@ -203,8 +208,10 @@ class SelectSuggesterTest extends BaseTest { | |
val tokens = getMLSQLTokens(sql) | ||
|
||
val suggester = new SelectSuggester(context, tokens, TokenPos(0, TokenPosType.NEXT, 0)) | ||
println("=======") | ||
println(suggester.suggest()) | ||
log.info("=======") | ||
if (log.isInfoEnabled()) { | ||
log.info(suggester.suggest().toString()) | ||
} | ||
assert(suggester.suggest().head.name=="b") | ||
} | ||
|
||
|
@@ -250,7 +257,9 @@ class SelectSuggesterTest extends BaseTest { | |
|""".stripMargin).tokens.asScala.toList | ||
|
||
val suggester = new SelectSuggester(context, wow, TokenPos(1, TokenPosType.CURRENT, 3)) | ||
println(suggester.suggest()) | ||
if (log.isInfoEnabled()) { | ||
log.info(suggester.suggest().toString()) | ||
} | ||
assert(suggester.suggest().map(_.name) == List(("split"))) | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,14 +6,15 @@ import streaming.dsl.ScriptSQLExec | |
import streaming.dsl.auth._ | ||
import streaming.dsl.mmlib.SQLAlg | ||
import streaming.dsl.mmlib.algs.param.WowParams | ||
import tech.mlsql.common.utils.log.Logging | ||
import tech.mlsql.common.utils.serder.json.JSONTool | ||
import tech.mlsql.dsl.auth.ETAuth | ||
import tech.mlsql.dsl.auth.dsl.mmlib.ETMethod.ETMethod | ||
|
||
/** | ||
* 27/3/2020 WilliamZhu([email protected]) | ||
*/ | ||
class ProfilerCommand(override val uid: String) extends SQLAlg with ETAuth with WowParams { | ||
class ProfilerCommand(override val uid: String) extends SQLAlg with ETAuth with WowParams with Logging { | ||
def this() = this(WowParams.randomUID()) | ||
|
||
override def train(df: DataFrame, path: String, params: Map[String, String]): DataFrame = { | ||
|
@@ -48,7 +49,9 @@ class ProfilerCommand(override val uid: String) extends SQLAlg with ETAuth with | |
val explain = MLSQLUtils.createExplainCommand(df.queryExecution.logical, extended = extended) | ||
val items = df.sparkSession.sessionState.executePlan(explain).executedPlan.executeCollect(). | ||
map(_.getString(0)).mkString("\n") | ||
println(items) | ||
if (log.isInfoEnabled()) { | ||
log.info(items) | ||
} | ||
df.sparkSession.createDataset[Plan](Seq(Plan("doc", items))).toDF() | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
package tech.mlsql.indexer.impl | ||
|
||
import java.nio.charset.Charset | ||
|
||
import org.apache.http.client.fluent.{Form, Request} | ||
import tech.mlsql.common.utils.log.Logging | ||
import tech.mlsql.common.utils.serder.json.JSONTool | ||
import tech.mlsql.indexer.{MLSQLIndexerMeta, MlsqlIndexerItem, MlsqlOriTable} | ||
|
||
/** | ||
* 21/12/2020 WilliamZhu([email protected]) | ||
*/ | ||
class RestIndexerMeta(url: String, token: String,timeout:Int=2000) extends MLSQLIndexerMeta { | ||
class RestIndexerMeta(url: String, token: String,timeout:Int=2000) extends MLSQLIndexerMeta with Logging { | ||
override def fetchIndexers(tableNames: List[MlsqlOriTable], options: Map[String, String]): Map[MlsqlOriTable, List[MlsqlIndexerItem]] = { | ||
val form = Form.form() | ||
form.add("data", JSONTool.toJsonStr(tableNames)) | ||
|
@@ -23,7 +23,7 @@ class RestIndexerMeta(url: String, token: String,timeout:Int=2000) extends MLSQL | |
JSONTool.parseJson[Map[MlsqlOriTable, List[MlsqlIndexerItem]]](value) | ||
} catch { | ||
case e: Exception => | ||
e.printStackTrace() | ||
log.error("FetchIndexers Error: {}", e) | ||
Map() | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,14 +6,15 @@ import streaming.dsl.ScriptSQLExec | |
import streaming.dsl.auth._ | ||
import streaming.dsl.mmlib.SQLAlg | ||
import streaming.dsl.mmlib.algs.param.WowParams | ||
import tech.mlsql.common.utils.log.Logging | ||
import tech.mlsql.common.utils.serder.json.JSONTool | ||
import tech.mlsql.dsl.auth.ETAuth | ||
import tech.mlsql.dsl.auth.dsl.mmlib.ETMethod.ETMethod | ||
|
||
/** | ||
* 27/3/2020 WilliamZhu([email protected]) | ||
*/ | ||
class ProfilerCommand(override val uid: String) extends SQLAlg with ETAuth with WowParams { | ||
class ProfilerCommand(override val uid: String) extends SQLAlg with ETAuth with WowParams with Logging { | ||
def this() = this(WowParams.randomUID()) | ||
|
||
override def train(df: DataFrame, path: String, params: Map[String, String]): DataFrame = { | ||
|
@@ -48,7 +49,9 @@ class ProfilerCommand(override val uid: String) extends SQLAlg with ETAuth with | |
val explain = MLSQLUtils.createExplainCommand(df.queryExecution.logical, extended = extended) | ||
val items = df.sparkSession.sessionState.executePlan(explain).executedPlan.executeCollect(). | ||
map(_.getString(0)).mkString("\n") | ||
println(items) | ||
if (log.isInfoEnabled()) { | ||
log.info(items) | ||
} | ||
df.sparkSession.createDataset[Plan](Seq(Plan("doc", items))).toDF() | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,9 +18,9 @@ | |
|
||
package tech.mlsql.cluster.service.elastic_resource | ||
|
||
import java.util.concurrent.{Executors, TimeUnit} | ||
import java.util.logging.Logger | ||
import org.slf4j.LoggerFactory | ||
|
||
import java.util.concurrent.{Executors, TimeUnit} | ||
import tech.mlsql.cluster.ProxyApplication | ||
import tech.mlsql.cluster.model.ElasticMonitor | ||
import tech.mlsql.common.utils.log.Logging | ||
|
@@ -31,7 +31,6 @@ import scala.collection.JavaConverters._ | |
* 2018-12-05 WilliamZhu([email protected]) | ||
*/ | ||
object AllocateService extends Logging { | ||
val logger = Logger.getLogger("AllocateService") | ||
private[this] val _executor = Executors.newFixedThreadPool(100) | ||
private[this] val scheduler = Executors.newSingleThreadScheduledExecutor() | ||
|
||
|
@@ -65,7 +64,7 @@ object AllocateService extends Logging { | |
} | ||
} catch { | ||
case e: Exception => | ||
e.printStackTrace() | ||
log.error("Running Error: {}", e) | ||
//catch all ,so the scheduler will not been stopped by exception | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,20 +19,20 @@ | |
package tech.mlsql.cluster.test | ||
|
||
import java.util | ||
|
||
import net.csdn.ServiceFramwork | ||
import net.csdn.bootstrap.Bootstrap | ||
import org.scalatest.{FlatSpec, Matchers} | ||
import tech.mlsql.cluster.model.{Backend, EcsResourcePool, ElasticMonitor} | ||
import tech.mlsql.cluster.service.elastic_resource.local.LocalDeployInstance | ||
import tech.mlsql.cluster.service.elastic_resource.{BaseResource, JobNumAwareAllocateStrategy, LocalResourceAllocation, LocalResourceDeAllocation} | ||
import tech.mlsql.common.utils.log.Logging | ||
|
||
import scala.collection.JavaConverters._ | ||
|
||
/** | ||
* 2018-12-07 WilliamZhu([email protected]) | ||
*/ | ||
class DeploySpec extends FlatSpec with Matchers { | ||
class DeploySpec extends FlatSpec with Matchers with Logging{ | ||
|
||
def mockServer = { | ||
try { | ||
|
@@ -117,7 +117,9 @@ class DeploySpec extends FlatSpec with Matchers { | |
planRes = allocate.plan(monitor.getTag.split(",").toSeq, monitor) | ||
assume(planRes.isDefined) | ||
|
||
print(planRes) | ||
if (log.isInfoEnabled()) { | ||
log.info(planRes.toString) | ||
} | ||
|
||
planRes.get match { | ||
case LocalResourceAllocation(tags) => assume(tags == "jack") | ||
|
@@ -186,7 +188,9 @@ class DeploySpec extends FlatSpec with Matchers { | |
planRes = allocate.plan(monitor.getTag.split(",").toSeq, monitor) | ||
assume(planRes.isDefined) | ||
|
||
print(planRes) | ||
if (log.isInfoEnabled()) { | ||
log.info(planRes.toString) | ||
} | ||
|
||
planRes.get match { | ||
case LocalResourceDeAllocation(tags) => assume(tags == "jack") | ||
|
Oops, something went wrong.