Skip to content

Commit

Permalink
Avoid reinitialization of lexical in parse method
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinod K C committed Jun 26, 2015
1 parent ef4f60f commit e27c66c
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ private[sql] abstract class AbstractSparkSQLParser

def parse(input: String): LogicalPlan = {
// Initialize the Keywords.
lexical.initialize(reservedWords)
initLexical
phrase(start)(new lexical.Scanner(input)) match {
case Success(plan, _) => plan
case failureOrError => sys.error(failureOrError.toString)
}
}
/* One time initialization of lexical.This avoid reinitialization of lexical in parse method */
protected lazy val initLexical: Unit = lexical.initialize(reservedWords)

protected case class Keyword(str: String) {
def normalize: String = lexical.normalizeKeyword(str)
Expand Down Expand Up @@ -82,10 +84,8 @@ class SqlLexical extends StdLexical {

/* This is a work around to support the lazy setting */
def initialize(keywords: Seq[String]): Unit = {
synchronized {
reserved.clear()
reserved ++= keywords
}
}

/* Normal the keyword string */
Expand Down

0 comments on commit e27c66c

Please sign in to comment.