{"action":"created","comment":{"url":"https://api.github.com/repos/lucidworks/spark-solr/pulls/comments/67783972","id":67783972,"diff_hunk":"@@ -0,0 +1,85 @@\n+package com.lucidworks.spark\n+\n+import java.text.SimpleDateFormat\n+import java.util.{Date, TimeZone}\n+import java.util.concurrent.TimeUnit\n+import java.util.regex.{Matcher, Pattern}\n+\n+import com.lucidworks.spark.util.QueryConstants._\n+import com.lucidworks.spark.util.{SolrQuerySupport, SolrSupport}\n+import org.apache.solr.client.solrj.SolrQuery\n+import org.apache.spark.Logging\n+\n+/**\n+  * Created by akashmehta on 6/17/16.\n+  */\n+class PartitionByTimeFeature(val conf:SolrConf) extends Logging {\n+  private val TIME_PERIOD_PATTERN: Pattern = Pattern.compile(\"^(\\\\d{1,4})(MINUTES|HOURS|DAYS)$\")\n+\n+  private var timestampFieldName: String = null\n+  private var timezoneId: String = null\n+  private var timeFrame: Int = 0\n+  private var timeUnit: TimeUnit = null\n+  private var timeFrameMs: Long = 0L\n+  private var dateTimePattern: String = null\n+  private var partitionNamePrefix: String = null\n+  private var maxActivePartitions: String = null\n+\n+  val timePeriod: String = conf.getTimePeriod.getOrElse(DEFAULT_TIME_PERIOD)\n+\n+  val matcher: Matcher = TIME_PERIOD_PATTERN.matcher(timePeriod)\n+  if (!matcher.matches) {\n+    throw new IllegalArgumentException(\"Invalid timePeriod \"+ timePeriod)\n+  }\n+\n+  timestampFieldName = conf.getTSFieldName.getOrElse(DEFAULT_TS_FIELD_NAME)\n+  timezoneId = conf.getTimeZoneId.getOrElse(DEFAULT_TIMEZONE_ID)\n+  partitionNamePrefix = conf.getCollection.get+ \"_\"\n+  timeFrame = matcher.group(1).toInt\n+  timeUnit = TimeUnit.valueOf(matcher.group(2))\n+  timeFrameMs = TimeUnit.MILLISECONDS.convert(timeFrame, timeUnit)\n+  dateTimePattern = conf.getDateTimePattern.getOrElse(getDefaultDateTimePattern(timeUnit))\n+\n+  private val dateFormatter: ThreadLocal[SimpleDateFormat] = new ThreadLocal[SimpleDateFormat]() {\n+    override protected def initialValue: SimpleDateFormat = {\n+      val sdf: SimpleDateFormat = new SimpleDateFormat(dateTimePattern)\n+      sdf.setTimeZone(TimeZone.getTimeZone(dateTimePattern))\n+      sdf\n+    }\n+  }\n+\n+\n+  maxActivePartitions = conf.getMaxActivePartitions.getOrElse(null)\n+  if (maxActivePartitions!= null && maxActivePartitions.toInt <= 0) {\n+    throw new IllegalArgumentException(\"Value for  MAX_ACTIVE_PARTITIONS  must be strictly greater than zero!\")\n+  }\n+\n+  val solrCloudClient = SolrSupport.getCachedCloudClient(conf.getZkHost.get)","path":"src/main/scala/com/lucidworks/spark/PartitionByTimeFeature.scala","position":57,"original_position":57,"commit_id":"d80c28b2a3471a39959e10856f266221f1d94589","original_commit_id":"d80c28b2a3471a39959e10856f266221f1d94589","user":{"login":"thelabdude","id":417074,"avatar_url":"https://avatars.githubusercontent.com/u/417074?v=3","gravatar_id":"","url":"https://api.github.com/users/thelabdude","html_url":"https://github.com/thelabdude","followers_url":"https://api.github.com/users/thelabdude/followers","following_url":"https://api.github.com/users/thelabdude/following{/other_user}","gists_url":"https://api.github.com/users/thelabdude/gists{/gist_id}","starred_url":"https://api.github.com/users/thelabdude/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thelabdude/subscriptions","organizations_url":"https://api.github.com/users/thelabdude/orgs","repos_url":"https://api.github.com/users/thelabdude/repos","events_url":"https://api.github.com/users/thelabdude/events{/privacy}","received_events_url":"https://api.github.com/users/thelabdude/received_events","type":"User","site_admin":false},"body":"why is this here?","created_at":"2016-06-20T23:15:28Z","updated_at":"2016-06-20T23:15:28Z","html_url":"https://github.com/lucidworks/spark-solr/pull/72#discussion_r67783972","pull_request_url":"https://api.github.com/repos/lucidworks/spark-solr/pulls/72","_links":{"self":{"href":"https://api.github.com/repos/lucidworks/spark-solr/pulls/comments/67783972"},"html":{"href":"https://github.com/lucidworks/spark-solr/pull/72#discussion_r67783972"},"pull_request":{"href":"https://api.github.com/repos/lucidworks/spark-solr/pulls/72"}}},"pull_request":{"url":"https://api.github.com/repos/lucidworks/spark-solr/pulls/72","id":74528324,"html_url":"https://github.com/lucidworks/spark-solr/pull/72","diff_url":"https://github.com/lucidworks/spark-solr/pull/72.diff","patch_url":"https://github.com/lucidworks/spark-solr/pull/72.patch","issue_url":"https://api.github.com/repos/lucidworks/spark-solr/issues/72","number":72,"state":"open","locked":false,"title":"Spar 31","user":{"login":"mehtakash93","id":14355212,"avatar_url":"https://avatars.githubusercontent.com/u/14355212?v=3","gravatar_id":"","url":"https://api.github.com/users/mehtakash93","html_url":"https://github.com/mehtakash93","followers_url":"https://api.github.com/users/mehtakash93/followers","following_url":"https://api.github.com/users/mehtakash93/following{/other_user}","gists_url":"https://api.github.com/users/mehtakash93/gists{/gist_id}","starred_url":"https://api.github.com/users/mehtakash93/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mehtakash93/subscriptions","organizations_url":"https://api.github.com/users/mehtakash93/orgs","repos_url":"https://api.github.com/users/mehtakash93/repos","events_url":"https://api.github.com/users/mehtakash93/events{/privacy}","received_events_url":"https://api.github.com/users/mehtakash93/received_events","type":"User","site_admin":false},"body":"Adding support to query multiple timeseries partitions","created_at":"2016-06-20T23:09:55Z","updated_at":"2016-06-20T23:15:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/lucidworks/spark-solr/pulls/72/commits","review_comments_url":"https://api.github.com/repos/lucidworks/spark-solr/pulls/72/comments","review_comment_url":"https://api.github.com/repos/lucidworks/spark-solr/pulls/comments{/number}","comments_url":"https://api.github.com/repos/lucidworks/spark-solr/issues/72/comments","statuses_url":"https://api.github.com/repos/lucidworks/spark-solr/statuses/d80c28b2a3471a39959e10856f266221f1d94589","head":{"label":"lucidworks:SPAR-31","ref":"SPAR-31","sha":"d80c28b2a3471a39959e10856f266221f1d94589","user":{"login":"lucidworks","id":4417866,"avatar_url":"https://avatars.githubusercontent.com/u/4417866?v=3","gravatar_id":"","url":"https://api.github.com/users/lucidworks","html_url":"https://github.com/lucidworks","followers_url":"https://api.github.com/users/lucidworks/followers","following_url":"https://api.github.com/users/lucidworks/following{/other_user}","gists_url":"https://api.github.com/users/lucidworks/gists{/gist_id}","starred_url":"https://api.github.com/users/lucidworks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lucidworks/subscriptions","organizations_url":"https://api.github.com/users/lucidworks/orgs","repos_url":"https://api.github.com/users/lucidworks/repos","events_url":"https://api.github.com/users/lucidworks/events{/privacy}","received_events_url":"https://api.github.com/users/lucidworks/received_events","type":"Organization","site_admin":false},"repo":{"id":29303892,"name":"spark-solr","full_name":"lucidworks/spark-solr","owner":{"login":"lucidworks","id":4417866,"avatar_url":"https://avatars.githubusercontent.com/u/4417866?v=3","gravatar_id":"","url":"https://api.github.com/users/lucidworks","html_url":"https://github.com/lucidworks","followers_url":"https://api.github.com/users/lucidworks/followers","following_url":"https://api.github.com/users/lucidworks/following{/other_user}","gists_url":"https://api.github.com/users/lucidworks/gists{/gist_id}","starred_url":"https://api.github.com/users/lucidworks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lucidworks/subscriptions","organizations_url":"https://api.github.com/users/lucidworks/orgs","repos_url":"https://api.github.com/users/lucidworks/repos","events_url":"https://api.github.com/users/lucidworks/events{/privacy}","received_events_url":"https://api.github.com/users/lucidworks/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lucidworks/spark-solr","description":"Tools for reading data from Solr as a Spark RDD and indexing objects from Spark into Solr using SolrJ.","fork":false,"url":"https://api.github.com/repos/lucidworks/spark-solr","forks_url":"https://api.github.com/repos/lucidworks/spark-solr/forks","keys_url":"https://api.github.com/repos/lucidworks/spark-solr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lucidworks/spark-solr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lucidworks/spark-solr/teams","hooks_url":"https://api.github.com/repos/lucidworks/spark-solr/hooks","issue_events_url":"https://api.github.com/repos/lucidworks/spark-solr/issues/events{/number}","events_url":"https://api.github.com/repos/lucidworks/spark-solr/events","assignees_url":"https://api.github.com/repos/lucidworks/spark-solr/assignees{/user}","branches_url":"https://api.github.com/repos/lucidworks/spark-solr/branches{/branch}","tags_url":"https://api.github.com/repos/lucidworks/spark-solr/tags","blobs_url":"https://api.github.com/repos/lucidworks/spark-solr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lucidworks/spark-solr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lucidworks/spark-solr/git/refs{/sha}","trees_url":"https://api.github.com/repos/lucidworks/spark-solr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lucidworks/spark-solr/statuses/{sha}","languages_url":"https://api.github.com/repos/lucidworks/spark-solr/languages","stargazers_url":"https://api.github.com/repos/lucidworks/spark-solr/stargazers","contributors_url":"https://api.github.com/repos/lucidworks/spark-solr/contributors","subscribers_url":"https://api.github.com/repos/lucidworks/spark-solr/subscribers","subscription_url":"https://api.github.com/repos/lucidworks/spark-solr/subscription","commits_url":"https://api.github.com/repos/lucidworks/spark-solr/commits{/sha}","git_commits_url":"https://api.github.com/repos/lucidworks/spark-solr/git/commits{/sha}","comments_url":"https://api.github.com/repos/lucidworks/spark-solr/comments{/number}","issue_comment_url":"https://api.github.com/repos/lucidworks/spark-solr/issues/comments{/number}","contents_url":"https://api.github.com/repos/lucidworks/spark-solr/contents/{+path}","compare_url":"https://api.github.com/repos/lucidworks/spark-solr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lucidworks/spark-solr/merges","archive_url":"https://api.github.com/repos/lucidworks/spark-solr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lucidworks/spark-solr/downloads","issues_url":"https://api.github.com/repos/lucidworks/spark-solr/issues{/number}","pulls_url":"https://api.github.com/repos/lucidworks/spark-solr/pulls{/number}","milestones_url":"https://api.github.com/repos/lucidworks/spark-solr/milestones{/number}","notifications_url":"https://api.github.com/repos/lucidworks/spark-solr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lucidworks/spark-solr/labels{/name}","releases_url":"https://api.github.com/repos/lucidworks/spark-solr/releases{/id}","deployments_url":"https://api.github.com/repos/lucidworks/spark-solr/deployments","created_at":"2015-01-15T15:33:38Z","updated_at":"2016-06-16T02:36:51Z","pushed_at":"2016-06-20T23:09:56Z","git_url":"git://github.com/lucidworks/spark-solr.git","ssh_url":"git@github.com:lucidworks/spark-solr.git","clone_url":"https://github.com/lucidworks/spark-solr.git","svn_url":"https://github.com/lucidworks/spark-solr","homepage":null,"size":1334,"stargazers_count":161,"watchers_count":161,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":94,"mirror_url":null,"open_issues_count":11,"forks":94,"open_issues":11,"watchers":161,"default_branch":"master"}},"base":{"label":"lucidworks:master","ref":"master","sha":"279034aa65f9c188c281b677450697aac8c4988e","user":{"login":"lucidworks","id":4417866,"avatar_url":"https://avatars.githubusercontent.com/u/4417866?v=3","gravatar_id":"","url":"https://api.github.com/users/lucidworks","html_url":"https://github.com/lucidworks","followers_url":"https://api.github.com/users/lucidworks/followers","following_url":"https://api.github.com/users/lucidworks/following{/other_user}","gists_url":"https://api.github.com/users/lucidworks/gists{/gist_id}","starred_url":"https://api.github.com/users/lucidworks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lucidworks/subscriptions","organizations_url":"https://api.github.com/users/lucidworks/orgs","repos_url":"https://api.github.com/users/lucidworks/repos","events_url":"https://api.github.com/users/lucidworks/events{/privacy}","received_events_url":"https://api.github.com/users/lucidworks/received_events","type":"Organization","site_admin":false},"repo":{"id":29303892,"name":"spark-solr","full_name":"lucidworks/spark-solr","owner":{"login":"lucidworks","id":4417866,"avatar_url":"https://avatars.githubusercontent.com/u/4417866?v=3","gravatar_id":"","url":"https://api.github.com/users/lucidworks","html_url":"https://github.com/lucidworks","followers_url":"https://api.github.com/users/lucidworks/followers","following_url":"https://api.github.com/users/lucidworks/following{/other_user}","gists_url":"https://api.github.com/users/lucidworks/gists{/gist_id}","starred_url":"https://api.github.com/users/lucidworks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lucidworks/subscriptions","organizations_url":"https://api.github.com/users/lucidworks/orgs","repos_url":"https://api.github.com/users/lucidworks/repos","events_url":"https://api.github.com/users/lucidworks/events{/privacy}","received_events_url":"https://api.github.com/users/lucidworks/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lucidworks/spark-solr","description":"Tools for reading data from Solr as a Spark RDD and indexing objects from Spark into Solr using SolrJ.","fork":false,"url":"https://api.github.com/repos/lucidworks/spark-solr","forks_url":"https://api.github.com/repos/lucidworks/spark-solr/forks","keys_url":"https://api.github.com/repos/lucidworks/spark-solr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lucidworks/spark-solr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lucidworks/spark-solr/teams","hooks_url":"https://api.github.com/repos/lucidworks/spark-solr/hooks","issue_events_url":"https://api.github.com/repos/lucidworks/spark-solr/issues/events{/number}","events_url":"https://api.github.com/repos/lucidworks/spark-solr/events","assignees_url":"https://api.github.com/repos/lucidworks/spark-solr/assignees{/user}","branches_url":"https://api.github.com/repos/lucidworks/spark-solr/branches{/branch}","tags_url":"https://api.github.com/repos/lucidworks/spark-solr/tags","blobs_url":"https://api.github.com/repos/lucidworks/spark-solr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lucidworks/spark-solr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lucidworks/spark-solr/git/refs{/sha}","trees_url":"https://api.github.com/repos/lucidworks/spark-solr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lucidworks/spark-solr/statuses/{sha}","languages_url":"https://api.github.com/repos/lucidworks/spark-solr/languages","stargazers_url":"https://api.github.com/repos/lucidworks/spark-solr/stargazers","contributors_url":"https://api.github.com/repos/lucidworks/spark-solr/contributors","subscribers_url":"https://api.github.com/repos/lucidworks/spark-solr/subscribers","subscription_url":"https://api.github.com/repos/lucidworks/spark-solr/subscription","commits_url":"https://api.github.com/repos/lucidworks/spark-solr/commits{/sha}","git_commits_url":"https://api.github.com/repos/lucidworks/spark-solr/git/commits{/sha}","comments_url":"https://api.github.com/repos/lucidworks/spark-solr/comments{/number}","issue_comment_url":"https://api.github.com/repos/lucidworks/spark-solr/issues/comments{/number}","contents_url":"https://api.github.com/repos/lucidworks/spark-solr/contents/{+path}","compare_url":"https://api.github.com/repos/lucidworks/spark-solr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lucidworks/spark-solr/merges","archive_url":"https://api.github.com/repos/lucidworks/spark-solr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lucidworks/spark-solr/downloads","issues_url":"https://api.github.com/repos/lucidworks/spark-solr/issues{/number}","pulls_url":"https://api.github.com/repos/lucidworks/spark-solr/pulls{/number}","milestones_url":"https://api.github.com/repos/lucidworks/spark-solr/milestones{/number}","notifications_url":"https://api.github.com/repos/lucidworks/spark-solr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lucidworks/spark-solr/labels{/name}","releases_url":"https://api.github.com/repos/lucidworks/spark-solr/releases{/id}","deployments_url":"https://api.github.com/repos/lucidworks/spark-solr/deployments","created_at":"2015-01-15T15:33:38Z","updated_at":"2016-06-16T02:36:51Z","pushed_at":"2016-06-20T23:09:56Z","git_url":"git://github.com/lucidworks/spark-solr.git","ssh_url":"git@github.com:lucidworks/spark-solr.git","clone_url":"https://github.com/lucidworks/spark-solr.git","svn_url":"https://github.com/lucidworks/spark-solr","homepage":null,"size":1334,"stargazers_count":161,"watchers_count":161,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":94,"mirror_url":null,"open_issues_count":11,"forks":94,"open_issues":11,"watchers":161,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/lucidworks/spark-solr/pulls/72"},"html":{"href":"https://github.com/lucidworks/spark-solr/pull/72"},"issue":{"href":"https://api.github.com/repos/lucidworks/spark-solr/issues/72"},"comments":{"href":"https://api.github.com/repos/lucidworks/spark-solr/issues/72/comments"},"review_comments":{"href":"https://api.github.com/repos/lucidworks/spark-solr/pulls/72/comments"},"review_comment":{"href":"https://api.github.com/repos/lucidworks/spark-solr/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/lucidworks/spark-solr/pulls/72/commits"},"statuses":{"href":"https://api.github.com/repos/lucidworks/spark-solr/statuses/d80c28b2a3471a39959e10856f266221f1d94589"}}}}
{"actor":{"display_login":"thelabdude"}}