id int32 0 165k | repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1 value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 |
|---|---|---|---|---|---|---|---|---|---|---|---|
25,800 | apache/incubator-gobblin | gobblin-core-base/src/main/java/org/apache/gobblin/instrumented/extractor/InstrumentedExtractorBase.java | InstrumentedExtractorBase.afterRead | public void afterRead(D record, long startTime) {
Instrumented.updateTimer(this.extractorTimer, System.nanoTime() - startTime, TimeUnit.NANOSECONDS);
if (record != null) {
Instrumented.markMeter(this.readRecordsMeter);
}
} | java | public void afterRead(D record, long startTime) {
Instrumented.updateTimer(this.extractorTimer, System.nanoTime() - startTime, TimeUnit.NANOSECONDS);
if (record != null) {
Instrumented.markMeter(this.readRecordsMeter);
}
} | [
"public",
"void",
"afterRead",
"(",
"D",
"record",
",",
"long",
"startTime",
")",
"{",
"Instrumented",
".",
"updateTimer",
"(",
"this",
".",
"extractorTimer",
",",
"System",
".",
"nanoTime",
"(",
")",
"-",
"startTime",
",",
"TimeUnit",
".",
"NANOSECONDS",
")",
";",
"if",
"(",
"record",
"!=",
"null",
")",
"{",
"Instrumented",
".",
"markMeter",
"(",
"this",
".",
"readRecordsMeter",
")",
";",
"}",
"}"
] | Called after each record is read.
@param record record read.
@param startTime reading start time. | [
"Called",
"after",
"each",
"record",
"is",
"read",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-core-base/src/main/java/org/apache/gobblin/instrumented/extractor/InstrumentedExtractorBase.java#L208-L213 |
25,801 | apache/incubator-gobblin | gobblin-metrics-libs/gobblin-metrics-base/src/main/java/org/apache/gobblin/metrics/event/MultiTimingEvent.java | MultiTimingEvent.nextStage | public void nextStage(String name) throws IOException {
endStage();
this.currentStage = name;
this.currentStageStart = System.currentTimeMillis();
} | java | public void nextStage(String name) throws IOException {
endStage();
this.currentStage = name;
this.currentStageStart = System.currentTimeMillis();
} | [
"public",
"void",
"nextStage",
"(",
"String",
"name",
")",
"throws",
"IOException",
"{",
"endStage",
"(",
")",
";",
"this",
".",
"currentStage",
"=",
"name",
";",
"this",
".",
"currentStageStart",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"}"
] | End the previous stage, record the time spent in that stage, and start the timer for a new stage.
@param name name of the new stage.
@throws IOException | [
"End",
"the",
"previous",
"stage",
"record",
"the",
"time",
"spent",
"in",
"that",
"stage",
"and",
"start",
"the",
"timer",
"for",
"a",
"new",
"stage",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-metrics-libs/gobblin-metrics-base/src/main/java/org/apache/gobblin/metrics/event/MultiTimingEvent.java#L88-L92 |
25,802 | apache/incubator-gobblin | gobblin-metrics-libs/gobblin-metrics-base/src/main/java/org/apache/gobblin/metrics/event/MultiTimingEvent.java | MultiTimingEvent.endStage | public void endStage() {
if (this.currentStage != null) {
long time = System.currentTimeMillis() - this.currentStageStart;
this.timings.add(new Stage(this.currentStage, time));
if (reportAsMetrics && submitter.getMetricContext().isPresent()) {
String timerName = submitter.getNamespace() + "." + name + "." + this.currentStage;
submitter.getMetricContext().get().timer(timerName).update(time, TimeUnit.MILLISECONDS);
}
}
this.currentStage = null;
} | java | public void endStage() {
if (this.currentStage != null) {
long time = System.currentTimeMillis() - this.currentStageStart;
this.timings.add(new Stage(this.currentStage, time));
if (reportAsMetrics && submitter.getMetricContext().isPresent()) {
String timerName = submitter.getNamespace() + "." + name + "." + this.currentStage;
submitter.getMetricContext().get().timer(timerName).update(time, TimeUnit.MILLISECONDS);
}
}
this.currentStage = null;
} | [
"public",
"void",
"endStage",
"(",
")",
"{",
"if",
"(",
"this",
".",
"currentStage",
"!=",
"null",
")",
"{",
"long",
"time",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"this",
".",
"currentStageStart",
";",
"this",
".",
"timings",
".",
"add",
"(",
"new",
"Stage",
"(",
"this",
".",
"currentStage",
",",
"time",
")",
")",
";",
"if",
"(",
"reportAsMetrics",
"&&",
"submitter",
".",
"getMetricContext",
"(",
")",
".",
"isPresent",
"(",
")",
")",
"{",
"String",
"timerName",
"=",
"submitter",
".",
"getNamespace",
"(",
")",
"+",
"\".\"",
"+",
"name",
"+",
"\".\"",
"+",
"this",
".",
"currentStage",
";",
"submitter",
".",
"getMetricContext",
"(",
")",
".",
"get",
"(",
")",
".",
"timer",
"(",
"timerName",
")",
".",
"update",
"(",
"time",
",",
"TimeUnit",
".",
"MILLISECONDS",
")",
";",
"}",
"}",
"this",
".",
"currentStage",
"=",
"null",
";",
"}"
] | End the previous stage and record the time spent in that stage. | [
"End",
"the",
"previous",
"stage",
"and",
"record",
"the",
"time",
"spent",
"in",
"that",
"stage",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-metrics-libs/gobblin-metrics-base/src/main/java/org/apache/gobblin/metrics/event/MultiTimingEvent.java#L97-L107 |
25,803 | apache/incubator-gobblin | gobblin-metrics-libs/gobblin-metrics-base/src/main/java/org/apache/gobblin/metrics/event/MultiTimingEvent.java | MultiTimingEvent.submit | public void submit(Map<String, String> additionalMetadata) throws IOException {
if (this.submitted) {
throw new IOException("MultiTimingEvent has already been submitted.");
}
this.submitted = true;
endStage();
Map<String, String> finalMetadata = Maps.newHashMap();
finalMetadata.putAll(additionalMetadata);
finalMetadata.put(EventSubmitter.EVENT_TYPE, MULTI_TIMING_EVENT);
for (Stage timing : this.timings) {
finalMetadata.put(timing.getName(), Long.toString(timing.getDuration()));
}
this.submitter.submit(this.name, finalMetadata);
} | java | public void submit(Map<String, String> additionalMetadata) throws IOException {
if (this.submitted) {
throw new IOException("MultiTimingEvent has already been submitted.");
}
this.submitted = true;
endStage();
Map<String, String> finalMetadata = Maps.newHashMap();
finalMetadata.putAll(additionalMetadata);
finalMetadata.put(EventSubmitter.EVENT_TYPE, MULTI_TIMING_EVENT);
for (Stage timing : this.timings) {
finalMetadata.put(timing.getName(), Long.toString(timing.getDuration()));
}
this.submitter.submit(this.name, finalMetadata);
} | [
"public",
"void",
"submit",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"additionalMetadata",
")",
"throws",
"IOException",
"{",
"if",
"(",
"this",
".",
"submitted",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"MultiTimingEvent has already been submitted.\"",
")",
";",
"}",
"this",
".",
"submitted",
"=",
"true",
";",
"endStage",
"(",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"finalMetadata",
"=",
"Maps",
".",
"newHashMap",
"(",
")",
";",
"finalMetadata",
".",
"putAll",
"(",
"additionalMetadata",
")",
";",
"finalMetadata",
".",
"put",
"(",
"EventSubmitter",
".",
"EVENT_TYPE",
",",
"MULTI_TIMING_EVENT",
")",
";",
"for",
"(",
"Stage",
"timing",
":",
"this",
".",
"timings",
")",
"{",
"finalMetadata",
".",
"put",
"(",
"timing",
".",
"getName",
"(",
")",
",",
"Long",
".",
"toString",
"(",
"timing",
".",
"getDuration",
"(",
")",
")",
")",
";",
"}",
"this",
".",
"submitter",
".",
"submit",
"(",
"this",
".",
"name",
",",
"finalMetadata",
")",
";",
"}"
] | Ends the current stage and submits the event containing the timings of each event.
@param additionalMetadata additional metadata to include in the event.
@throws IOException | [
"Ends",
"the",
"current",
"stage",
"and",
"submits",
"the",
"event",
"containing",
"the",
"timings",
"of",
"each",
"event",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-metrics-libs/gobblin-metrics-base/src/main/java/org/apache/gobblin/metrics/event/MultiTimingEvent.java#L122-L139 |
25,804 | apache/incubator-gobblin | gobblin-admin/src/main/java/org/apache/gobblin/cli/AdminClient.java | AdminClient.queryByJobId | public Optional<JobExecutionInfo> queryByJobId(String id) throws RemoteInvocationException {
JobExecutionQuery query = new JobExecutionQuery();
query.setIdType(QueryIdTypeEnum.JOB_ID);
query.setId(JobExecutionQuery.Id.create(id));
query.setLimit(1);
List<JobExecutionInfo> results = executeQuery(query);
return getFirstFromQueryResults(results);
} | java | public Optional<JobExecutionInfo> queryByJobId(String id) throws RemoteInvocationException {
JobExecutionQuery query = new JobExecutionQuery();
query.setIdType(QueryIdTypeEnum.JOB_ID);
query.setId(JobExecutionQuery.Id.create(id));
query.setLimit(1);
List<JobExecutionInfo> results = executeQuery(query);
return getFirstFromQueryResults(results);
} | [
"public",
"Optional",
"<",
"JobExecutionInfo",
">",
"queryByJobId",
"(",
"String",
"id",
")",
"throws",
"RemoteInvocationException",
"{",
"JobExecutionQuery",
"query",
"=",
"new",
"JobExecutionQuery",
"(",
")",
";",
"query",
".",
"setIdType",
"(",
"QueryIdTypeEnum",
".",
"JOB_ID",
")",
";",
"query",
".",
"setId",
"(",
"JobExecutionQuery",
".",
"Id",
".",
"create",
"(",
"id",
")",
")",
";",
"query",
".",
"setLimit",
"(",
"1",
")",
";",
"List",
"<",
"JobExecutionInfo",
">",
"results",
"=",
"executeQuery",
"(",
"query",
")",
";",
"return",
"getFirstFromQueryResults",
"(",
"results",
")",
";",
"}"
] | Retrieve a Gobblin job by its id.
@param id Id of the job to retrieve
@return JobExecutionInfo representing the job | [
"Retrieve",
"a",
"Gobblin",
"job",
"by",
"its",
"id",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-admin/src/main/java/org/apache/gobblin/cli/AdminClient.java#L66-L74 |
25,805 | apache/incubator-gobblin | gobblin-admin/src/main/java/org/apache/gobblin/cli/AdminClient.java | AdminClient.queryAllJobs | public List<JobExecutionInfo> queryAllJobs(QueryListType lookupType, int resultsLimit)
throws RemoteInvocationException {
JobExecutionQuery query = new JobExecutionQuery();
query.setIdType(QueryIdTypeEnum.LIST_TYPE);
query.setId(JobExecutionQuery.Id.create(lookupType));
// Disable properties and task executions (prevents response size from ballooning)
query.setJobProperties(ConfigurationKeys.JOB_RUN_ONCE_KEY + "," + ConfigurationKeys.JOB_SCHEDULE_KEY);
query.setIncludeTaskExecutions(false);
query.setLimit(resultsLimit);
return executeQuery(query);
} | java | public List<JobExecutionInfo> queryAllJobs(QueryListType lookupType, int resultsLimit)
throws RemoteInvocationException {
JobExecutionQuery query = new JobExecutionQuery();
query.setIdType(QueryIdTypeEnum.LIST_TYPE);
query.setId(JobExecutionQuery.Id.create(lookupType));
// Disable properties and task executions (prevents response size from ballooning)
query.setJobProperties(ConfigurationKeys.JOB_RUN_ONCE_KEY + "," + ConfigurationKeys.JOB_SCHEDULE_KEY);
query.setIncludeTaskExecutions(false);
query.setLimit(resultsLimit);
return executeQuery(query);
} | [
"public",
"List",
"<",
"JobExecutionInfo",
">",
"queryAllJobs",
"(",
"QueryListType",
"lookupType",
",",
"int",
"resultsLimit",
")",
"throws",
"RemoteInvocationException",
"{",
"JobExecutionQuery",
"query",
"=",
"new",
"JobExecutionQuery",
"(",
")",
";",
"query",
".",
"setIdType",
"(",
"QueryIdTypeEnum",
".",
"LIST_TYPE",
")",
";",
"query",
".",
"setId",
"(",
"JobExecutionQuery",
".",
"Id",
".",
"create",
"(",
"lookupType",
")",
")",
";",
"// Disable properties and task executions (prevents response size from ballooning)",
"query",
".",
"setJobProperties",
"(",
"ConfigurationKeys",
".",
"JOB_RUN_ONCE_KEY",
"+",
"\",\"",
"+",
"ConfigurationKeys",
".",
"JOB_SCHEDULE_KEY",
")",
";",
"query",
".",
"setIncludeTaskExecutions",
"(",
"false",
")",
";",
"query",
".",
"setLimit",
"(",
"resultsLimit",
")",
";",
"return",
"executeQuery",
"(",
"query",
")",
";",
"}"
] | Retrieve all jobs
@param lookupType Query type
@return List of all jobs (limited by results limit) | [
"Retrieve",
"all",
"jobs"
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-admin/src/main/java/org/apache/gobblin/cli/AdminClient.java#L82-L95 |
25,806 | apache/incubator-gobblin | gobblin-admin/src/main/java/org/apache/gobblin/cli/AdminClient.java | AdminClient.queryByJobName | public List<JobExecutionInfo> queryByJobName(String name, int resultsLimit) throws RemoteInvocationException {
JobExecutionQuery query = new JobExecutionQuery();
query.setIdType(QueryIdTypeEnum.JOB_NAME);
query.setId(JobExecutionQuery.Id.create(name));
query.setIncludeTaskExecutions(false);
query.setLimit(resultsLimit);
return executeQuery(query);
} | java | public List<JobExecutionInfo> queryByJobName(String name, int resultsLimit) throws RemoteInvocationException {
JobExecutionQuery query = new JobExecutionQuery();
query.setIdType(QueryIdTypeEnum.JOB_NAME);
query.setId(JobExecutionQuery.Id.create(name));
query.setIncludeTaskExecutions(false);
query.setLimit(resultsLimit);
return executeQuery(query);
} | [
"public",
"List",
"<",
"JobExecutionInfo",
">",
"queryByJobName",
"(",
"String",
"name",
",",
"int",
"resultsLimit",
")",
"throws",
"RemoteInvocationException",
"{",
"JobExecutionQuery",
"query",
"=",
"new",
"JobExecutionQuery",
"(",
")",
";",
"query",
".",
"setIdType",
"(",
"QueryIdTypeEnum",
".",
"JOB_NAME",
")",
";",
"query",
".",
"setId",
"(",
"JobExecutionQuery",
".",
"Id",
".",
"create",
"(",
"name",
")",
")",
";",
"query",
".",
"setIncludeTaskExecutions",
"(",
"false",
")",
";",
"query",
".",
"setLimit",
"(",
"resultsLimit",
")",
";",
"return",
"executeQuery",
"(",
"query",
")",
";",
"}"
] | Query jobs by name
@param name Name of the job to query for
@param resultsLimit Max # of results to return
@return List of jobs with the name (empty list if none can be found) | [
"Query",
"jobs",
"by",
"name"
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-admin/src/main/java/org/apache/gobblin/cli/AdminClient.java#L104-L112 |
25,807 | apache/incubator-gobblin | gobblin-admin/src/main/java/org/apache/gobblin/cli/AdminClient.java | AdminClient.executeQuery | private List<JobExecutionInfo> executeQuery(JobExecutionQuery query) throws RemoteInvocationException {
JobExecutionQueryResult result = this.client.get(query);
if (result != null && result.hasJobExecutions()) {
return result.getJobExecutions();
}
return Collections.emptyList();
} | java | private List<JobExecutionInfo> executeQuery(JobExecutionQuery query) throws RemoteInvocationException {
JobExecutionQueryResult result = this.client.get(query);
if (result != null && result.hasJobExecutions()) {
return result.getJobExecutions();
}
return Collections.emptyList();
} | [
"private",
"List",
"<",
"JobExecutionInfo",
">",
"executeQuery",
"(",
"JobExecutionQuery",
"query",
")",
"throws",
"RemoteInvocationException",
"{",
"JobExecutionQueryResult",
"result",
"=",
"this",
".",
"client",
".",
"get",
"(",
"query",
")",
";",
"if",
"(",
"result",
"!=",
"null",
"&&",
"result",
".",
"hasJobExecutions",
"(",
")",
")",
"{",
"return",
"result",
".",
"getJobExecutions",
"(",
")",
";",
"}",
"return",
"Collections",
".",
"emptyList",
"(",
")",
";",
"}"
] | Execute a query and coerce the result into a java List
@param query Query to execute
@return List of jobs that matched the query. (Empty list if none did).
@throws RemoteInvocationException If the server throws an error | [
"Execute",
"a",
"query",
"and",
"coerce",
"the",
"result",
"into",
"a",
"java",
"List"
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-admin/src/main/java/org/apache/gobblin/cli/AdminClient.java#L120-L127 |
25,808 | apache/incubator-gobblin | gobblin-runtime/src/main/java/org/apache/gobblin/runtime/Task.java | Task.shouldPublishDataInTask | private boolean shouldPublishDataInTask() {
boolean publishDataAtJobLevel = this.taskState.getPropAsBoolean(ConfigurationKeys.PUBLISH_DATA_AT_JOB_LEVEL,
ConfigurationKeys.DEFAULT_PUBLISH_DATA_AT_JOB_LEVEL);
if (publishDataAtJobLevel) {
LOG.info(String
.format("%s is true. Will publish data at the job level.", ConfigurationKeys.PUBLISH_DATA_AT_JOB_LEVEL));
return false;
}
JobCommitPolicy jobCommitPolicy = JobCommitPolicy.getCommitPolicy(this.taskState);
if (jobCommitPolicy == JobCommitPolicy.COMMIT_SUCCESSFUL_TASKS) {
return this.taskState.getWorkingState() == WorkUnitState.WorkingState.SUCCESSFUL;
}
if (jobCommitPolicy == JobCommitPolicy.COMMIT_ON_PARTIAL_SUCCESS) {
return true;
}
LOG.info("Will publish data at the job level with job commit policy: " + jobCommitPolicy);
return false;
} | java | private boolean shouldPublishDataInTask() {
boolean publishDataAtJobLevel = this.taskState.getPropAsBoolean(ConfigurationKeys.PUBLISH_DATA_AT_JOB_LEVEL,
ConfigurationKeys.DEFAULT_PUBLISH_DATA_AT_JOB_LEVEL);
if (publishDataAtJobLevel) {
LOG.info(String
.format("%s is true. Will publish data at the job level.", ConfigurationKeys.PUBLISH_DATA_AT_JOB_LEVEL));
return false;
}
JobCommitPolicy jobCommitPolicy = JobCommitPolicy.getCommitPolicy(this.taskState);
if (jobCommitPolicy == JobCommitPolicy.COMMIT_SUCCESSFUL_TASKS) {
return this.taskState.getWorkingState() == WorkUnitState.WorkingState.SUCCESSFUL;
}
if (jobCommitPolicy == JobCommitPolicy.COMMIT_ON_PARTIAL_SUCCESS) {
return true;
}
LOG.info("Will publish data at the job level with job commit policy: " + jobCommitPolicy);
return false;
} | [
"private",
"boolean",
"shouldPublishDataInTask",
"(",
")",
"{",
"boolean",
"publishDataAtJobLevel",
"=",
"this",
".",
"taskState",
".",
"getPropAsBoolean",
"(",
"ConfigurationKeys",
".",
"PUBLISH_DATA_AT_JOB_LEVEL",
",",
"ConfigurationKeys",
".",
"DEFAULT_PUBLISH_DATA_AT_JOB_LEVEL",
")",
";",
"if",
"(",
"publishDataAtJobLevel",
")",
"{",
"LOG",
".",
"info",
"(",
"String",
".",
"format",
"(",
"\"%s is true. Will publish data at the job level.\"",
",",
"ConfigurationKeys",
".",
"PUBLISH_DATA_AT_JOB_LEVEL",
")",
")",
";",
"return",
"false",
";",
"}",
"JobCommitPolicy",
"jobCommitPolicy",
"=",
"JobCommitPolicy",
".",
"getCommitPolicy",
"(",
"this",
".",
"taskState",
")",
";",
"if",
"(",
"jobCommitPolicy",
"==",
"JobCommitPolicy",
".",
"COMMIT_SUCCESSFUL_TASKS",
")",
"{",
"return",
"this",
".",
"taskState",
".",
"getWorkingState",
"(",
")",
"==",
"WorkUnitState",
".",
"WorkingState",
".",
"SUCCESSFUL",
";",
"}",
"if",
"(",
"jobCommitPolicy",
"==",
"JobCommitPolicy",
".",
"COMMIT_ON_PARTIAL_SUCCESS",
")",
"{",
"return",
"true",
";",
"}",
"LOG",
".",
"info",
"(",
"\"Will publish data at the job level with job commit policy: \"",
"+",
"jobCommitPolicy",
")",
";",
"return",
"false",
";",
"}"
] | Whether the task should directly publish its output data to the final publisher output directory.
<p>
The task should publish its output data directly if {@link ConfigurationKeys#PUBLISH_DATA_AT_JOB_LEVEL}
is set to false AND any of the following conditions is satisfied:
<ul>
<li>The {@link JobCommitPolicy#COMMIT_ON_PARTIAL_SUCCESS} policy is used.</li>
<li>The {@link JobCommitPolicy#COMMIT_SUCCESSFUL_TASKS} policy is used. and all {@link Fork}s of this
{@link Task} succeeded.</li>
</ul>
</p> | [
"Whether",
"the",
"task",
"should",
"directly",
"publish",
"its",
"output",
"data",
"to",
"the",
"final",
"publisher",
"output",
"directory",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-runtime/src/main/java/org/apache/gobblin/runtime/Task.java#L570-L591 |
25,809 | apache/incubator-gobblin | gobblin-runtime/src/main/java/org/apache/gobblin/runtime/Task.java | Task.inMultipleBranches | private static boolean inMultipleBranches(List<Boolean> branches) {
int inBranches = 0;
for (Boolean bool : branches) {
if (bool && ++inBranches > 1) {
break;
}
}
return inBranches > 1;
} | java | private static boolean inMultipleBranches(List<Boolean> branches) {
int inBranches = 0;
for (Boolean bool : branches) {
if (bool && ++inBranches > 1) {
break;
}
}
return inBranches > 1;
} | [
"private",
"static",
"boolean",
"inMultipleBranches",
"(",
"List",
"<",
"Boolean",
">",
"branches",
")",
"{",
"int",
"inBranches",
"=",
"0",
";",
"for",
"(",
"Boolean",
"bool",
":",
"branches",
")",
"{",
"if",
"(",
"bool",
"&&",
"++",
"inBranches",
">",
"1",
")",
"{",
"break",
";",
"}",
"}",
"return",
"inBranches",
">",
"1",
";",
"}"
] | Check if a schema or data record is being passed to more than one branches. | [
"Check",
"if",
"a",
"schema",
"or",
"data",
"record",
"is",
"being",
"passed",
"to",
"more",
"than",
"one",
"branches",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-runtime/src/main/java/org/apache/gobblin/runtime/Task.java#L812-L820 |
25,810 | apache/incubator-gobblin | gobblin-runtime/src/main/java/org/apache/gobblin/runtime/Task.java | Task.cancel | public synchronized boolean cancel() {
if (this.taskFuture != null && this.taskFuture.cancel(true)) {
this.taskStateTracker.onTaskRunCompletion(this);
this.completeShutdown();
return true;
} else {
return false;
}
} | java | public synchronized boolean cancel() {
if (this.taskFuture != null && this.taskFuture.cancel(true)) {
this.taskStateTracker.onTaskRunCompletion(this);
this.completeShutdown();
return true;
} else {
return false;
}
} | [
"public",
"synchronized",
"boolean",
"cancel",
"(",
")",
"{",
"if",
"(",
"this",
".",
"taskFuture",
"!=",
"null",
"&&",
"this",
".",
"taskFuture",
".",
"cancel",
"(",
"true",
")",
")",
"{",
"this",
".",
"taskStateTracker",
".",
"onTaskRunCompletion",
"(",
"this",
")",
";",
"this",
".",
"completeShutdown",
"(",
")",
";",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] | return true if the task is successfully cancelled.
@return | [
"return",
"true",
"if",
"the",
"task",
"is",
"successfully",
"cancelled",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-runtime/src/main/java/org/apache/gobblin/runtime/Task.java#L1012-L1020 |
25,811 | apache/incubator-gobblin | gobblin-modules/gobblin-kafka-common/src/main/java/org/apache/gobblin/source/extractor/extract/kafka/KafkaAvroExtractor.java | KafkaAvroExtractor.convertRecord | @Override
protected GenericRecord convertRecord(GenericRecord record) throws IOException {
return AvroUtils.convertRecordSchema(record, this.schema.get());
} | java | @Override
protected GenericRecord convertRecord(GenericRecord record) throws IOException {
return AvroUtils.convertRecordSchema(record, this.schema.get());
} | [
"@",
"Override",
"protected",
"GenericRecord",
"convertRecord",
"(",
"GenericRecord",
"record",
")",
"throws",
"IOException",
"{",
"return",
"AvroUtils",
".",
"convertRecordSchema",
"(",
"record",
",",
"this",
".",
"schema",
".",
"get",
"(",
")",
")",
";",
"}"
] | Convert the record to the output schema of this extractor
@param record the input record
@return the converted record
@throws IOException | [
"Convert",
"the",
"record",
"to",
"the",
"output",
"schema",
"of",
"this",
"extractor"
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-kafka-common/src/main/java/org/apache/gobblin/source/extractor/extract/kafka/KafkaAvroExtractor.java#L130-L133 |
25,812 | apache/incubator-gobblin | gobblin-config-management/gobblin-config-core/src/main/java/org/apache/gobblin/config/store/zip/ZipFileConfigStore.java | ZipFileConfigStore.getDatasetDirForKey | private Path getDatasetDirForKey(ConfigKeyPath configKey) throws VersionDoesNotExistException {
return this.fs.getPath(this.storePrefix, configKey.getAbsolutePathString());
} | java | private Path getDatasetDirForKey(ConfigKeyPath configKey) throws VersionDoesNotExistException {
return this.fs.getPath(this.storePrefix, configKey.getAbsolutePathString());
} | [
"private",
"Path",
"getDatasetDirForKey",
"(",
"ConfigKeyPath",
"configKey",
")",
"throws",
"VersionDoesNotExistException",
"{",
"return",
"this",
".",
"fs",
".",
"getPath",
"(",
"this",
".",
"storePrefix",
",",
"configKey",
".",
"getAbsolutePathString",
"(",
")",
")",
";",
"}"
] | Get path object using zipped file system and relative path | [
"Get",
"path",
"object",
"using",
"zipped",
"file",
"system",
"and",
"relative",
"path"
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-config-management/gobblin-config-core/src/main/java/org/apache/gobblin/config/store/zip/ZipFileConfigStore.java#L196-L198 |
25,813 | apache/incubator-gobblin | gobblin-modules/gobblin-service-kafka/src/main/java/org/apache/gobblin/service/StreamingKafkaSpecConsumer.java | StreamingKafkaSpecConsumer.changedSpecs | @Override
public Future<? extends List<Pair<SpecExecutor.Verb, Spec>>> changedSpecs() {
List<Pair<SpecExecutor.Verb, Spec>> changesSpecs = new ArrayList<>();
try {
Pair<SpecExecutor.Verb, Spec> specPair = _jobSpecQueue.take();
_metrics.jobSpecDeqCount.incrementAndGet();
do {
changesSpecs.add(specPair);
// if there are more elements then pass them along in this call
specPair = _jobSpecQueue.poll();
} while (specPair != null);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
return new CompletedFuture(changesSpecs, null);
} | java | @Override
public Future<? extends List<Pair<SpecExecutor.Verb, Spec>>> changedSpecs() {
List<Pair<SpecExecutor.Verb, Spec>> changesSpecs = new ArrayList<>();
try {
Pair<SpecExecutor.Verb, Spec> specPair = _jobSpecQueue.take();
_metrics.jobSpecDeqCount.incrementAndGet();
do {
changesSpecs.add(specPair);
// if there are more elements then pass them along in this call
specPair = _jobSpecQueue.poll();
} while (specPair != null);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
return new CompletedFuture(changesSpecs, null);
} | [
"@",
"Override",
"public",
"Future",
"<",
"?",
"extends",
"List",
"<",
"Pair",
"<",
"SpecExecutor",
".",
"Verb",
",",
"Spec",
">",
">",
">",
"changedSpecs",
"(",
")",
"{",
"List",
"<",
"Pair",
"<",
"SpecExecutor",
".",
"Verb",
",",
"Spec",
">",
">",
"changesSpecs",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"try",
"{",
"Pair",
"<",
"SpecExecutor",
".",
"Verb",
",",
"Spec",
">",
"specPair",
"=",
"_jobSpecQueue",
".",
"take",
"(",
")",
";",
"_metrics",
".",
"jobSpecDeqCount",
".",
"incrementAndGet",
"(",
")",
";",
"do",
"{",
"changesSpecs",
".",
"add",
"(",
"specPair",
")",
";",
"// if there are more elements then pass them along in this call",
"specPair",
"=",
"_jobSpecQueue",
".",
"poll",
"(",
")",
";",
"}",
"while",
"(",
"specPair",
"!=",
"null",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"Thread",
".",
"currentThread",
"(",
")",
".",
"interrupt",
"(",
")",
";",
"}",
"return",
"new",
"CompletedFuture",
"(",
"changesSpecs",
",",
"null",
")",
";",
"}"
] | This method returns job specs receive from Kafka. It will block if there are no job specs.
@return list of (verb, jobspecs) pairs. | [
"This",
"method",
"returns",
"job",
"specs",
"receive",
"from",
"Kafka",
".",
"It",
"will",
"block",
"if",
"there",
"are",
"no",
"job",
"specs",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-service-kafka/src/main/java/org/apache/gobblin/service/StreamingKafkaSpecConsumer.java#L108-L126 |
25,814 | apache/incubator-gobblin | gobblin-metrics-libs/gobblin-metrics-base/src/main/java/org/apache/gobblin/metrics/InnerMetricContext.java | InnerMetricContext.remove | @Override
public synchronized boolean remove(String name) {
MetricContext metricContext = this.metricContext.get();
if (metricContext != null) {
metricContext.removeFromMetrics(this.contextAwareMetrics.get(name).getContextAwareMetric());
}
return this.contextAwareMetrics.remove(name) != null && removeChildrenMetrics(name);
} | java | @Override
public synchronized boolean remove(String name) {
MetricContext metricContext = this.metricContext.get();
if (metricContext != null) {
metricContext.removeFromMetrics(this.contextAwareMetrics.get(name).getContextAwareMetric());
}
return this.contextAwareMetrics.remove(name) != null && removeChildrenMetrics(name);
} | [
"@",
"Override",
"public",
"synchronized",
"boolean",
"remove",
"(",
"String",
"name",
")",
"{",
"MetricContext",
"metricContext",
"=",
"this",
".",
"metricContext",
".",
"get",
"(",
")",
";",
"if",
"(",
"metricContext",
"!=",
"null",
")",
"{",
"metricContext",
".",
"removeFromMetrics",
"(",
"this",
".",
"contextAwareMetrics",
".",
"get",
"(",
"name",
")",
".",
"getContextAwareMetric",
"(",
")",
")",
";",
"}",
"return",
"this",
".",
"contextAwareMetrics",
".",
"remove",
"(",
"name",
")",
"!=",
"null",
"&&",
"removeChildrenMetrics",
"(",
"name",
")",
";",
"}"
] | Remove a metric with a given name.
<p>
This method will remove the metric with the given name from this {@link MetricContext}
as well as metrics with the same name from every child {@link MetricContext}s.
</p>
@param name name of the metric to be removed
@return whether or not the metric has been removed | [
"Remove",
"a",
"metric",
"with",
"a",
"given",
"name",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-metrics-libs/gobblin-metrics-base/src/main/java/org/apache/gobblin/metrics/InnerMetricContext.java#L299-L306 |
25,815 | apache/incubator-gobblin | gobblin-core/src/main/java/org/apache/gobblin/source/extractor/watermark/SimpleWatermark.java | SimpleWatermark.getInterval | private static long getInterval(long lowWatermarkValue, long highWatermarkValue, long partitionInterval,
int maxIntervals) {
if (lowWatermarkValue > highWatermarkValue) {
LOG.info(
"lowWatermarkValue: " + lowWatermarkValue + " is greater than highWatermarkValue: " + highWatermarkValue);
return 0;
}
long outputInterval = partitionInterval;
boolean longOverflow = false;
long totalIntervals = Long.MAX_VALUE;
try {
totalIntervals = DoubleMath.roundToLong(
(double) highWatermarkValue / partitionInterval - (double) lowWatermarkValue / partitionInterval,
RoundingMode.CEILING);
} catch (java.lang.ArithmeticException e) {
longOverflow = true;
}
if (longOverflow || totalIntervals > maxIntervals) {
outputInterval = DoubleMath.roundToLong(
(double) highWatermarkValue / maxIntervals - (double) lowWatermarkValue / maxIntervals, RoundingMode.CEILING);
}
return outputInterval;
} | java | private static long getInterval(long lowWatermarkValue, long highWatermarkValue, long partitionInterval,
int maxIntervals) {
if (lowWatermarkValue > highWatermarkValue) {
LOG.info(
"lowWatermarkValue: " + lowWatermarkValue + " is greater than highWatermarkValue: " + highWatermarkValue);
return 0;
}
long outputInterval = partitionInterval;
boolean longOverflow = false;
long totalIntervals = Long.MAX_VALUE;
try {
totalIntervals = DoubleMath.roundToLong(
(double) highWatermarkValue / partitionInterval - (double) lowWatermarkValue / partitionInterval,
RoundingMode.CEILING);
} catch (java.lang.ArithmeticException e) {
longOverflow = true;
}
if (longOverflow || totalIntervals > maxIntervals) {
outputInterval = DoubleMath.roundToLong(
(double) highWatermarkValue / maxIntervals - (double) lowWatermarkValue / maxIntervals, RoundingMode.CEILING);
}
return outputInterval;
} | [
"private",
"static",
"long",
"getInterval",
"(",
"long",
"lowWatermarkValue",
",",
"long",
"highWatermarkValue",
",",
"long",
"partitionInterval",
",",
"int",
"maxIntervals",
")",
"{",
"if",
"(",
"lowWatermarkValue",
">",
"highWatermarkValue",
")",
"{",
"LOG",
".",
"info",
"(",
"\"lowWatermarkValue: \"",
"+",
"lowWatermarkValue",
"+",
"\" is greater than highWatermarkValue: \"",
"+",
"highWatermarkValue",
")",
";",
"return",
"0",
";",
"}",
"long",
"outputInterval",
"=",
"partitionInterval",
";",
"boolean",
"longOverflow",
"=",
"false",
";",
"long",
"totalIntervals",
"=",
"Long",
".",
"MAX_VALUE",
";",
"try",
"{",
"totalIntervals",
"=",
"DoubleMath",
".",
"roundToLong",
"(",
"(",
"double",
")",
"highWatermarkValue",
"/",
"partitionInterval",
"-",
"(",
"double",
")",
"lowWatermarkValue",
"/",
"partitionInterval",
",",
"RoundingMode",
".",
"CEILING",
")",
";",
"}",
"catch",
"(",
"java",
".",
"lang",
".",
"ArithmeticException",
"e",
")",
"{",
"longOverflow",
"=",
"true",
";",
"}",
"if",
"(",
"longOverflow",
"||",
"totalIntervals",
">",
"maxIntervals",
")",
"{",
"outputInterval",
"=",
"DoubleMath",
".",
"roundToLong",
"(",
"(",
"double",
")",
"highWatermarkValue",
"/",
"maxIntervals",
"-",
"(",
"double",
")",
"lowWatermarkValue",
"/",
"maxIntervals",
",",
"RoundingMode",
".",
"CEILING",
")",
";",
"}",
"return",
"outputInterval",
";",
"}"
] | recalculate interval if total number of partitions greater than maximum number of allowed partitions
@param lowWatermarkValue low watermark value
@param highWatermarkValue high watermark value
@param partitionInterval partition interval
@param maxIntervals max number of allowed partitions
@return calculated interval | [
"recalculate",
"interval",
"if",
"total",
"number",
"of",
"partitions",
"greater",
"than",
"maximum",
"number",
"of",
"allowed",
"partitions"
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-core/src/main/java/org/apache/gobblin/source/extractor/watermark/SimpleWatermark.java#L94-L118 |
25,816 | apache/incubator-gobblin | gobblin-metrics-libs/gobblin-metrics-base/src/main/java/org/apache/gobblin/metrics/reporter/ScheduledReporter.java | ScheduledReporter.report | protected void report(SortedMap<String, Gauge> gauges, SortedMap<String, Counter> counters,
SortedMap<String, Histogram> histograms, SortedMap<String, Meter> meters, SortedMap<String, Timer> timers,
Map<String, Object> tags, boolean isFinal) {
report(gauges, counters, histograms, meters, timers, tags);
} | java | protected void report(SortedMap<String, Gauge> gauges, SortedMap<String, Counter> counters,
SortedMap<String, Histogram> histograms, SortedMap<String, Meter> meters, SortedMap<String, Timer> timers,
Map<String, Object> tags, boolean isFinal) {
report(gauges, counters, histograms, meters, timers, tags);
} | [
"protected",
"void",
"report",
"(",
"SortedMap",
"<",
"String",
",",
"Gauge",
">",
"gauges",
",",
"SortedMap",
"<",
"String",
",",
"Counter",
">",
"counters",
",",
"SortedMap",
"<",
"String",
",",
"Histogram",
">",
"histograms",
",",
"SortedMap",
"<",
"String",
",",
"Meter",
">",
"meters",
",",
"SortedMap",
"<",
"String",
",",
"Timer",
">",
"timers",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"tags",
",",
"boolean",
"isFinal",
")",
"{",
"report",
"(",
"gauges",
",",
"counters",
",",
"histograms",
",",
"meters",
",",
"timers",
",",
"tags",
")",
";",
"}"
] | Report the input metrics. The input tags apply to all input metrics.
<p>
The default implementation of this method is to ignore the value of isFinal. Sub-classes that are interested in
using the value of isFinal should override this method as well as
{@link #report(SortedMap, SortedMap, SortedMap, SortedMap, SortedMap, Map)}. If they are not interested in the
value of isFinal, they should just override
{@link #report(SortedMap, SortedMap, SortedMap, SortedMap, SortedMap, Map)}.
</p>
@param isFinal true if this is the final time report will be called, false otherwise | [
"Report",
"the",
"input",
"metrics",
".",
"The",
"input",
"tags",
"apply",
"to",
"all",
"input",
"metrics",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-metrics-libs/gobblin-metrics-base/src/main/java/org/apache/gobblin/metrics/reporter/ScheduledReporter.java#L229-L233 |
25,817 | apache/incubator-gobblin | gobblin-restli/gobblin-throttling-service/gobblin-throttling-service-client/src/main/java/org/apache/gobblin/util/limiter/BatchedPermitsRequester.java | BatchedPermitsRequester.getPermits | public boolean getPermits(long permits) throws InterruptedException {
if (permits <= 0) {
return true;
}
long startTimeNanos = System.nanoTime();
this.permitsOutstanding.addEntryWithWeight(permits);
this.lock.lock();
try {
while (true) {
if (permits >= this.knownUnsatisfiablePermits) {
// We are requesting more permits than the remote policy will ever be able to satisfy, return immediately with no permits
break;
}
if (elapsedMillis(startTimeNanos) > this.maxTimeout) {
// Max timeout reached, break
break;
}
if (this.permitBatchContainer.tryTake(permits)) {
this.permitsOutstanding.removeEntryWithWeight(permits);
return true;
}
if (this.retryStatus.canRetryWithinMillis(remainingTime(startTimeNanos, this.maxTimeout))) {
long callbackCounterSnap = this.callbackCounter.get();
maybeSendNewPermitRequest();
if (this.callbackCounter.get() == callbackCounterSnap) {
// If a callback has happened since we tried to send the new permit request, don't await
// Since some request senders may be synchronous, we would have missed the notification
boolean ignore = this.newPermitsAvailable.await(remainingTime(startTimeNanos, this.maxTimeout), TimeUnit.MILLISECONDS);
}
} else {
break;
}
}
} finally {
this.lock.unlock();
}
this.permitsOutstanding.removeEntryWithWeight(permits);
return false;
} | java | public boolean getPermits(long permits) throws InterruptedException {
if (permits <= 0) {
return true;
}
long startTimeNanos = System.nanoTime();
this.permitsOutstanding.addEntryWithWeight(permits);
this.lock.lock();
try {
while (true) {
if (permits >= this.knownUnsatisfiablePermits) {
// We are requesting more permits than the remote policy will ever be able to satisfy, return immediately with no permits
break;
}
if (elapsedMillis(startTimeNanos) > this.maxTimeout) {
// Max timeout reached, break
break;
}
if (this.permitBatchContainer.tryTake(permits)) {
this.permitsOutstanding.removeEntryWithWeight(permits);
return true;
}
if (this.retryStatus.canRetryWithinMillis(remainingTime(startTimeNanos, this.maxTimeout))) {
long callbackCounterSnap = this.callbackCounter.get();
maybeSendNewPermitRequest();
if (this.callbackCounter.get() == callbackCounterSnap) {
// If a callback has happened since we tried to send the new permit request, don't await
// Since some request senders may be synchronous, we would have missed the notification
boolean ignore = this.newPermitsAvailable.await(remainingTime(startTimeNanos, this.maxTimeout), TimeUnit.MILLISECONDS);
}
} else {
break;
}
}
} finally {
this.lock.unlock();
}
this.permitsOutstanding.removeEntryWithWeight(permits);
return false;
} | [
"public",
"boolean",
"getPermits",
"(",
"long",
"permits",
")",
"throws",
"InterruptedException",
"{",
"if",
"(",
"permits",
"<=",
"0",
")",
"{",
"return",
"true",
";",
"}",
"long",
"startTimeNanos",
"=",
"System",
".",
"nanoTime",
"(",
")",
";",
"this",
".",
"permitsOutstanding",
".",
"addEntryWithWeight",
"(",
"permits",
")",
";",
"this",
".",
"lock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"while",
"(",
"true",
")",
"{",
"if",
"(",
"permits",
">=",
"this",
".",
"knownUnsatisfiablePermits",
")",
"{",
"// We are requesting more permits than the remote policy will ever be able to satisfy, return immediately with no permits",
"break",
";",
"}",
"if",
"(",
"elapsedMillis",
"(",
"startTimeNanos",
")",
">",
"this",
".",
"maxTimeout",
")",
"{",
"// Max timeout reached, break",
"break",
";",
"}",
"if",
"(",
"this",
".",
"permitBatchContainer",
".",
"tryTake",
"(",
"permits",
")",
")",
"{",
"this",
".",
"permitsOutstanding",
".",
"removeEntryWithWeight",
"(",
"permits",
")",
";",
"return",
"true",
";",
"}",
"if",
"(",
"this",
".",
"retryStatus",
".",
"canRetryWithinMillis",
"(",
"remainingTime",
"(",
"startTimeNanos",
",",
"this",
".",
"maxTimeout",
")",
")",
")",
"{",
"long",
"callbackCounterSnap",
"=",
"this",
".",
"callbackCounter",
".",
"get",
"(",
")",
";",
"maybeSendNewPermitRequest",
"(",
")",
";",
"if",
"(",
"this",
".",
"callbackCounter",
".",
"get",
"(",
")",
"==",
"callbackCounterSnap",
")",
"{",
"// If a callback has happened since we tried to send the new permit request, don't await",
"// Since some request senders may be synchronous, we would have missed the notification",
"boolean",
"ignore",
"=",
"this",
".",
"newPermitsAvailable",
".",
"await",
"(",
"remainingTime",
"(",
"startTimeNanos",
",",
"this",
".",
"maxTimeout",
")",
",",
"TimeUnit",
".",
"MILLISECONDS",
")",
";",
"}",
"}",
"else",
"{",
"break",
";",
"}",
"}",
"}",
"finally",
"{",
"this",
".",
"lock",
".",
"unlock",
"(",
")",
";",
"}",
"this",
".",
"permitsOutstanding",
".",
"removeEntryWithWeight",
"(",
"permits",
")",
";",
"return",
"false",
";",
"}"
] | Try to get a number of permits from this requester.
@return true if permits were obtained successfully. | [
"Try",
"to",
"get",
"a",
"number",
"of",
"permits",
"from",
"this",
"requester",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-restli/gobblin-throttling-service/gobblin-throttling-service-client/src/main/java/org/apache/gobblin/util/limiter/BatchedPermitsRequester.java#L148-L186 |
25,818 | apache/incubator-gobblin | gobblin-restli/gobblin-throttling-service/gobblin-throttling-service-client/src/main/java/org/apache/gobblin/util/limiter/BatchedPermitsRequester.java | BatchedPermitsRequester.maybeSendNewPermitRequest | private void maybeSendNewPermitRequest() {
if (!this.requestSemaphore.tryAcquire()) {
return;
}
if (!this.retryStatus.canRetryNow()) {
this.requestSemaphore.release();
return;
}
try {
long permits = computeNextPermitRequest();
if (permits <= 0) {
this.requestSemaphore.release();
return;
}
PermitRequest permitRequest = this.basePermitRequest.copy();
permitRequest.setPermits(permits);
permitRequest.setMinPermits((long) this.permitsOutstanding.getAverageWeightOrZero());
permitRequest.setVersion(ThrottlingProtocolVersion.WAIT_ON_CLIENT.ordinal());
if (BatchedPermitsRequester.this.restRequestHistogram != null) {
BatchedPermitsRequester.this.restRequestHistogram.update(permits);
}
log.debug("Sending permit request " + permitRequest);
this.requestSender.sendRequest(permitRequest, new AllocationCallback(
BatchedPermitsRequester.this.restRequestTimer == null ? NoopCloseable.INSTANCE :
BatchedPermitsRequester.this.restRequestTimer.time(), new Sleeper()));
} catch (CloneNotSupportedException cnse) {
// This should never happen.
this.requestSemaphore.release();
throw new RuntimeException(cnse);
}
} | java | private void maybeSendNewPermitRequest() {
if (!this.requestSemaphore.tryAcquire()) {
return;
}
if (!this.retryStatus.canRetryNow()) {
this.requestSemaphore.release();
return;
}
try {
long permits = computeNextPermitRequest();
if (permits <= 0) {
this.requestSemaphore.release();
return;
}
PermitRequest permitRequest = this.basePermitRequest.copy();
permitRequest.setPermits(permits);
permitRequest.setMinPermits((long) this.permitsOutstanding.getAverageWeightOrZero());
permitRequest.setVersion(ThrottlingProtocolVersion.WAIT_ON_CLIENT.ordinal());
if (BatchedPermitsRequester.this.restRequestHistogram != null) {
BatchedPermitsRequester.this.restRequestHistogram.update(permits);
}
log.debug("Sending permit request " + permitRequest);
this.requestSender.sendRequest(permitRequest, new AllocationCallback(
BatchedPermitsRequester.this.restRequestTimer == null ? NoopCloseable.INSTANCE :
BatchedPermitsRequester.this.restRequestTimer.time(), new Sleeper()));
} catch (CloneNotSupportedException cnse) {
// This should never happen.
this.requestSemaphore.release();
throw new RuntimeException(cnse);
}
} | [
"private",
"void",
"maybeSendNewPermitRequest",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"requestSemaphore",
".",
"tryAcquire",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"this",
".",
"retryStatus",
".",
"canRetryNow",
"(",
")",
")",
"{",
"this",
".",
"requestSemaphore",
".",
"release",
"(",
")",
";",
"return",
";",
"}",
"try",
"{",
"long",
"permits",
"=",
"computeNextPermitRequest",
"(",
")",
";",
"if",
"(",
"permits",
"<=",
"0",
")",
"{",
"this",
".",
"requestSemaphore",
".",
"release",
"(",
")",
";",
"return",
";",
"}",
"PermitRequest",
"permitRequest",
"=",
"this",
".",
"basePermitRequest",
".",
"copy",
"(",
")",
";",
"permitRequest",
".",
"setPermits",
"(",
"permits",
")",
";",
"permitRequest",
".",
"setMinPermits",
"(",
"(",
"long",
")",
"this",
".",
"permitsOutstanding",
".",
"getAverageWeightOrZero",
"(",
")",
")",
";",
"permitRequest",
".",
"setVersion",
"(",
"ThrottlingProtocolVersion",
".",
"WAIT_ON_CLIENT",
".",
"ordinal",
"(",
")",
")",
";",
"if",
"(",
"BatchedPermitsRequester",
".",
"this",
".",
"restRequestHistogram",
"!=",
"null",
")",
"{",
"BatchedPermitsRequester",
".",
"this",
".",
"restRequestHistogram",
".",
"update",
"(",
"permits",
")",
";",
"}",
"log",
".",
"debug",
"(",
"\"Sending permit request \"",
"+",
"permitRequest",
")",
";",
"this",
".",
"requestSender",
".",
"sendRequest",
"(",
"permitRequest",
",",
"new",
"AllocationCallback",
"(",
"BatchedPermitsRequester",
".",
"this",
".",
"restRequestTimer",
"==",
"null",
"?",
"NoopCloseable",
".",
"INSTANCE",
":",
"BatchedPermitsRequester",
".",
"this",
".",
"restRequestTimer",
".",
"time",
"(",
")",
",",
"new",
"Sleeper",
"(",
")",
")",
")",
";",
"}",
"catch",
"(",
"CloneNotSupportedException",
"cnse",
")",
"{",
"// This should never happen.",
"this",
".",
"requestSemaphore",
".",
"release",
"(",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
"cnse",
")",
";",
"}",
"}"
] | Send a new permit request to the server. | [
"Send",
"a",
"new",
"permit",
"request",
"to",
"the",
"server",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-restli/gobblin-throttling-service/gobblin-throttling-service-client/src/main/java/org/apache/gobblin/util/limiter/BatchedPermitsRequester.java#L199-L232 |
25,819 | apache/incubator-gobblin | gobblin-utility/src/main/java/org/apache/gobblin/util/RateControlledFileSystem.java | RateControlledFileSystem.getRateIfRateControlled | public static Optional<Long> getRateIfRateControlled(FileSystem fs) {
if (fs instanceof Decorator) {
List<Object> lineage = DecoratorUtils.getDecoratorLineage(fs);
for (Object obj : lineage) {
if (obj instanceof RateControlledFileSystem) {
return Optional.of(((RateControlledFileSystem) obj).limitPerSecond);
}
}
return Optional.absent();
}
return Optional.absent();
} | java | public static Optional<Long> getRateIfRateControlled(FileSystem fs) {
if (fs instanceof Decorator) {
List<Object> lineage = DecoratorUtils.getDecoratorLineage(fs);
for (Object obj : lineage) {
if (obj instanceof RateControlledFileSystem) {
return Optional.of(((RateControlledFileSystem) obj).limitPerSecond);
}
}
return Optional.absent();
}
return Optional.absent();
} | [
"public",
"static",
"Optional",
"<",
"Long",
">",
"getRateIfRateControlled",
"(",
"FileSystem",
"fs",
")",
"{",
"if",
"(",
"fs",
"instanceof",
"Decorator",
")",
"{",
"List",
"<",
"Object",
">",
"lineage",
"=",
"DecoratorUtils",
".",
"getDecoratorLineage",
"(",
"fs",
")",
";",
"for",
"(",
"Object",
"obj",
":",
"lineage",
")",
"{",
"if",
"(",
"obj",
"instanceof",
"RateControlledFileSystem",
")",
"{",
"return",
"Optional",
".",
"of",
"(",
"(",
"(",
"RateControlledFileSystem",
")",
"obj",
")",
".",
"limitPerSecond",
")",
";",
"}",
"}",
"return",
"Optional",
".",
"absent",
"(",
")",
";",
"}",
"return",
"Optional",
".",
"absent",
"(",
")",
";",
"}"
] | Determines whether the file system is rate controlled, and if so, returns the allowed rate in operations per
second.
@param fs {@link FileSystem} to check for rate control.
@return {@link Optional#absent} if file system is not rate controlled, otherwise, the rate in operations per second. | [
"Determines",
"whether",
"the",
"file",
"system",
"is",
"rate",
"controlled",
"and",
"if",
"so",
"returns",
"the",
"allowed",
"rate",
"in",
"operations",
"per",
"second",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-utility/src/main/java/org/apache/gobblin/util/RateControlledFileSystem.java#L67-L78 |
25,820 | apache/incubator-gobblin | gobblin-runtime/src/main/java/org/apache/gobblin/runtime/std/DefaultJobSpecScheduleImpl.java | DefaultJobSpecScheduleImpl.createImmediateSchedule | public static DefaultJobSpecScheduleImpl createImmediateSchedule(JobSpec jobSpec,
Runnable jobRunnable) {
return new DefaultJobSpecScheduleImpl(jobSpec, jobRunnable,
Optional.of(System.currentTimeMillis()));
} | java | public static DefaultJobSpecScheduleImpl createImmediateSchedule(JobSpec jobSpec,
Runnable jobRunnable) {
return new DefaultJobSpecScheduleImpl(jobSpec, jobRunnable,
Optional.of(System.currentTimeMillis()));
} | [
"public",
"static",
"DefaultJobSpecScheduleImpl",
"createImmediateSchedule",
"(",
"JobSpec",
"jobSpec",
",",
"Runnable",
"jobRunnable",
")",
"{",
"return",
"new",
"DefaultJobSpecScheduleImpl",
"(",
"jobSpec",
",",
"jobRunnable",
",",
"Optional",
".",
"of",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
")",
")",
";",
"}"
] | Creates a schedule denoting that the job is to be executed immediately | [
"Creates",
"a",
"schedule",
"denoting",
"that",
"the",
"job",
"is",
"to",
"be",
"executed",
"immediately"
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-runtime/src/main/java/org/apache/gobblin/runtime/std/DefaultJobSpecScheduleImpl.java#L36-L40 |
25,821 | apache/incubator-gobblin | gobblin-runtime/src/main/java/org/apache/gobblin/runtime/std/DefaultJobSpecScheduleImpl.java | DefaultJobSpecScheduleImpl.createNoSchedule | public static DefaultJobSpecScheduleImpl createNoSchedule(JobSpec jobSpec,
Runnable jobRunnable) {
return new DefaultJobSpecScheduleImpl(jobSpec, jobRunnable,
Optional.<Long>absent());
} | java | public static DefaultJobSpecScheduleImpl createNoSchedule(JobSpec jobSpec,
Runnable jobRunnable) {
return new DefaultJobSpecScheduleImpl(jobSpec, jobRunnable,
Optional.<Long>absent());
} | [
"public",
"static",
"DefaultJobSpecScheduleImpl",
"createNoSchedule",
"(",
"JobSpec",
"jobSpec",
",",
"Runnable",
"jobRunnable",
")",
"{",
"return",
"new",
"DefaultJobSpecScheduleImpl",
"(",
"jobSpec",
",",
"jobRunnable",
",",
"Optional",
".",
"<",
"Long",
">",
"absent",
"(",
")",
")",
";",
"}"
] | Creates a schedule denoting that the job is not to be executed | [
"Creates",
"a",
"schedule",
"denoting",
"that",
"the",
"job",
"is",
"not",
"to",
"be",
"executed"
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-runtime/src/main/java/org/apache/gobblin/runtime/std/DefaultJobSpecScheduleImpl.java#L43-L47 |
25,822 | apache/incubator-gobblin | gobblin-data-management/src/main/java/org/apache/gobblin/data/management/copy/hive/HiveCopyEntityHelper.java | HiveCopyEntityHelper.getTargetLocation | Path getTargetLocation(FileSystem sourceFs, FileSystem targetFs, Path path, Optional<Partition> partition)
throws IOException {
return getTargetPathHelper().getTargetPath(path, targetFs, partition, false);
} | java | Path getTargetLocation(FileSystem sourceFs, FileSystem targetFs, Path path, Optional<Partition> partition)
throws IOException {
return getTargetPathHelper().getTargetPath(path, targetFs, partition, false);
} | [
"Path",
"getTargetLocation",
"(",
"FileSystem",
"sourceFs",
",",
"FileSystem",
"targetFs",
",",
"Path",
"path",
",",
"Optional",
"<",
"Partition",
">",
"partition",
")",
"throws",
"IOException",
"{",
"return",
"getTargetPathHelper",
"(",
")",
".",
"getTargetPath",
"(",
"path",
",",
"targetFs",
",",
"partition",
",",
"false",
")",
";",
"}"
] | Compute the target location for a Hive location.
@param sourceFs Source {@link FileSystem}.
@param path source {@link Path} in Hive location.
@param partition partition these paths correspond to.
@return transformed location in the target.
@throws IOException if cannot generate a single target location. | [
"Compute",
"the",
"target",
"location",
"for",
"a",
"Hive",
"location",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-data-management/src/main/java/org/apache/gobblin/data/management/copy/hive/HiveCopyEntityHelper.java#L780-L783 |
25,823 | apache/incubator-gobblin | gobblin-utility/src/main/java/org/apache/gobblin/util/DownloadUtils.java | DownloadUtils.getIvySettingsFile | public static File getIvySettingsFile() throws IOException {
URL settingsUrl = Thread.currentThread().getContextClassLoader().getResource(IVY_SETTINGS_FILE_NAME);
if (settingsUrl == null) {
throw new IOException("Failed to find " + IVY_SETTINGS_FILE_NAME + " from class path");
}
// Check if settingsUrl is file on classpath
File ivySettingsFile = new File(settingsUrl.getFile());
if (ivySettingsFile.exists()) {
// can access settingsUrl as a file
return ivySettingsFile;
}
// Create temporary Ivy settings file.
ivySettingsFile = File.createTempFile("ivy.settings", ".xml");
ivySettingsFile.deleteOnExit();
try (OutputStream os = new BufferedOutputStream(new FileOutputStream(ivySettingsFile))) {
Resources.copy(settingsUrl, os);
}
return ivySettingsFile;
} | java | public static File getIvySettingsFile() throws IOException {
URL settingsUrl = Thread.currentThread().getContextClassLoader().getResource(IVY_SETTINGS_FILE_NAME);
if (settingsUrl == null) {
throw new IOException("Failed to find " + IVY_SETTINGS_FILE_NAME + " from class path");
}
// Check if settingsUrl is file on classpath
File ivySettingsFile = new File(settingsUrl.getFile());
if (ivySettingsFile.exists()) {
// can access settingsUrl as a file
return ivySettingsFile;
}
// Create temporary Ivy settings file.
ivySettingsFile = File.createTempFile("ivy.settings", ".xml");
ivySettingsFile.deleteOnExit();
try (OutputStream os = new BufferedOutputStream(new FileOutputStream(ivySettingsFile))) {
Resources.copy(settingsUrl, os);
}
return ivySettingsFile;
} | [
"public",
"static",
"File",
"getIvySettingsFile",
"(",
")",
"throws",
"IOException",
"{",
"URL",
"settingsUrl",
"=",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getContextClassLoader",
"(",
")",
".",
"getResource",
"(",
"IVY_SETTINGS_FILE_NAME",
")",
";",
"if",
"(",
"settingsUrl",
"==",
"null",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Failed to find \"",
"+",
"IVY_SETTINGS_FILE_NAME",
"+",
"\" from class path\"",
")",
";",
"}",
"// Check if settingsUrl is file on classpath",
"File",
"ivySettingsFile",
"=",
"new",
"File",
"(",
"settingsUrl",
".",
"getFile",
"(",
")",
")",
";",
"if",
"(",
"ivySettingsFile",
".",
"exists",
"(",
")",
")",
"{",
"// can access settingsUrl as a file",
"return",
"ivySettingsFile",
";",
"}",
"// Create temporary Ivy settings file.",
"ivySettingsFile",
"=",
"File",
".",
"createTempFile",
"(",
"\"ivy.settings\"",
",",
"\".xml\"",
")",
";",
"ivySettingsFile",
".",
"deleteOnExit",
"(",
")",
";",
"try",
"(",
"OutputStream",
"os",
"=",
"new",
"BufferedOutputStream",
"(",
"new",
"FileOutputStream",
"(",
"ivySettingsFile",
")",
")",
")",
"{",
"Resources",
".",
"copy",
"(",
"settingsUrl",
",",
"os",
")",
";",
"}",
"return",
"ivySettingsFile",
";",
"}"
] | Get ivy settings file from classpath | [
"Get",
"ivy",
"settings",
"file",
"from",
"classpath"
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-utility/src/main/java/org/apache/gobblin/util/DownloadUtils.java#L73-L95 |
25,824 | apache/incubator-gobblin | gobblin-api/src/main/java/org/apache/gobblin/writer/DataWriterBuilder.java | DataWriterBuilder.writeTo | public DataWriterBuilder<S, D> writeTo(Destination destination) {
this.destination = destination;
log.debug("For destination: {}", destination);
return this;
} | java | public DataWriterBuilder<S, D> writeTo(Destination destination) {
this.destination = destination;
log.debug("For destination: {}", destination);
return this;
} | [
"public",
"DataWriterBuilder",
"<",
"S",
",",
"D",
">",
"writeTo",
"(",
"Destination",
"destination",
")",
"{",
"this",
".",
"destination",
"=",
"destination",
";",
"log",
".",
"debug",
"(",
"\"For destination: {}\"",
",",
"destination",
")",
";",
"return",
"this",
";",
"}"
] | Tell the writer the destination to write to.
@param destination destination to write to
@return this {@link DataWriterBuilder} instance | [
"Tell",
"the",
"writer",
"the",
"destination",
"to",
"write",
"to",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-api/src/main/java/org/apache/gobblin/writer/DataWriterBuilder.java#L57-L61 |
25,825 | apache/incubator-gobblin | gobblin-api/src/main/java/org/apache/gobblin/writer/DataWriterBuilder.java | DataWriterBuilder.withWriterId | public DataWriterBuilder<S, D> withWriterId(String writerId) {
this.writerId = writerId;
log.debug("withWriterId : {}", this.writerId);
return this;
} | java | public DataWriterBuilder<S, D> withWriterId(String writerId) {
this.writerId = writerId;
log.debug("withWriterId : {}", this.writerId);
return this;
} | [
"public",
"DataWriterBuilder",
"<",
"S",
",",
"D",
">",
"withWriterId",
"(",
"String",
"writerId",
")",
"{",
"this",
".",
"writerId",
"=",
"writerId",
";",
"log",
".",
"debug",
"(",
"\"withWriterId : {}\"",
",",
"this",
".",
"writerId",
")",
";",
"return",
"this",
";",
"}"
] | Give the writer a unique ID.
@param writerId unique writer ID
@return this {@link DataWriterBuilder} instance | [
"Give",
"the",
"writer",
"a",
"unique",
"ID",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-api/src/main/java/org/apache/gobblin/writer/DataWriterBuilder.java#L81-L85 |
25,826 | apache/incubator-gobblin | gobblin-api/src/main/java/org/apache/gobblin/writer/DataWriterBuilder.java | DataWriterBuilder.withSchema | public DataWriterBuilder<S, D> withSchema(S schema) {
this.schema = schema;
log.debug("withSchema : {}", this.schema);
return this;
} | java | public DataWriterBuilder<S, D> withSchema(S schema) {
this.schema = schema;
log.debug("withSchema : {}", this.schema);
return this;
} | [
"public",
"DataWriterBuilder",
"<",
"S",
",",
"D",
">",
"withSchema",
"(",
"S",
"schema",
")",
"{",
"this",
".",
"schema",
"=",
"schema",
";",
"log",
".",
"debug",
"(",
"\"withSchema : {}\"",
",",
"this",
".",
"schema",
")",
";",
"return",
"this",
";",
"}"
] | Tell the writer the data schema.
@param schema data schema
@return this {@link DataWriterBuilder} instance | [
"Tell",
"the",
"writer",
"the",
"data",
"schema",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-api/src/main/java/org/apache/gobblin/writer/DataWriterBuilder.java#L93-L97 |
25,827 | apache/incubator-gobblin | gobblin-api/src/main/java/org/apache/gobblin/writer/DataWriterBuilder.java | DataWriterBuilder.withBranches | public DataWriterBuilder<S, D> withBranches(int branches) {
this.branches = branches;
log.debug("With branches: {}", this.branches);
return this;
} | java | public DataWriterBuilder<S, D> withBranches(int branches) {
this.branches = branches;
log.debug("With branches: {}", this.branches);
return this;
} | [
"public",
"DataWriterBuilder",
"<",
"S",
",",
"D",
">",
"withBranches",
"(",
"int",
"branches",
")",
"{",
"this",
".",
"branches",
"=",
"branches",
";",
"log",
".",
"debug",
"(",
"\"With branches: {}\"",
",",
"this",
".",
"branches",
")",
";",
"return",
"this",
";",
"}"
] | Tell the writer how many branches are being used.
@param branches is the number of branches
@return this {@link DataWriterBuilder} instance | [
"Tell",
"the",
"writer",
"how",
"many",
"branches",
"are",
"being",
"used",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-api/src/main/java/org/apache/gobblin/writer/DataWriterBuilder.java#L105-L109 |
25,828 | apache/incubator-gobblin | gobblin-api/src/main/java/org/apache/gobblin/writer/DataWriterBuilder.java | DataWriterBuilder.forBranch | public DataWriterBuilder<S, D> forBranch(int branch) {
this.branch = branch;
log.debug("For branch: {}", this.branch);
return this;
} | java | public DataWriterBuilder<S, D> forBranch(int branch) {
this.branch = branch;
log.debug("For branch: {}", this.branch);
return this;
} | [
"public",
"DataWriterBuilder",
"<",
"S",
",",
"D",
">",
"forBranch",
"(",
"int",
"branch",
")",
"{",
"this",
".",
"branch",
"=",
"branch",
";",
"log",
".",
"debug",
"(",
"\"For branch: {}\"",
",",
"this",
".",
"branch",
")",
";",
"return",
"this",
";",
"}"
] | Tell the writer which branch it is associated with.
@param branch branch index
@return this {@link DataWriterBuilder} instance | [
"Tell",
"the",
"writer",
"which",
"branch",
"it",
"is",
"associated",
"with",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-api/src/main/java/org/apache/gobblin/writer/DataWriterBuilder.java#L117-L121 |
25,829 | apache/incubator-gobblin | gobblin-data-management/src/main/java/org/apache/gobblin/data/management/copy/hive/avro/HiveAvroCopyEntityHelper.java | HiveAvroCopyEntityHelper.isHiveTableAvroType | public static boolean isHiveTableAvroType(Table targetTable) throws IOException {
String serializationLib = targetTable.getTTable().getSd().getSerdeInfo().getSerializationLib();
String inputFormat = targetTable.getTTable().getSd().getInputFormat();
String outputFormat = targetTable.getTTable().getSd().getOutputFormat();
return inputFormat.endsWith("AvroContainerInputFormat") || outputFormat.endsWith("AvroContainerOutputFormat")
|| serializationLib.endsWith("AvroSerDe");
} | java | public static boolean isHiveTableAvroType(Table targetTable) throws IOException {
String serializationLib = targetTable.getTTable().getSd().getSerdeInfo().getSerializationLib();
String inputFormat = targetTable.getTTable().getSd().getInputFormat();
String outputFormat = targetTable.getTTable().getSd().getOutputFormat();
return inputFormat.endsWith("AvroContainerInputFormat") || outputFormat.endsWith("AvroContainerOutputFormat")
|| serializationLib.endsWith("AvroSerDe");
} | [
"public",
"static",
"boolean",
"isHiveTableAvroType",
"(",
"Table",
"targetTable",
")",
"throws",
"IOException",
"{",
"String",
"serializationLib",
"=",
"targetTable",
".",
"getTTable",
"(",
")",
".",
"getSd",
"(",
")",
".",
"getSerdeInfo",
"(",
")",
".",
"getSerializationLib",
"(",
")",
";",
"String",
"inputFormat",
"=",
"targetTable",
".",
"getTTable",
"(",
")",
".",
"getSd",
"(",
")",
".",
"getInputFormat",
"(",
")",
";",
"String",
"outputFormat",
"=",
"targetTable",
".",
"getTTable",
"(",
")",
".",
"getSd",
"(",
")",
".",
"getOutputFormat",
"(",
")",
";",
"return",
"inputFormat",
".",
"endsWith",
"(",
"\"AvroContainerInputFormat\"",
")",
"||",
"outputFormat",
".",
"endsWith",
"(",
"\"AvroContainerOutputFormat\"",
")",
"||",
"serializationLib",
".",
"endsWith",
"(",
"\"AvroSerDe\"",
")",
";",
"}"
] | Tell whether a hive table is actually an Avro table
@param targetTable
@return
@throws IOException | [
"Tell",
"whether",
"a",
"hive",
"table",
"is",
"actually",
"an",
"Avro",
"table"
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-data-management/src/main/java/org/apache/gobblin/data/management/copy/hive/avro/HiveAvroCopyEntityHelper.java#L103-L110 |
25,830 | apache/incubator-gobblin | gobblin-modules/gobblin-compliance/src/main/java/org/apache/gobblin/compliance/purger/HivePurgerQueryTemplate.java | HivePurgerQueryTemplate.getCreateTableQuery | public static String getCreateTableQuery(String completeNewTableName, String likeTableDbName, String likeTableName,
String location) {
return getCreateTableQuery(completeNewTableName, likeTableDbName, likeTableName) + " LOCATION " + PartitionUtils
.getQuotedString(location);
} | java | public static String getCreateTableQuery(String completeNewTableName, String likeTableDbName, String likeTableName,
String location) {
return getCreateTableQuery(completeNewTableName, likeTableDbName, likeTableName) + " LOCATION " + PartitionUtils
.getQuotedString(location);
} | [
"public",
"static",
"String",
"getCreateTableQuery",
"(",
"String",
"completeNewTableName",
",",
"String",
"likeTableDbName",
",",
"String",
"likeTableName",
",",
"String",
"location",
")",
"{",
"return",
"getCreateTableQuery",
"(",
"completeNewTableName",
",",
"likeTableDbName",
",",
"likeTableName",
")",
"+",
"\" LOCATION \"",
"+",
"PartitionUtils",
".",
"getQuotedString",
"(",
"location",
")",
";",
"}"
] | If staging table doesn't exist, it will create a staging table. | [
"If",
"staging",
"table",
"doesn",
"t",
"exist",
"it",
"will",
"create",
"a",
"staging",
"table",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-compliance/src/main/java/org/apache/gobblin/compliance/purger/HivePurgerQueryTemplate.java#L67-L71 |
25,831 | apache/incubator-gobblin | gobblin-modules/gobblin-compliance/src/main/java/org/apache/gobblin/compliance/purger/HivePurgerQueryTemplate.java | HivePurgerQueryTemplate.getInsertQuery | public static String getInsertQuery(PurgeableHivePartitionDataset dataset) {
return "INSERT OVERWRITE" + " TABLE " + dataset.getCompleteStagingTableName() + " PARTITION (" + PartitionUtils
.getPartitionSpecString(dataset.getSpec()) + ")" + " SELECT /*+MAPJOIN(b) */ " + getCommaSeparatedColumnNames(
dataset.getCols(), "a.") + " FROM " + dataset.getDbName() + "." + dataset.getTableName() + " a LEFT JOIN "
+ dataset.getComplianceIdTable() + " b" + " ON a." + dataset.getComplianceField() + "=b." + dataset
.getComplianceId() + " WHERE b." + dataset.getComplianceId() + " IS NULL AND " + getWhereClauseForPartition(
dataset.getSpec(), "a.");
} | java | public static String getInsertQuery(PurgeableHivePartitionDataset dataset) {
return "INSERT OVERWRITE" + " TABLE " + dataset.getCompleteStagingTableName() + " PARTITION (" + PartitionUtils
.getPartitionSpecString(dataset.getSpec()) + ")" + " SELECT /*+MAPJOIN(b) */ " + getCommaSeparatedColumnNames(
dataset.getCols(), "a.") + " FROM " + dataset.getDbName() + "." + dataset.getTableName() + " a LEFT JOIN "
+ dataset.getComplianceIdTable() + " b" + " ON a." + dataset.getComplianceField() + "=b." + dataset
.getComplianceId() + " WHERE b." + dataset.getComplianceId() + " IS NULL AND " + getWhereClauseForPartition(
dataset.getSpec(), "a.");
} | [
"public",
"static",
"String",
"getInsertQuery",
"(",
"PurgeableHivePartitionDataset",
"dataset",
")",
"{",
"return",
"\"INSERT OVERWRITE\"",
"+",
"\" TABLE \"",
"+",
"dataset",
".",
"getCompleteStagingTableName",
"(",
")",
"+",
"\" PARTITION (\"",
"+",
"PartitionUtils",
".",
"getPartitionSpecString",
"(",
"dataset",
".",
"getSpec",
"(",
")",
")",
"+",
"\")\"",
"+",
"\" SELECT /*+MAPJOIN(b) */ \"",
"+",
"getCommaSeparatedColumnNames",
"(",
"dataset",
".",
"getCols",
"(",
")",
",",
"\"a.\"",
")",
"+",
"\" FROM \"",
"+",
"dataset",
".",
"getDbName",
"(",
")",
"+",
"\".\"",
"+",
"dataset",
".",
"getTableName",
"(",
")",
"+",
"\" a LEFT JOIN \"",
"+",
"dataset",
".",
"getComplianceIdTable",
"(",
")",
"+",
"\" b\"",
"+",
"\" ON a.\"",
"+",
"dataset",
".",
"getComplianceField",
"(",
")",
"+",
"\"=b.\"",
"+",
"dataset",
".",
"getComplianceId",
"(",
")",
"+",
"\" WHERE b.\"",
"+",
"dataset",
".",
"getComplianceId",
"(",
")",
"+",
"\" IS NULL AND \"",
"+",
"getWhereClauseForPartition",
"(",
"dataset",
".",
"getSpec",
"(",
")",
",",
"\"a.\"",
")",
";",
"}"
] | This query will create a partition in staging table and insert the datasets whose compliance id is not
contained in the compliance id table. | [
"This",
"query",
"will",
"create",
"a",
"partition",
"in",
"staging",
"table",
"and",
"insert",
"the",
"datasets",
"whose",
"compliance",
"id",
"is",
"not",
"contained",
"in",
"the",
"compliance",
"id",
"table",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-compliance/src/main/java/org/apache/gobblin/compliance/purger/HivePurgerQueryTemplate.java#L82-L89 |
25,832 | apache/incubator-gobblin | gobblin-modules/gobblin-compliance/src/main/java/org/apache/gobblin/compliance/purger/HivePurgerQueryTemplate.java | HivePurgerQueryTemplate.getPurgeQueries | public static List<String> getPurgeQueries(PurgeableHivePartitionDataset dataset) {
List<String> queries = new ArrayList<>();
queries.add(getUseDbQuery(dataset.getStagingDb()));
queries.add(getInsertQuery(dataset));
return queries;
} | java | public static List<String> getPurgeQueries(PurgeableHivePartitionDataset dataset) {
List<String> queries = new ArrayList<>();
queries.add(getUseDbQuery(dataset.getStagingDb()));
queries.add(getInsertQuery(dataset));
return queries;
} | [
"public",
"static",
"List",
"<",
"String",
">",
"getPurgeQueries",
"(",
"PurgeableHivePartitionDataset",
"dataset",
")",
"{",
"List",
"<",
"String",
">",
"queries",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"queries",
".",
"add",
"(",
"getUseDbQuery",
"(",
"dataset",
".",
"getStagingDb",
"(",
")",
")",
")",
";",
"queries",
".",
"add",
"(",
"getInsertQuery",
"(",
"dataset",
")",
")",
";",
"return",
"queries",
";",
"}"
] | Will return all the queries needed to populate the staging table partition.
This won't include alter table partition location query. | [
"Will",
"return",
"all",
"the",
"queries",
"needed",
"to",
"populate",
"the",
"staging",
"table",
"partition",
".",
"This",
"won",
"t",
"include",
"alter",
"table",
"partition",
"location",
"query",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-compliance/src/main/java/org/apache/gobblin/compliance/purger/HivePurgerQueryTemplate.java#L123-L128 |
25,833 | apache/incubator-gobblin | gobblin-modules/gobblin-compliance/src/main/java/org/apache/gobblin/compliance/purger/HivePurgerQueryTemplate.java | HivePurgerQueryTemplate.getBackupQueries | public static List<String> getBackupQueries(PurgeableHivePartitionDataset dataset) {
List<String> queries = new ArrayList<>();
queries.add(getUseDbQuery(dataset.getDbName()));
queries.add(getCreateTableQuery(dataset.getCompleteBackupTableName(), dataset.getDbName(), dataset.getTableName(),
dataset.getBackupTableLocation()));
Optional<String> fileFormat = Optional.absent();
if (dataset.getSpecifyPartitionFormat()) {
fileFormat = dataset.getFileFormat();
}
queries.add(
getAddPartitionQuery(dataset.getBackupTableName(), PartitionUtils.getPartitionSpecString(dataset.getSpec()),
fileFormat, Optional.fromNullable(dataset.getOriginalPartitionLocation())));
return queries;
} | java | public static List<String> getBackupQueries(PurgeableHivePartitionDataset dataset) {
List<String> queries = new ArrayList<>();
queries.add(getUseDbQuery(dataset.getDbName()));
queries.add(getCreateTableQuery(dataset.getCompleteBackupTableName(), dataset.getDbName(), dataset.getTableName(),
dataset.getBackupTableLocation()));
Optional<String> fileFormat = Optional.absent();
if (dataset.getSpecifyPartitionFormat()) {
fileFormat = dataset.getFileFormat();
}
queries.add(
getAddPartitionQuery(dataset.getBackupTableName(), PartitionUtils.getPartitionSpecString(dataset.getSpec()),
fileFormat, Optional.fromNullable(dataset.getOriginalPartitionLocation())));
return queries;
} | [
"public",
"static",
"List",
"<",
"String",
">",
"getBackupQueries",
"(",
"PurgeableHivePartitionDataset",
"dataset",
")",
"{",
"List",
"<",
"String",
">",
"queries",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"queries",
".",
"add",
"(",
"getUseDbQuery",
"(",
"dataset",
".",
"getDbName",
"(",
")",
")",
")",
";",
"queries",
".",
"add",
"(",
"getCreateTableQuery",
"(",
"dataset",
".",
"getCompleteBackupTableName",
"(",
")",
",",
"dataset",
".",
"getDbName",
"(",
")",
",",
"dataset",
".",
"getTableName",
"(",
")",
",",
"dataset",
".",
"getBackupTableLocation",
"(",
")",
")",
")",
";",
"Optional",
"<",
"String",
">",
"fileFormat",
"=",
"Optional",
".",
"absent",
"(",
")",
";",
"if",
"(",
"dataset",
".",
"getSpecifyPartitionFormat",
"(",
")",
")",
"{",
"fileFormat",
"=",
"dataset",
".",
"getFileFormat",
"(",
")",
";",
"}",
"queries",
".",
"add",
"(",
"getAddPartitionQuery",
"(",
"dataset",
".",
"getBackupTableName",
"(",
")",
",",
"PartitionUtils",
".",
"getPartitionSpecString",
"(",
"dataset",
".",
"getSpec",
"(",
")",
")",
",",
"fileFormat",
",",
"Optional",
".",
"fromNullable",
"(",
"dataset",
".",
"getOriginalPartitionLocation",
"(",
")",
")",
")",
")",
";",
"return",
"queries",
";",
"}"
] | Will return all the queries needed to have a backup table partition pointing to the original partition data location | [
"Will",
"return",
"all",
"the",
"queries",
"needed",
"to",
"have",
"a",
"backup",
"table",
"partition",
"pointing",
"to",
"the",
"original",
"partition",
"data",
"location"
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-compliance/src/main/java/org/apache/gobblin/compliance/purger/HivePurgerQueryTemplate.java#L150-L163 |
25,834 | apache/incubator-gobblin | gobblin-modules/gobblin-compliance/src/main/java/org/apache/gobblin/compliance/purger/HivePurgerQueryTemplate.java | HivePurgerQueryTemplate.getAlterOriginalPartitionLocationQueries | public static List<String> getAlterOriginalPartitionLocationQueries(PurgeableHivePartitionDataset dataset) {
List<String> queries = new ArrayList<>();
queries.add(getUseDbQuery(dataset.getDbName()));
String partitionSpecString = PartitionUtils.getPartitionSpecString(dataset.getSpec());
queries.add(
getAlterTableLocationQuery(dataset.getTableName(), partitionSpecString, dataset.getStagingPartitionLocation()));
queries.add(getUpdatePartitionMetadataQuery(dataset.getDbName(), dataset.getTableName(), partitionSpecString));
return queries;
} | java | public static List<String> getAlterOriginalPartitionLocationQueries(PurgeableHivePartitionDataset dataset) {
List<String> queries = new ArrayList<>();
queries.add(getUseDbQuery(dataset.getDbName()));
String partitionSpecString = PartitionUtils.getPartitionSpecString(dataset.getSpec());
queries.add(
getAlterTableLocationQuery(dataset.getTableName(), partitionSpecString, dataset.getStagingPartitionLocation()));
queries.add(getUpdatePartitionMetadataQuery(dataset.getDbName(), dataset.getTableName(), partitionSpecString));
return queries;
} | [
"public",
"static",
"List",
"<",
"String",
">",
"getAlterOriginalPartitionLocationQueries",
"(",
"PurgeableHivePartitionDataset",
"dataset",
")",
"{",
"List",
"<",
"String",
">",
"queries",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"queries",
".",
"add",
"(",
"getUseDbQuery",
"(",
"dataset",
".",
"getDbName",
"(",
")",
")",
")",
";",
"String",
"partitionSpecString",
"=",
"PartitionUtils",
".",
"getPartitionSpecString",
"(",
"dataset",
".",
"getSpec",
"(",
")",
")",
";",
"queries",
".",
"add",
"(",
"getAlterTableLocationQuery",
"(",
"dataset",
".",
"getTableName",
"(",
")",
",",
"partitionSpecString",
",",
"dataset",
".",
"getStagingPartitionLocation",
"(",
")",
")",
")",
";",
"queries",
".",
"add",
"(",
"getUpdatePartitionMetadataQuery",
"(",
"dataset",
".",
"getDbName",
"(",
")",
",",
"dataset",
".",
"getTableName",
"(",
")",
",",
"partitionSpecString",
")",
")",
";",
"return",
"queries",
";",
"}"
] | Will return all the queries needed to alter the location of the table partition.
Alter table partition query doesn't work with syntax dbName.tableName | [
"Will",
"return",
"all",
"the",
"queries",
"needed",
"to",
"alter",
"the",
"location",
"of",
"the",
"table",
"partition",
".",
"Alter",
"table",
"partition",
"query",
"doesn",
"t",
"work",
"with",
"syntax",
"dbName",
".",
"tableName"
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-compliance/src/main/java/org/apache/gobblin/compliance/purger/HivePurgerQueryTemplate.java#L169-L177 |
25,835 | apache/incubator-gobblin | gobblin-modules/gobblin-kafka-common/src/main/java/org/apache/gobblin/converter/EnvelopePayloadConverter.java | EnvelopePayloadConverter.convertFieldSchema | protected Field convertFieldSchema(Schema inputSchema, Field field, WorkUnitState workUnit)
throws SchemaConversionException {
if (field.name().equals(payloadField)) {
// Create a payload field with latest schema
return createLatestPayloadField(field);
}
// Make a copy of the field to the output schema
return new Field(field.name(), field.schema(), field.doc(), field.defaultValue(), field.order());
} | java | protected Field convertFieldSchema(Schema inputSchema, Field field, WorkUnitState workUnit)
throws SchemaConversionException {
if (field.name().equals(payloadField)) {
// Create a payload field with latest schema
return createLatestPayloadField(field);
}
// Make a copy of the field to the output schema
return new Field(field.name(), field.schema(), field.doc(), field.defaultValue(), field.order());
} | [
"protected",
"Field",
"convertFieldSchema",
"(",
"Schema",
"inputSchema",
",",
"Field",
"field",
",",
"WorkUnitState",
"workUnit",
")",
"throws",
"SchemaConversionException",
"{",
"if",
"(",
"field",
".",
"name",
"(",
")",
".",
"equals",
"(",
"payloadField",
")",
")",
"{",
"// Create a payload field with latest schema",
"return",
"createLatestPayloadField",
"(",
"field",
")",
";",
"}",
"// Make a copy of the field to the output schema",
"return",
"new",
"Field",
"(",
"field",
".",
"name",
"(",
")",
",",
"field",
".",
"schema",
"(",
")",
",",
"field",
".",
"doc",
"(",
")",
",",
"field",
".",
"defaultValue",
"(",
")",
",",
"field",
".",
"order",
"(",
")",
")",
";",
"}"
] | Convert to the output schema of a field | [
"Convert",
"to",
"the",
"output",
"schema",
"of",
"a",
"field"
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-kafka-common/src/main/java/org/apache/gobblin/converter/EnvelopePayloadConverter.java#L66-L74 |
25,836 | apache/incubator-gobblin | gobblin-modules/gobblin-kafka-common/src/main/java/org/apache/gobblin/converter/EnvelopePayloadConverter.java | EnvelopePayloadConverter.convertFieldValue | protected Object convertFieldValue(Schema outputSchema, Field field, GenericRecord inputRecord,
WorkUnitState workUnit)
throws DataConversionException {
if (field.name().equals(payloadField)) {
return upConvertPayload(inputRecord);
}
return inputRecord.get(field.name());
} | java | protected Object convertFieldValue(Schema outputSchema, Field field, GenericRecord inputRecord,
WorkUnitState workUnit)
throws DataConversionException {
if (field.name().equals(payloadField)) {
return upConvertPayload(inputRecord);
}
return inputRecord.get(field.name());
} | [
"protected",
"Object",
"convertFieldValue",
"(",
"Schema",
"outputSchema",
",",
"Field",
"field",
",",
"GenericRecord",
"inputRecord",
",",
"WorkUnitState",
"workUnit",
")",
"throws",
"DataConversionException",
"{",
"if",
"(",
"field",
".",
"name",
"(",
")",
".",
"equals",
"(",
"payloadField",
")",
")",
"{",
"return",
"upConvertPayload",
"(",
"inputRecord",
")",
";",
"}",
"return",
"inputRecord",
".",
"get",
"(",
"field",
".",
"name",
"(",
")",
")",
";",
"}"
] | Convert to the output value of a field | [
"Convert",
"to",
"the",
"output",
"value",
"of",
"a",
"field"
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-kafka-common/src/main/java/org/apache/gobblin/converter/EnvelopePayloadConverter.java#L105-L112 |
25,837 | apache/incubator-gobblin | gobblin-modules/google-ingestion/src/main/java/org/apache/gobblin/source/extractor/extract/google/GoogleAnalyticsUnsampledExtractor.java | GoogleAnalyticsUnsampledExtractor.convertFormat | private String convertFormat(long watermark) {
Preconditions.checkArgument(watermark > 0, "Watermark should be positive number.");
return googleAnalyticsFormatter.print(watermarkFormatter.parseDateTime(Long.toString(watermark)));
} | java | private String convertFormat(long watermark) {
Preconditions.checkArgument(watermark > 0, "Watermark should be positive number.");
return googleAnalyticsFormatter.print(watermarkFormatter.parseDateTime(Long.toString(watermark)));
} | [
"private",
"String",
"convertFormat",
"(",
"long",
"watermark",
")",
"{",
"Preconditions",
".",
"checkArgument",
"(",
"watermark",
">",
"0",
",",
"\"Watermark should be positive number.\"",
")",
";",
"return",
"googleAnalyticsFormatter",
".",
"print",
"(",
"watermarkFormatter",
".",
"parseDateTime",
"(",
"Long",
".",
"toString",
"(",
"watermark",
")",
")",
")",
";",
"}"
] | Converts date format from watermark format to Google analytics format
@param watermark
@return | [
"Converts",
"date",
"format",
"from",
"watermark",
"format",
"to",
"Google",
"analytics",
"format"
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/google-ingestion/src/main/java/org/apache/gobblin/source/extractor/extract/google/GoogleAnalyticsUnsampledExtractor.java#L295-L298 |
25,838 | apache/incubator-gobblin | gobblin-utility/src/main/java/org/apache/gobblin/util/ParallelRunner.java | ParallelRunner.submitCallable | public void submitCallable(Callable<Void> callable, String name) {
this.futures.add(new NamedFuture(this.executor.submit(callable), name));
} | java | public void submitCallable(Callable<Void> callable, String name) {
this.futures.add(new NamedFuture(this.executor.submit(callable), name));
} | [
"public",
"void",
"submitCallable",
"(",
"Callable",
"<",
"Void",
">",
"callable",
",",
"String",
"name",
")",
"{",
"this",
".",
"futures",
".",
"add",
"(",
"new",
"NamedFuture",
"(",
"this",
".",
"executor",
".",
"submit",
"(",
"callable",
")",
",",
"name",
")",
")",
";",
"}"
] | Submit a callable to the thread pool
<p>
This method submits a task and returns immediately
</p>
@param callable the callable to submit
@param name for the future | [
"Submit",
"a",
"callable",
"to",
"the",
"thread",
"pool"
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-utility/src/main/java/org/apache/gobblin/util/ParallelRunner.java#L349-L351 |
25,839 | apache/incubator-gobblin | gobblin-core/src/main/java/org/apache/gobblin/writer/SimpleDataWriter.java | SimpleDataWriter.write | @Override
public void write(byte[] record) throws IOException {
Preconditions.checkNotNull(record);
byte[] toWrite = record;
if (this.recordDelimiter.isPresent()) {
toWrite = Arrays.copyOf(record, record.length + 1);
toWrite[toWrite.length - 1] = this.recordDelimiter.get();
}
if (this.prependSize) {
long recordSize = toWrite.length;
ByteBuffer buf = ByteBuffer.allocate(Longs.BYTES);
buf.putLong(recordSize);
toWrite = ArrayUtils.addAll(buf.array(), toWrite);
}
this.stagingFileOutputStream.write(toWrite);
this.bytesWritten += toWrite.length;
this.recordsWritten++;
} | java | @Override
public void write(byte[] record) throws IOException {
Preconditions.checkNotNull(record);
byte[] toWrite = record;
if (this.recordDelimiter.isPresent()) {
toWrite = Arrays.copyOf(record, record.length + 1);
toWrite[toWrite.length - 1] = this.recordDelimiter.get();
}
if (this.prependSize) {
long recordSize = toWrite.length;
ByteBuffer buf = ByteBuffer.allocate(Longs.BYTES);
buf.putLong(recordSize);
toWrite = ArrayUtils.addAll(buf.array(), toWrite);
}
this.stagingFileOutputStream.write(toWrite);
this.bytesWritten += toWrite.length;
this.recordsWritten++;
} | [
"@",
"Override",
"public",
"void",
"write",
"(",
"byte",
"[",
"]",
"record",
")",
"throws",
"IOException",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"record",
")",
";",
"byte",
"[",
"]",
"toWrite",
"=",
"record",
";",
"if",
"(",
"this",
".",
"recordDelimiter",
".",
"isPresent",
"(",
")",
")",
"{",
"toWrite",
"=",
"Arrays",
".",
"copyOf",
"(",
"record",
",",
"record",
".",
"length",
"+",
"1",
")",
";",
"toWrite",
"[",
"toWrite",
".",
"length",
"-",
"1",
"]",
"=",
"this",
".",
"recordDelimiter",
".",
"get",
"(",
")",
";",
"}",
"if",
"(",
"this",
".",
"prependSize",
")",
"{",
"long",
"recordSize",
"=",
"toWrite",
".",
"length",
";",
"ByteBuffer",
"buf",
"=",
"ByteBuffer",
".",
"allocate",
"(",
"Longs",
".",
"BYTES",
")",
";",
"buf",
".",
"putLong",
"(",
"recordSize",
")",
";",
"toWrite",
"=",
"ArrayUtils",
".",
"addAll",
"(",
"buf",
".",
"array",
"(",
")",
",",
"toWrite",
")",
";",
"}",
"this",
".",
"stagingFileOutputStream",
".",
"write",
"(",
"toWrite",
")",
";",
"this",
".",
"bytesWritten",
"+=",
"toWrite",
".",
"length",
";",
"this",
".",
"recordsWritten",
"++",
";",
"}"
] | Write a source record to the staging file
@param record data record to write
@throws java.io.IOException if there is anything wrong writing the record | [
"Write",
"a",
"source",
"record",
"to",
"the",
"staging",
"file"
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-core/src/main/java/org/apache/gobblin/writer/SimpleDataWriter.java#L85-L103 |
25,840 | apache/incubator-gobblin | gobblin-data-management/src/main/java/org/apache/gobblin/data/management/trash/ProxiedTrash.java | ProxiedTrash.moveToTrashAsUser | @Override
public boolean moveToTrashAsUser(Path path, final String user) throws IOException {
return getUserTrash(user).moveToTrash(path);
} | java | @Override
public boolean moveToTrashAsUser(Path path, final String user) throws IOException {
return getUserTrash(user).moveToTrash(path);
} | [
"@",
"Override",
"public",
"boolean",
"moveToTrashAsUser",
"(",
"Path",
"path",
",",
"final",
"String",
"user",
")",
"throws",
"IOException",
"{",
"return",
"getUserTrash",
"(",
"user",
")",
".",
"moveToTrash",
"(",
"path",
")",
";",
"}"
] | Move the path to trash as specified user.
@param path {@link org.apache.hadoop.fs.Path} to move.
@param user User to move the path as.
@return true if the move succeeded.
@throws IOException | [
"Move",
"the",
"path",
"to",
"trash",
"as",
"specified",
"user",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-data-management/src/main/java/org/apache/gobblin/data/management/trash/ProxiedTrash.java#L61-L64 |
25,841 | apache/incubator-gobblin | gobblin-data-management/src/main/java/org/apache/gobblin/data/management/trash/ProxiedTrash.java | ProxiedTrash.moveToTrashAsOwner | public boolean moveToTrashAsOwner(Path path) throws IOException {
String owner = this.fs.getFileStatus(path).getOwner();
return moveToTrashAsUser(path, owner);
} | java | public boolean moveToTrashAsOwner(Path path) throws IOException {
String owner = this.fs.getFileStatus(path).getOwner();
return moveToTrashAsUser(path, owner);
} | [
"public",
"boolean",
"moveToTrashAsOwner",
"(",
"Path",
"path",
")",
"throws",
"IOException",
"{",
"String",
"owner",
"=",
"this",
".",
"fs",
".",
"getFileStatus",
"(",
"path",
")",
".",
"getOwner",
"(",
")",
";",
"return",
"moveToTrashAsUser",
"(",
"path",
",",
"owner",
")",
";",
"}"
] | Move the path to trash as the owner of the path.
@param path {@link org.apache.hadoop.fs.Path} to move.
@return true if the move succeeded.
@throws IOException | [
"Move",
"the",
"path",
"to",
"trash",
"as",
"the",
"owner",
"of",
"the",
"path",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-data-management/src/main/java/org/apache/gobblin/data/management/trash/ProxiedTrash.java#L72-L75 |
25,842 | apache/incubator-gobblin | gobblin-metrics-libs/gobblin-metrics-base/src/main/java/org/apache/gobblin/metrics/example/ReporterExampleBase.java | ReporterExampleBase.run | public void run() throws Exception {
try {
CountDownLatch countDownLatch = new CountDownLatch(this.tasks);
for (int i = 0; i < this.tasks; i++) {
addTask(i, countDownLatch);
}
// Wait for the tasks to finish
countDownLatch.await();
} finally {
try {
// Calling close() will stop metric reporting
this.context.close();
} finally {
this.executor.shutdownNow();
}
}
} | java | public void run() throws Exception {
try {
CountDownLatch countDownLatch = new CountDownLatch(this.tasks);
for (int i = 0; i < this.tasks; i++) {
addTask(i, countDownLatch);
}
// Wait for the tasks to finish
countDownLatch.await();
} finally {
try {
// Calling close() will stop metric reporting
this.context.close();
} finally {
this.executor.shutdownNow();
}
}
} | [
"public",
"void",
"run",
"(",
")",
"throws",
"Exception",
"{",
"try",
"{",
"CountDownLatch",
"countDownLatch",
"=",
"new",
"CountDownLatch",
"(",
"this",
".",
"tasks",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"tasks",
";",
"i",
"++",
")",
"{",
"addTask",
"(",
"i",
",",
"countDownLatch",
")",
";",
"}",
"// Wait for the tasks to finish",
"countDownLatch",
".",
"await",
"(",
")",
";",
"}",
"finally",
"{",
"try",
"{",
"// Calling close() will stop metric reporting",
"this",
".",
"context",
".",
"close",
"(",
")",
";",
"}",
"finally",
"{",
"this",
".",
"executor",
".",
"shutdownNow",
"(",
")",
";",
"}",
"}",
"}"
] | Run the example. | [
"Run",
"the",
"example",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-metrics-libs/gobblin-metrics-base/src/main/java/org/apache/gobblin/metrics/example/ReporterExampleBase.java#L97-L114 |
25,843 | apache/incubator-gobblin | gobblin-utility/src/main/java/org/apache/gobblin/util/logs/LogCopier.java | LogCopier.checkSrcLogFiles | private void checkSrcLogFiles() throws IOException {
List<FileStatus> srcLogFiles = new ArrayList<>();
for (Path logDirPath: this.srcLogDirs) {
srcLogFiles.addAll(FileListUtils.listFilesRecursively(this.srcFs, logDirPath, new PathFilter() {
@Override
public boolean accept(Path path) {
return LogCopier.this.logFileExtensions.contains(Files.getFileExtension(path.getName()));
}
}));
}
if (srcLogFiles.isEmpty()) {
LOGGER.warn("No log file found under directories " + this.srcLogDirs);
return;
}
Set<Path> newLogFiles = Sets.newHashSet();
for (FileStatus srcLogFile : srcLogFiles) {
newLogFiles.add(srcLogFile.getPath());
}
HashSet<Path> deletedLogFiles = Sets.newHashSet(getSourceFiles());
// Compute the set of deleted log files since the last check
deletedLogFiles.removeAll(newLogFiles);
// Compute the set of new log files since the last check
newLogFiles.removeAll(getSourceFiles());
// Schedule a copy task for each new log file
for (final Path srcLogFile : newLogFiles) {
String destLogFileName = this.logFileNamePrefix.isPresent()
? this.logFileNamePrefix.get() + "." + srcLogFile.getName() : srcLogFile.getName();
final Path destLogFile = new Path(this.destLogDir, destLogFileName);
this.scheduler.schedule(new LogCopyTask(srcLogFile, destLogFile), this.copyInterval, this.timeUnit);
}
// Cancel the copy task for each deleted log file
for (Path deletedLogFile : deletedLogFiles) {
Optional<LogCopyTask> logCopyTask = this.scheduler.getScheduledTask(deletedLogFile);
if (logCopyTask.isPresent()) {
this.scheduler.cancel(logCopyTask.get());
}
}
} | java | private void checkSrcLogFiles() throws IOException {
List<FileStatus> srcLogFiles = new ArrayList<>();
for (Path logDirPath: this.srcLogDirs) {
srcLogFiles.addAll(FileListUtils.listFilesRecursively(this.srcFs, logDirPath, new PathFilter() {
@Override
public boolean accept(Path path) {
return LogCopier.this.logFileExtensions.contains(Files.getFileExtension(path.getName()));
}
}));
}
if (srcLogFiles.isEmpty()) {
LOGGER.warn("No log file found under directories " + this.srcLogDirs);
return;
}
Set<Path> newLogFiles = Sets.newHashSet();
for (FileStatus srcLogFile : srcLogFiles) {
newLogFiles.add(srcLogFile.getPath());
}
HashSet<Path> deletedLogFiles = Sets.newHashSet(getSourceFiles());
// Compute the set of deleted log files since the last check
deletedLogFiles.removeAll(newLogFiles);
// Compute the set of new log files since the last check
newLogFiles.removeAll(getSourceFiles());
// Schedule a copy task for each new log file
for (final Path srcLogFile : newLogFiles) {
String destLogFileName = this.logFileNamePrefix.isPresent()
? this.logFileNamePrefix.get() + "." + srcLogFile.getName() : srcLogFile.getName();
final Path destLogFile = new Path(this.destLogDir, destLogFileName);
this.scheduler.schedule(new LogCopyTask(srcLogFile, destLogFile), this.copyInterval, this.timeUnit);
}
// Cancel the copy task for each deleted log file
for (Path deletedLogFile : deletedLogFiles) {
Optional<LogCopyTask> logCopyTask = this.scheduler.getScheduledTask(deletedLogFile);
if (logCopyTask.isPresent()) {
this.scheduler.cancel(logCopyTask.get());
}
}
} | [
"private",
"void",
"checkSrcLogFiles",
"(",
")",
"throws",
"IOException",
"{",
"List",
"<",
"FileStatus",
">",
"srcLogFiles",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"Path",
"logDirPath",
":",
"this",
".",
"srcLogDirs",
")",
"{",
"srcLogFiles",
".",
"addAll",
"(",
"FileListUtils",
".",
"listFilesRecursively",
"(",
"this",
".",
"srcFs",
",",
"logDirPath",
",",
"new",
"PathFilter",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"accept",
"(",
"Path",
"path",
")",
"{",
"return",
"LogCopier",
".",
"this",
".",
"logFileExtensions",
".",
"contains",
"(",
"Files",
".",
"getFileExtension",
"(",
"path",
".",
"getName",
"(",
")",
")",
")",
";",
"}",
"}",
")",
")",
";",
"}",
"if",
"(",
"srcLogFiles",
".",
"isEmpty",
"(",
")",
")",
"{",
"LOGGER",
".",
"warn",
"(",
"\"No log file found under directories \"",
"+",
"this",
".",
"srcLogDirs",
")",
";",
"return",
";",
"}",
"Set",
"<",
"Path",
">",
"newLogFiles",
"=",
"Sets",
".",
"newHashSet",
"(",
")",
";",
"for",
"(",
"FileStatus",
"srcLogFile",
":",
"srcLogFiles",
")",
"{",
"newLogFiles",
".",
"add",
"(",
"srcLogFile",
".",
"getPath",
"(",
")",
")",
";",
"}",
"HashSet",
"<",
"Path",
">",
"deletedLogFiles",
"=",
"Sets",
".",
"newHashSet",
"(",
"getSourceFiles",
"(",
")",
")",
";",
"// Compute the set of deleted log files since the last check",
"deletedLogFiles",
".",
"removeAll",
"(",
"newLogFiles",
")",
";",
"// Compute the set of new log files since the last check",
"newLogFiles",
".",
"removeAll",
"(",
"getSourceFiles",
"(",
")",
")",
";",
"// Schedule a copy task for each new log file",
"for",
"(",
"final",
"Path",
"srcLogFile",
":",
"newLogFiles",
")",
"{",
"String",
"destLogFileName",
"=",
"this",
".",
"logFileNamePrefix",
".",
"isPresent",
"(",
")",
"?",
"this",
".",
"logFileNamePrefix",
".",
"get",
"(",
")",
"+",
"\".\"",
"+",
"srcLogFile",
".",
"getName",
"(",
")",
":",
"srcLogFile",
".",
"getName",
"(",
")",
";",
"final",
"Path",
"destLogFile",
"=",
"new",
"Path",
"(",
"this",
".",
"destLogDir",
",",
"destLogFileName",
")",
";",
"this",
".",
"scheduler",
".",
"schedule",
"(",
"new",
"LogCopyTask",
"(",
"srcLogFile",
",",
"destLogFile",
")",
",",
"this",
".",
"copyInterval",
",",
"this",
".",
"timeUnit",
")",
";",
"}",
"// Cancel the copy task for each deleted log file",
"for",
"(",
"Path",
"deletedLogFile",
":",
"deletedLogFiles",
")",
"{",
"Optional",
"<",
"LogCopyTask",
">",
"logCopyTask",
"=",
"this",
".",
"scheduler",
".",
"getScheduledTask",
"(",
"deletedLogFile",
")",
";",
"if",
"(",
"logCopyTask",
".",
"isPresent",
"(",
")",
")",
"{",
"this",
".",
"scheduler",
".",
"cancel",
"(",
"logCopyTask",
".",
"get",
"(",
")",
")",
";",
"}",
"}",
"}"
] | Perform a check on new source log files and submit copy tasks for new log files. | [
"Perform",
"a",
"check",
"on",
"new",
"source",
"log",
"files",
"and",
"submit",
"copy",
"tasks",
"for",
"new",
"log",
"files",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-utility/src/main/java/org/apache/gobblin/util/logs/LogCopier.java#L184-L228 |
25,844 | apache/incubator-gobblin | gobblin-utility/src/main/java/org/apache/gobblin/util/WritableShimSerialization.java | WritableShimSerialization.addToHadoopConfiguration | public static void addToHadoopConfiguration(Configuration conf) {
final String SERIALIZATION_KEY = "io.serializations";
String existingSerializers = conf.get(SERIALIZATION_KEY);
if (existingSerializers != null) {
conf.set(SERIALIZATION_KEY, existingSerializers + "," + WritableShimSerialization.class.getName());
} else {
conf.set(SERIALIZATION_KEY,
"org.apache.hadoop.io.serializer.WritableSerialization," + WritableShimSerialization.class.getName());
}
} | java | public static void addToHadoopConfiguration(Configuration conf) {
final String SERIALIZATION_KEY = "io.serializations";
String existingSerializers = conf.get(SERIALIZATION_KEY);
if (existingSerializers != null) {
conf.set(SERIALIZATION_KEY, existingSerializers + "," + WritableShimSerialization.class.getName());
} else {
conf.set(SERIALIZATION_KEY,
"org.apache.hadoop.io.serializer.WritableSerialization," + WritableShimSerialization.class.getName());
}
} | [
"public",
"static",
"void",
"addToHadoopConfiguration",
"(",
"Configuration",
"conf",
")",
"{",
"final",
"String",
"SERIALIZATION_KEY",
"=",
"\"io.serializations\"",
";",
"String",
"existingSerializers",
"=",
"conf",
".",
"get",
"(",
"SERIALIZATION_KEY",
")",
";",
"if",
"(",
"existingSerializers",
"!=",
"null",
")",
"{",
"conf",
".",
"set",
"(",
"SERIALIZATION_KEY",
",",
"existingSerializers",
"+",
"\",\"",
"+",
"WritableShimSerialization",
".",
"class",
".",
"getName",
"(",
")",
")",
";",
"}",
"else",
"{",
"conf",
".",
"set",
"(",
"SERIALIZATION_KEY",
",",
"\"org.apache.hadoop.io.serializer.WritableSerialization,\"",
"+",
"WritableShimSerialization",
".",
"class",
".",
"getName",
"(",
")",
")",
";",
"}",
"}"
] | Helper method to add this serializer to an existing Hadoop config. | [
"Helper",
"method",
"to",
"add",
"this",
"serializer",
"to",
"an",
"existing",
"Hadoop",
"config",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-utility/src/main/java/org/apache/gobblin/util/WritableShimSerialization.java#L42-L52 |
25,845 | apache/incubator-gobblin | gobblin-modules/google-ingestion/src/main/java/org/apache/gobblin/ingestion/google/webmaster/TrieBasedProducerJob.java | TrieBasedProducerJob.partitionJobs | @Override
public List<? extends ProducerJob> partitionJobs() {
UrlTrieNode root = _jobNode.getRight();
if (isOperatorEquals() || root.getSize() == 1) {
//Either at an Equals-Node or a Leaf-Node, both of which actually has actual size 1.
return super.partitionJobs();
} else {
if (_groupSize <= 1) {
throw new RuntimeException("This is impossible. When group size is 1, the operator must be equals");
}
UrlTrie trie = new UrlTrie(getPage(), root);
int gs = Math.min(root.getSize(), _groupSize);
UrlTriePrefixGrouper grouper = new UrlTriePrefixGrouper(trie, (int) Math.ceil(gs / 2.0));
List<TrieBasedProducerJob> jobs = new ArrayList<>();
while (grouper.hasNext()) {
jobs.add(new TrieBasedProducerJob(_startDate, _endDate, grouper.next(), grouper.getGroupSize()));
}
return jobs;
}
} | java | @Override
public List<? extends ProducerJob> partitionJobs() {
UrlTrieNode root = _jobNode.getRight();
if (isOperatorEquals() || root.getSize() == 1) {
//Either at an Equals-Node or a Leaf-Node, both of which actually has actual size 1.
return super.partitionJobs();
} else {
if (_groupSize <= 1) {
throw new RuntimeException("This is impossible. When group size is 1, the operator must be equals");
}
UrlTrie trie = new UrlTrie(getPage(), root);
int gs = Math.min(root.getSize(), _groupSize);
UrlTriePrefixGrouper grouper = new UrlTriePrefixGrouper(trie, (int) Math.ceil(gs / 2.0));
List<TrieBasedProducerJob> jobs = new ArrayList<>();
while (grouper.hasNext()) {
jobs.add(new TrieBasedProducerJob(_startDate, _endDate, grouper.next(), grouper.getGroupSize()));
}
return jobs;
}
} | [
"@",
"Override",
"public",
"List",
"<",
"?",
"extends",
"ProducerJob",
">",
"partitionJobs",
"(",
")",
"{",
"UrlTrieNode",
"root",
"=",
"_jobNode",
".",
"getRight",
"(",
")",
";",
"if",
"(",
"isOperatorEquals",
"(",
")",
"||",
"root",
".",
"getSize",
"(",
")",
"==",
"1",
")",
"{",
"//Either at an Equals-Node or a Leaf-Node, both of which actually has actual size 1.",
"return",
"super",
".",
"partitionJobs",
"(",
")",
";",
"}",
"else",
"{",
"if",
"(",
"_groupSize",
"<=",
"1",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"This is impossible. When group size is 1, the operator must be equals\"",
")",
";",
"}",
"UrlTrie",
"trie",
"=",
"new",
"UrlTrie",
"(",
"getPage",
"(",
")",
",",
"root",
")",
";",
"int",
"gs",
"=",
"Math",
".",
"min",
"(",
"root",
".",
"getSize",
"(",
")",
",",
"_groupSize",
")",
";",
"UrlTriePrefixGrouper",
"grouper",
"=",
"new",
"UrlTriePrefixGrouper",
"(",
"trie",
",",
"(",
"int",
")",
"Math",
".",
"ceil",
"(",
"gs",
"/",
"2.0",
")",
")",
";",
"List",
"<",
"TrieBasedProducerJob",
">",
"jobs",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"while",
"(",
"grouper",
".",
"hasNext",
"(",
")",
")",
"{",
"jobs",
".",
"add",
"(",
"new",
"TrieBasedProducerJob",
"(",
"_startDate",
",",
"_endDate",
",",
"grouper",
".",
"next",
"(",
")",
",",
"grouper",
".",
"getGroupSize",
"(",
")",
")",
")",
";",
"}",
"return",
"jobs",
";",
"}",
"}"
] | The implementation here will first partition the job by pages, and then by dates.
@return | [
"The",
"implementation",
"here",
"will",
"first",
"partition",
"the",
"job",
"by",
"pages",
"and",
"then",
"by",
"dates",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/google-ingestion/src/main/java/org/apache/gobblin/ingestion/google/webmaster/TrieBasedProducerJob.java#L73-L95 |
25,846 | apache/incubator-gobblin | gobblin-modules/gobblin-metrics-influxdb/src/main/java/org/apache/gobblin/metrics/influxdb/InfluxDBPusher.java | InfluxDBPusher.push | public void push(Point point) {
BatchPoints.Builder batchPointsBuilder = BatchPoints.database(database).retentionPolicy(DEFAULT_RETENTION_POLICY);
batchPointsBuilder.point(point);
influxDB.write(batchPointsBuilder.build());
} | java | public void push(Point point) {
BatchPoints.Builder batchPointsBuilder = BatchPoints.database(database).retentionPolicy(DEFAULT_RETENTION_POLICY);
batchPointsBuilder.point(point);
influxDB.write(batchPointsBuilder.build());
} | [
"public",
"void",
"push",
"(",
"Point",
"point",
")",
"{",
"BatchPoints",
".",
"Builder",
"batchPointsBuilder",
"=",
"BatchPoints",
".",
"database",
"(",
"database",
")",
".",
"retentionPolicy",
"(",
"DEFAULT_RETENTION_POLICY",
")",
";",
"batchPointsBuilder",
".",
"point",
"(",
"point",
")",
";",
"influxDB",
".",
"write",
"(",
"batchPointsBuilder",
".",
"build",
"(",
")",
")",
";",
"}"
] | Push a single Point
@param point the {@link Point} to report | [
"Push",
"a",
"single",
"Point"
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-metrics-influxdb/src/main/java/org/apache/gobblin/metrics/influxdb/InfluxDBPusher.java#L86-L90 |
25,847 | apache/incubator-gobblin | gobblin-modules/gobblin-kafka-common/src/main/java/org/apache/gobblin/source/extractor/extract/kafka/KafkaUtils.java | KafkaUtils.getPropAsLongFromSingleOrMultiWorkUnitState | public static long getPropAsLongFromSingleOrMultiWorkUnitState(WorkUnitState workUnitState,
String key, int partitionId) {
return Long.parseLong(workUnitState.contains(key) ? workUnitState.getProp(key)
: workUnitState.getProp(KafkaUtils.getPartitionPropName(key, partitionId), "0"));
} | java | public static long getPropAsLongFromSingleOrMultiWorkUnitState(WorkUnitState workUnitState,
String key, int partitionId) {
return Long.parseLong(workUnitState.contains(key) ? workUnitState.getProp(key)
: workUnitState.getProp(KafkaUtils.getPartitionPropName(key, partitionId), "0"));
} | [
"public",
"static",
"long",
"getPropAsLongFromSingleOrMultiWorkUnitState",
"(",
"WorkUnitState",
"workUnitState",
",",
"String",
"key",
",",
"int",
"partitionId",
")",
"{",
"return",
"Long",
".",
"parseLong",
"(",
"workUnitState",
".",
"contains",
"(",
"key",
")",
"?",
"workUnitState",
".",
"getProp",
"(",
"key",
")",
":",
"workUnitState",
".",
"getProp",
"(",
"KafkaUtils",
".",
"getPartitionPropName",
"(",
"key",
",",
"partitionId",
")",
",",
"\"0\"",
")",
")",
";",
"}"
] | Get a property as long from a work unit that may or may not be a multiworkunit.
This method is needed because the SingleLevelWorkUnitPacker does not squeeze work units
into a multiworkunit, and thus does not append the partitionId to property keys, while
the BiLevelWorkUnitPacker does.
Return 0 as default if key not found in either form. | [
"Get",
"a",
"property",
"as",
"long",
"from",
"a",
"work",
"unit",
"that",
"may",
"or",
"may",
"not",
"be",
"a",
"multiworkunit",
".",
"This",
"method",
"is",
"needed",
"because",
"the",
"SingleLevelWorkUnitPacker",
"does",
"not",
"squeeze",
"work",
"units",
"into",
"a",
"multiworkunit",
"and",
"thus",
"does",
"not",
"append",
"the",
"partitionId",
"to",
"property",
"keys",
"while",
"the",
"BiLevelWorkUnitPacker",
"does",
".",
"Return",
"0",
"as",
"default",
"if",
"key",
"not",
"found",
"in",
"either",
"form",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-kafka-common/src/main/java/org/apache/gobblin/source/extractor/extract/kafka/KafkaUtils.java#L180-L184 |
25,848 | apache/incubator-gobblin | gobblin-salesforce/src/main/java/org/apache/gobblin/salesforce/SalesforceSource.java | SalesforceSource.computeTargetPartitionSize | private int computeTargetPartitionSize(Histogram histogram, int minTargetPartitionSize, int maxPartitions) {
return Math.max(minTargetPartitionSize,
DoubleMath.roundToInt((double) histogram.totalRecordCount / maxPartitions, RoundingMode.CEILING));
} | java | private int computeTargetPartitionSize(Histogram histogram, int minTargetPartitionSize, int maxPartitions) {
return Math.max(minTargetPartitionSize,
DoubleMath.roundToInt((double) histogram.totalRecordCount / maxPartitions, RoundingMode.CEILING));
} | [
"private",
"int",
"computeTargetPartitionSize",
"(",
"Histogram",
"histogram",
",",
"int",
"minTargetPartitionSize",
",",
"int",
"maxPartitions",
")",
"{",
"return",
"Math",
".",
"max",
"(",
"minTargetPartitionSize",
",",
"DoubleMath",
".",
"roundToInt",
"(",
"(",
"double",
")",
"histogram",
".",
"totalRecordCount",
"/",
"maxPartitions",
",",
"RoundingMode",
".",
"CEILING",
")",
")",
";",
"}"
] | Compute the target partition size. | [
"Compute",
"the",
"target",
"partition",
"size",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-salesforce/src/main/java/org/apache/gobblin/salesforce/SalesforceSource.java#L287-L290 |
25,849 | apache/incubator-gobblin | gobblin-salesforce/src/main/java/org/apache/gobblin/salesforce/SalesforceSource.java | SalesforceSource.getCountForRange | private int getCountForRange(TableCountProbingContext probingContext, StrSubstitutor sub,
Map<String, String> subValues, long startTime, long endTime) {
String startTimeStr = Utils.dateToString(new Date(startTime), SalesforceExtractor.SALESFORCE_TIMESTAMP_FORMAT);
String endTimeStr = Utils.dateToString(new Date(endTime), SalesforceExtractor.SALESFORCE_TIMESTAMP_FORMAT);
subValues.put("start", startTimeStr);
subValues.put("end", endTimeStr);
String query = sub.replace(PROBE_PARTITION_QUERY_TEMPLATE);
log.debug("Count query: " + query);
probingContext.probeCount++;
JsonArray records = getRecordsForQuery(probingContext.connector, query);
Iterator<JsonElement> elements = records.iterator();
JsonObject element = elements.next().getAsJsonObject();
return element.get("cnt").getAsInt();
} | java | private int getCountForRange(TableCountProbingContext probingContext, StrSubstitutor sub,
Map<String, String> subValues, long startTime, long endTime) {
String startTimeStr = Utils.dateToString(new Date(startTime), SalesforceExtractor.SALESFORCE_TIMESTAMP_FORMAT);
String endTimeStr = Utils.dateToString(new Date(endTime), SalesforceExtractor.SALESFORCE_TIMESTAMP_FORMAT);
subValues.put("start", startTimeStr);
subValues.put("end", endTimeStr);
String query = sub.replace(PROBE_PARTITION_QUERY_TEMPLATE);
log.debug("Count query: " + query);
probingContext.probeCount++;
JsonArray records = getRecordsForQuery(probingContext.connector, query);
Iterator<JsonElement> elements = records.iterator();
JsonObject element = elements.next().getAsJsonObject();
return element.get("cnt").getAsInt();
} | [
"private",
"int",
"getCountForRange",
"(",
"TableCountProbingContext",
"probingContext",
",",
"StrSubstitutor",
"sub",
",",
"Map",
"<",
"String",
",",
"String",
">",
"subValues",
",",
"long",
"startTime",
",",
"long",
"endTime",
")",
"{",
"String",
"startTimeStr",
"=",
"Utils",
".",
"dateToString",
"(",
"new",
"Date",
"(",
"startTime",
")",
",",
"SalesforceExtractor",
".",
"SALESFORCE_TIMESTAMP_FORMAT",
")",
";",
"String",
"endTimeStr",
"=",
"Utils",
".",
"dateToString",
"(",
"new",
"Date",
"(",
"endTime",
")",
",",
"SalesforceExtractor",
".",
"SALESFORCE_TIMESTAMP_FORMAT",
")",
";",
"subValues",
".",
"put",
"(",
"\"start\"",
",",
"startTimeStr",
")",
";",
"subValues",
".",
"put",
"(",
"\"end\"",
",",
"endTimeStr",
")",
";",
"String",
"query",
"=",
"sub",
".",
"replace",
"(",
"PROBE_PARTITION_QUERY_TEMPLATE",
")",
";",
"log",
".",
"debug",
"(",
"\"Count query: \"",
"+",
"query",
")",
";",
"probingContext",
".",
"probeCount",
"++",
";",
"JsonArray",
"records",
"=",
"getRecordsForQuery",
"(",
"probingContext",
".",
"connector",
",",
"query",
")",
";",
"Iterator",
"<",
"JsonElement",
">",
"elements",
"=",
"records",
".",
"iterator",
"(",
")",
";",
"JsonObject",
"element",
"=",
"elements",
".",
"next",
"(",
")",
".",
"getAsJsonObject",
"(",
")",
";",
"return",
"element",
".",
"get",
"(",
"\"cnt\"",
")",
".",
"getAsInt",
"(",
")",
";",
"}"
] | Get the row count for a time range | [
"Get",
"the",
"row",
"count",
"for",
"a",
"time",
"range"
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-salesforce/src/main/java/org/apache/gobblin/salesforce/SalesforceSource.java#L318-L336 |
25,850 | apache/incubator-gobblin | gobblin-salesforce/src/main/java/org/apache/gobblin/salesforce/SalesforceSource.java | SalesforceSource.getHistogramRecursively | private void getHistogramRecursively(TableCountProbingContext probingContext, Histogram histogram, StrSubstitutor sub,
Map<String, String> values, int count, long startEpoch, long endEpoch) {
long midpointEpoch = startEpoch + (endEpoch - startEpoch) / 2;
// don't split further if small, above the probe limit, or less than 1 second difference between the midpoint and start
if (count <= probingContext.bucketSizeLimit
|| probingContext.probeCount > probingContext.probeLimit
|| (midpointEpoch - startEpoch < MIN_SPLIT_TIME_MILLIS)) {
histogram.add(new HistogramGroup(Utils.epochToDate(startEpoch, SECONDS_FORMAT), count));
return;
}
int countLeft = getCountForRange(probingContext, sub, values, startEpoch, midpointEpoch);
getHistogramRecursively(probingContext, histogram, sub, values, countLeft, startEpoch, midpointEpoch);
log.debug("Count {} for left partition {} to {}", countLeft, startEpoch, midpointEpoch);
int countRight = count - countLeft;
getHistogramRecursively(probingContext, histogram, sub, values, countRight, midpointEpoch, endEpoch);
log.debug("Count {} for right partition {} to {}", countRight, midpointEpoch, endEpoch);
} | java | private void getHistogramRecursively(TableCountProbingContext probingContext, Histogram histogram, StrSubstitutor sub,
Map<String, String> values, int count, long startEpoch, long endEpoch) {
long midpointEpoch = startEpoch + (endEpoch - startEpoch) / 2;
// don't split further if small, above the probe limit, or less than 1 second difference between the midpoint and start
if (count <= probingContext.bucketSizeLimit
|| probingContext.probeCount > probingContext.probeLimit
|| (midpointEpoch - startEpoch < MIN_SPLIT_TIME_MILLIS)) {
histogram.add(new HistogramGroup(Utils.epochToDate(startEpoch, SECONDS_FORMAT), count));
return;
}
int countLeft = getCountForRange(probingContext, sub, values, startEpoch, midpointEpoch);
getHistogramRecursively(probingContext, histogram, sub, values, countLeft, startEpoch, midpointEpoch);
log.debug("Count {} for left partition {} to {}", countLeft, startEpoch, midpointEpoch);
int countRight = count - countLeft;
getHistogramRecursively(probingContext, histogram, sub, values, countRight, midpointEpoch, endEpoch);
log.debug("Count {} for right partition {} to {}", countRight, midpointEpoch, endEpoch);
} | [
"private",
"void",
"getHistogramRecursively",
"(",
"TableCountProbingContext",
"probingContext",
",",
"Histogram",
"histogram",
",",
"StrSubstitutor",
"sub",
",",
"Map",
"<",
"String",
",",
"String",
">",
"values",
",",
"int",
"count",
",",
"long",
"startEpoch",
",",
"long",
"endEpoch",
")",
"{",
"long",
"midpointEpoch",
"=",
"startEpoch",
"+",
"(",
"endEpoch",
"-",
"startEpoch",
")",
"/",
"2",
";",
"// don't split further if small, above the probe limit, or less than 1 second difference between the midpoint and start",
"if",
"(",
"count",
"<=",
"probingContext",
".",
"bucketSizeLimit",
"||",
"probingContext",
".",
"probeCount",
">",
"probingContext",
".",
"probeLimit",
"||",
"(",
"midpointEpoch",
"-",
"startEpoch",
"<",
"MIN_SPLIT_TIME_MILLIS",
")",
")",
"{",
"histogram",
".",
"add",
"(",
"new",
"HistogramGroup",
"(",
"Utils",
".",
"epochToDate",
"(",
"startEpoch",
",",
"SECONDS_FORMAT",
")",
",",
"count",
")",
")",
";",
"return",
";",
"}",
"int",
"countLeft",
"=",
"getCountForRange",
"(",
"probingContext",
",",
"sub",
",",
"values",
",",
"startEpoch",
",",
"midpointEpoch",
")",
";",
"getHistogramRecursively",
"(",
"probingContext",
",",
"histogram",
",",
"sub",
",",
"values",
",",
"countLeft",
",",
"startEpoch",
",",
"midpointEpoch",
")",
";",
"log",
".",
"debug",
"(",
"\"Count {} for left partition {} to {}\"",
",",
"countLeft",
",",
"startEpoch",
",",
"midpointEpoch",
")",
";",
"int",
"countRight",
"=",
"count",
"-",
"countLeft",
";",
"getHistogramRecursively",
"(",
"probingContext",
",",
"histogram",
",",
"sub",
",",
"values",
",",
"countRight",
",",
"midpointEpoch",
",",
"endEpoch",
")",
";",
"log",
".",
"debug",
"(",
"\"Count {} for right partition {} to {}\"",
",",
"countRight",
",",
"midpointEpoch",
",",
"endEpoch",
")",
";",
"}"
] | Split a histogram bucket along the midpoint if it is larger than the bucket size limit. | [
"Split",
"a",
"histogram",
"bucket",
"along",
"the",
"midpoint",
"if",
"it",
"is",
"larger",
"than",
"the",
"bucket",
"size",
"limit",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-salesforce/src/main/java/org/apache/gobblin/salesforce/SalesforceSource.java#L341-L362 |
25,851 | apache/incubator-gobblin | gobblin-salesforce/src/main/java/org/apache/gobblin/salesforce/SalesforceSource.java | SalesforceSource.getHistogramByProbing | private Histogram getHistogramByProbing(TableCountProbingContext probingContext, int count, long startEpoch,
long endEpoch) {
Histogram histogram = new Histogram();
Map<String, String> values = new HashMap<>();
values.put("table", probingContext.entity);
values.put("column", probingContext.watermarkColumn);
values.put("greater", ">=");
values.put("less", "<");
StrSubstitutor sub = new StrSubstitutor(values);
getHistogramRecursively(probingContext, histogram, sub, values, count, startEpoch, endEpoch);
return histogram;
} | java | private Histogram getHistogramByProbing(TableCountProbingContext probingContext, int count, long startEpoch,
long endEpoch) {
Histogram histogram = new Histogram();
Map<String, String> values = new HashMap<>();
values.put("table", probingContext.entity);
values.put("column", probingContext.watermarkColumn);
values.put("greater", ">=");
values.put("less", "<");
StrSubstitutor sub = new StrSubstitutor(values);
getHistogramRecursively(probingContext, histogram, sub, values, count, startEpoch, endEpoch);
return histogram;
} | [
"private",
"Histogram",
"getHistogramByProbing",
"(",
"TableCountProbingContext",
"probingContext",
",",
"int",
"count",
",",
"long",
"startEpoch",
",",
"long",
"endEpoch",
")",
"{",
"Histogram",
"histogram",
"=",
"new",
"Histogram",
"(",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"values",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"values",
".",
"put",
"(",
"\"table\"",
",",
"probingContext",
".",
"entity",
")",
";",
"values",
".",
"put",
"(",
"\"column\"",
",",
"probingContext",
".",
"watermarkColumn",
")",
";",
"values",
".",
"put",
"(",
"\"greater\"",
",",
"\">=\"",
")",
";",
"values",
".",
"put",
"(",
"\"less\"",
",",
"\"<\"",
")",
";",
"StrSubstitutor",
"sub",
"=",
"new",
"StrSubstitutor",
"(",
"values",
")",
";",
"getHistogramRecursively",
"(",
"probingContext",
",",
"histogram",
",",
"sub",
",",
"values",
",",
"count",
",",
"startEpoch",
",",
"endEpoch",
")",
";",
"return",
"histogram",
";",
"}"
] | Get a histogram for the time range by probing to break down large buckets. Use count instead of
querying if it is non-negative. | [
"Get",
"a",
"histogram",
"for",
"the",
"time",
"range",
"by",
"probing",
"to",
"break",
"down",
"large",
"buckets",
".",
"Use",
"count",
"instead",
"of",
"querying",
"if",
"it",
"is",
"non",
"-",
"negative",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-salesforce/src/main/java/org/apache/gobblin/salesforce/SalesforceSource.java#L368-L382 |
25,852 | apache/incubator-gobblin | gobblin-salesforce/src/main/java/org/apache/gobblin/salesforce/SalesforceSource.java | SalesforceSource.getRefinedHistogram | private Histogram getRefinedHistogram(SalesforceConnector connector, String entity, String watermarkColumn,
SourceState state, Partition partition, Histogram histogram) {
final int maxPartitions = state.getPropAsInt(ConfigurationKeys.SOURCE_MAX_NUMBER_OF_PARTITIONS,
ConfigurationKeys.DEFAULT_MAX_NUMBER_OF_PARTITIONS);
final int probeLimit = state.getPropAsInt(DYNAMIC_PROBING_LIMIT, DEFAULT_DYNAMIC_PROBING_LIMIT);
final int minTargetPartitionSize = state.getPropAsInt(MIN_TARGET_PARTITION_SIZE, DEFAULT_MIN_TARGET_PARTITION_SIZE);
final Histogram outputHistogram = new Histogram();
final double probeTargetRatio = state.getPropAsDouble(PROBE_TARGET_RATIO, DEFAULT_PROBE_TARGET_RATIO);
final int bucketSizeLimit =
(int) (probeTargetRatio * computeTargetPartitionSize(histogram, minTargetPartitionSize, maxPartitions));
log.info("Refining histogram with bucket size limit {}.", bucketSizeLimit);
HistogramGroup currentGroup;
HistogramGroup nextGroup;
final TableCountProbingContext probingContext =
new TableCountProbingContext(connector, entity, watermarkColumn, bucketSizeLimit, probeLimit);
if (histogram.getGroups().isEmpty()) {
return outputHistogram;
}
// make a copy of the histogram list and add a dummy entry at the end to avoid special processing of the last group
List<HistogramGroup> list = new ArrayList(histogram.getGroups());
Date hwmDate = Utils.toDate(partition.getHighWatermark(), Partitioner.WATERMARKTIMEFORMAT);
list.add(new HistogramGroup(Utils.epochToDate(hwmDate.getTime(), SECONDS_FORMAT), 0));
for (int i = 0; i < list.size() - 1; i++) {
currentGroup = list.get(i);
nextGroup = list.get(i + 1);
// split the group if it is larger than the bucket size limit
if (currentGroup.count > bucketSizeLimit) {
long startEpoch = Utils.toDate(currentGroup.getKey(), SECONDS_FORMAT).getTime();
long endEpoch = Utils.toDate(nextGroup.getKey(), SECONDS_FORMAT).getTime();
outputHistogram.add(getHistogramByProbing(probingContext, currentGroup.count, startEpoch, endEpoch));
} else {
outputHistogram.add(currentGroup);
}
}
log.info("Executed {} probes for refining the histogram.", probingContext.probeCount);
// if the probe limit has been reached then print a warning
if (probingContext.probeCount >= probingContext.probeLimit) {
log.warn("Reached the probe limit");
}
return outputHistogram;
} | java | private Histogram getRefinedHistogram(SalesforceConnector connector, String entity, String watermarkColumn,
SourceState state, Partition partition, Histogram histogram) {
final int maxPartitions = state.getPropAsInt(ConfigurationKeys.SOURCE_MAX_NUMBER_OF_PARTITIONS,
ConfigurationKeys.DEFAULT_MAX_NUMBER_OF_PARTITIONS);
final int probeLimit = state.getPropAsInt(DYNAMIC_PROBING_LIMIT, DEFAULT_DYNAMIC_PROBING_LIMIT);
final int minTargetPartitionSize = state.getPropAsInt(MIN_TARGET_PARTITION_SIZE, DEFAULT_MIN_TARGET_PARTITION_SIZE);
final Histogram outputHistogram = new Histogram();
final double probeTargetRatio = state.getPropAsDouble(PROBE_TARGET_RATIO, DEFAULT_PROBE_TARGET_RATIO);
final int bucketSizeLimit =
(int) (probeTargetRatio * computeTargetPartitionSize(histogram, minTargetPartitionSize, maxPartitions));
log.info("Refining histogram with bucket size limit {}.", bucketSizeLimit);
HistogramGroup currentGroup;
HistogramGroup nextGroup;
final TableCountProbingContext probingContext =
new TableCountProbingContext(connector, entity, watermarkColumn, bucketSizeLimit, probeLimit);
if (histogram.getGroups().isEmpty()) {
return outputHistogram;
}
// make a copy of the histogram list and add a dummy entry at the end to avoid special processing of the last group
List<HistogramGroup> list = new ArrayList(histogram.getGroups());
Date hwmDate = Utils.toDate(partition.getHighWatermark(), Partitioner.WATERMARKTIMEFORMAT);
list.add(new HistogramGroup(Utils.epochToDate(hwmDate.getTime(), SECONDS_FORMAT), 0));
for (int i = 0; i < list.size() - 1; i++) {
currentGroup = list.get(i);
nextGroup = list.get(i + 1);
// split the group if it is larger than the bucket size limit
if (currentGroup.count > bucketSizeLimit) {
long startEpoch = Utils.toDate(currentGroup.getKey(), SECONDS_FORMAT).getTime();
long endEpoch = Utils.toDate(nextGroup.getKey(), SECONDS_FORMAT).getTime();
outputHistogram.add(getHistogramByProbing(probingContext, currentGroup.count, startEpoch, endEpoch));
} else {
outputHistogram.add(currentGroup);
}
}
log.info("Executed {} probes for refining the histogram.", probingContext.probeCount);
// if the probe limit has been reached then print a warning
if (probingContext.probeCount >= probingContext.probeLimit) {
log.warn("Reached the probe limit");
}
return outputHistogram;
} | [
"private",
"Histogram",
"getRefinedHistogram",
"(",
"SalesforceConnector",
"connector",
",",
"String",
"entity",
",",
"String",
"watermarkColumn",
",",
"SourceState",
"state",
",",
"Partition",
"partition",
",",
"Histogram",
"histogram",
")",
"{",
"final",
"int",
"maxPartitions",
"=",
"state",
".",
"getPropAsInt",
"(",
"ConfigurationKeys",
".",
"SOURCE_MAX_NUMBER_OF_PARTITIONS",
",",
"ConfigurationKeys",
".",
"DEFAULT_MAX_NUMBER_OF_PARTITIONS",
")",
";",
"final",
"int",
"probeLimit",
"=",
"state",
".",
"getPropAsInt",
"(",
"DYNAMIC_PROBING_LIMIT",
",",
"DEFAULT_DYNAMIC_PROBING_LIMIT",
")",
";",
"final",
"int",
"minTargetPartitionSize",
"=",
"state",
".",
"getPropAsInt",
"(",
"MIN_TARGET_PARTITION_SIZE",
",",
"DEFAULT_MIN_TARGET_PARTITION_SIZE",
")",
";",
"final",
"Histogram",
"outputHistogram",
"=",
"new",
"Histogram",
"(",
")",
";",
"final",
"double",
"probeTargetRatio",
"=",
"state",
".",
"getPropAsDouble",
"(",
"PROBE_TARGET_RATIO",
",",
"DEFAULT_PROBE_TARGET_RATIO",
")",
";",
"final",
"int",
"bucketSizeLimit",
"=",
"(",
"int",
")",
"(",
"probeTargetRatio",
"*",
"computeTargetPartitionSize",
"(",
"histogram",
",",
"minTargetPartitionSize",
",",
"maxPartitions",
")",
")",
";",
"log",
".",
"info",
"(",
"\"Refining histogram with bucket size limit {}.\"",
",",
"bucketSizeLimit",
")",
";",
"HistogramGroup",
"currentGroup",
";",
"HistogramGroup",
"nextGroup",
";",
"final",
"TableCountProbingContext",
"probingContext",
"=",
"new",
"TableCountProbingContext",
"(",
"connector",
",",
"entity",
",",
"watermarkColumn",
",",
"bucketSizeLimit",
",",
"probeLimit",
")",
";",
"if",
"(",
"histogram",
".",
"getGroups",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"outputHistogram",
";",
"}",
"// make a copy of the histogram list and add a dummy entry at the end to avoid special processing of the last group",
"List",
"<",
"HistogramGroup",
">",
"list",
"=",
"new",
"ArrayList",
"(",
"histogram",
".",
"getGroups",
"(",
")",
")",
";",
"Date",
"hwmDate",
"=",
"Utils",
".",
"toDate",
"(",
"partition",
".",
"getHighWatermark",
"(",
")",
",",
"Partitioner",
".",
"WATERMARKTIMEFORMAT",
")",
";",
"list",
".",
"add",
"(",
"new",
"HistogramGroup",
"(",
"Utils",
".",
"epochToDate",
"(",
"hwmDate",
".",
"getTime",
"(",
")",
",",
"SECONDS_FORMAT",
")",
",",
"0",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"list",
".",
"size",
"(",
")",
"-",
"1",
";",
"i",
"++",
")",
"{",
"currentGroup",
"=",
"list",
".",
"get",
"(",
"i",
")",
";",
"nextGroup",
"=",
"list",
".",
"get",
"(",
"i",
"+",
"1",
")",
";",
"// split the group if it is larger than the bucket size limit",
"if",
"(",
"currentGroup",
".",
"count",
">",
"bucketSizeLimit",
")",
"{",
"long",
"startEpoch",
"=",
"Utils",
".",
"toDate",
"(",
"currentGroup",
".",
"getKey",
"(",
")",
",",
"SECONDS_FORMAT",
")",
".",
"getTime",
"(",
")",
";",
"long",
"endEpoch",
"=",
"Utils",
".",
"toDate",
"(",
"nextGroup",
".",
"getKey",
"(",
")",
",",
"SECONDS_FORMAT",
")",
".",
"getTime",
"(",
")",
";",
"outputHistogram",
".",
"add",
"(",
"getHistogramByProbing",
"(",
"probingContext",
",",
"currentGroup",
".",
"count",
",",
"startEpoch",
",",
"endEpoch",
")",
")",
";",
"}",
"else",
"{",
"outputHistogram",
".",
"add",
"(",
"currentGroup",
")",
";",
"}",
"}",
"log",
".",
"info",
"(",
"\"Executed {} probes for refining the histogram.\"",
",",
"probingContext",
".",
"probeCount",
")",
";",
"// if the probe limit has been reached then print a warning",
"if",
"(",
"probingContext",
".",
"probeCount",
">=",
"probingContext",
".",
"probeLimit",
")",
"{",
"log",
".",
"warn",
"(",
"\"Reached the probe limit\"",
")",
";",
"}",
"return",
"outputHistogram",
";",
"}"
] | Refine the histogram by probing to split large buckets
@return the refined histogram | [
"Refine",
"the",
"histogram",
"by",
"probing",
"to",
"split",
"large",
"buckets"
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-salesforce/src/main/java/org/apache/gobblin/salesforce/SalesforceSource.java#L388-L438 |
25,853 | apache/incubator-gobblin | gobblin-salesforce/src/main/java/org/apache/gobblin/salesforce/SalesforceSource.java | SalesforceSource.getHistogramByDayBucketing | private Histogram getHistogramByDayBucketing(SalesforceConnector connector, String entity, String watermarkColumn,
Partition partition) {
Histogram histogram = new Histogram();
Calendar calendar = new GregorianCalendar();
Date startDate = Utils.toDate(partition.getLowWatermark(), Partitioner.WATERMARKTIMEFORMAT);
calendar.setTime(startDate);
int startYear = calendar.get(Calendar.YEAR);
String lowWatermarkDate = Utils.dateToString(startDate, SalesforceExtractor.SALESFORCE_TIMESTAMP_FORMAT);
Date endDate = Utils.toDate(partition.getHighWatermark(), Partitioner.WATERMARKTIMEFORMAT);
calendar.setTime(endDate);
int endYear = calendar.get(Calendar.YEAR);
String highWatermarkDate = Utils.dateToString(endDate, SalesforceExtractor.SALESFORCE_TIMESTAMP_FORMAT);
Map<String, String> values = new HashMap<>();
values.put("table", entity);
values.put("column", watermarkColumn);
StrSubstitutor sub = new StrSubstitutor(values);
for (int year = startYear; year <= endYear; year++) {
if (year == startYear) {
values.put("start", lowWatermarkDate);
values.put("greater", partition.isLowWatermarkInclusive() ? ">=" : ">");
} else {
values.put("start", getDateString(year));
values.put("greater", ">=");
}
if (year == endYear) {
values.put("end", highWatermarkDate);
values.put("less", partition.isHighWatermarkInclusive() ? "<=" : "<");
} else {
values.put("end", getDateString(year + 1));
values.put("less", "<");
}
String query = sub.replace(DAY_PARTITION_QUERY_TEMPLATE);
log.info("Histogram query: " + query);
histogram.add(parseDayBucketingHistogram(getRecordsForQuery(connector, query)));
}
return histogram;
} | java | private Histogram getHistogramByDayBucketing(SalesforceConnector connector, String entity, String watermarkColumn,
Partition partition) {
Histogram histogram = new Histogram();
Calendar calendar = new GregorianCalendar();
Date startDate = Utils.toDate(partition.getLowWatermark(), Partitioner.WATERMARKTIMEFORMAT);
calendar.setTime(startDate);
int startYear = calendar.get(Calendar.YEAR);
String lowWatermarkDate = Utils.dateToString(startDate, SalesforceExtractor.SALESFORCE_TIMESTAMP_FORMAT);
Date endDate = Utils.toDate(partition.getHighWatermark(), Partitioner.WATERMARKTIMEFORMAT);
calendar.setTime(endDate);
int endYear = calendar.get(Calendar.YEAR);
String highWatermarkDate = Utils.dateToString(endDate, SalesforceExtractor.SALESFORCE_TIMESTAMP_FORMAT);
Map<String, String> values = new HashMap<>();
values.put("table", entity);
values.put("column", watermarkColumn);
StrSubstitutor sub = new StrSubstitutor(values);
for (int year = startYear; year <= endYear; year++) {
if (year == startYear) {
values.put("start", lowWatermarkDate);
values.put("greater", partition.isLowWatermarkInclusive() ? ">=" : ">");
} else {
values.put("start", getDateString(year));
values.put("greater", ">=");
}
if (year == endYear) {
values.put("end", highWatermarkDate);
values.put("less", partition.isHighWatermarkInclusive() ? "<=" : "<");
} else {
values.put("end", getDateString(year + 1));
values.put("less", "<");
}
String query = sub.replace(DAY_PARTITION_QUERY_TEMPLATE);
log.info("Histogram query: " + query);
histogram.add(parseDayBucketingHistogram(getRecordsForQuery(connector, query)));
}
return histogram;
} | [
"private",
"Histogram",
"getHistogramByDayBucketing",
"(",
"SalesforceConnector",
"connector",
",",
"String",
"entity",
",",
"String",
"watermarkColumn",
",",
"Partition",
"partition",
")",
"{",
"Histogram",
"histogram",
"=",
"new",
"Histogram",
"(",
")",
";",
"Calendar",
"calendar",
"=",
"new",
"GregorianCalendar",
"(",
")",
";",
"Date",
"startDate",
"=",
"Utils",
".",
"toDate",
"(",
"partition",
".",
"getLowWatermark",
"(",
")",
",",
"Partitioner",
".",
"WATERMARKTIMEFORMAT",
")",
";",
"calendar",
".",
"setTime",
"(",
"startDate",
")",
";",
"int",
"startYear",
"=",
"calendar",
".",
"get",
"(",
"Calendar",
".",
"YEAR",
")",
";",
"String",
"lowWatermarkDate",
"=",
"Utils",
".",
"dateToString",
"(",
"startDate",
",",
"SalesforceExtractor",
".",
"SALESFORCE_TIMESTAMP_FORMAT",
")",
";",
"Date",
"endDate",
"=",
"Utils",
".",
"toDate",
"(",
"partition",
".",
"getHighWatermark",
"(",
")",
",",
"Partitioner",
".",
"WATERMARKTIMEFORMAT",
")",
";",
"calendar",
".",
"setTime",
"(",
"endDate",
")",
";",
"int",
"endYear",
"=",
"calendar",
".",
"get",
"(",
"Calendar",
".",
"YEAR",
")",
";",
"String",
"highWatermarkDate",
"=",
"Utils",
".",
"dateToString",
"(",
"endDate",
",",
"SalesforceExtractor",
".",
"SALESFORCE_TIMESTAMP_FORMAT",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"values",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"values",
".",
"put",
"(",
"\"table\"",
",",
"entity",
")",
";",
"values",
".",
"put",
"(",
"\"column\"",
",",
"watermarkColumn",
")",
";",
"StrSubstitutor",
"sub",
"=",
"new",
"StrSubstitutor",
"(",
"values",
")",
";",
"for",
"(",
"int",
"year",
"=",
"startYear",
";",
"year",
"<=",
"endYear",
";",
"year",
"++",
")",
"{",
"if",
"(",
"year",
"==",
"startYear",
")",
"{",
"values",
".",
"put",
"(",
"\"start\"",
",",
"lowWatermarkDate",
")",
";",
"values",
".",
"put",
"(",
"\"greater\"",
",",
"partition",
".",
"isLowWatermarkInclusive",
"(",
")",
"?",
"\">=\"",
":",
"\">\"",
")",
";",
"}",
"else",
"{",
"values",
".",
"put",
"(",
"\"start\"",
",",
"getDateString",
"(",
"year",
")",
")",
";",
"values",
".",
"put",
"(",
"\"greater\"",
",",
"\">=\"",
")",
";",
"}",
"if",
"(",
"year",
"==",
"endYear",
")",
"{",
"values",
".",
"put",
"(",
"\"end\"",
",",
"highWatermarkDate",
")",
";",
"values",
".",
"put",
"(",
"\"less\"",
",",
"partition",
".",
"isHighWatermarkInclusive",
"(",
")",
"?",
"\"<=\"",
":",
"\"<\"",
")",
";",
"}",
"else",
"{",
"values",
".",
"put",
"(",
"\"end\"",
",",
"getDateString",
"(",
"year",
"+",
"1",
")",
")",
";",
"values",
".",
"put",
"(",
"\"less\"",
",",
"\"<\"",
")",
";",
"}",
"String",
"query",
"=",
"sub",
".",
"replace",
"(",
"DAY_PARTITION_QUERY_TEMPLATE",
")",
";",
"log",
".",
"info",
"(",
"\"Histogram query: \"",
"+",
"query",
")",
";",
"histogram",
".",
"add",
"(",
"parseDayBucketingHistogram",
"(",
"getRecordsForQuery",
"(",
"connector",
",",
"query",
")",
")",
")",
";",
"}",
"return",
"histogram",
";",
"}"
] | Get a histogram with day granularity buckets. | [
"Get",
"a",
"histogram",
"with",
"day",
"granularity",
"buckets",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-salesforce/src/main/java/org/apache/gobblin/salesforce/SalesforceSource.java#L443-L487 |
25,854 | apache/incubator-gobblin | gobblin-salesforce/src/main/java/org/apache/gobblin/salesforce/SalesforceSource.java | SalesforceSource.getHistogram | private Histogram getHistogram(String entity, String watermarkColumn, SourceState state,
Partition partition) {
SalesforceConnector connector = getConnector(state);
try {
if (!connector.connect()) {
throw new RuntimeException("Failed to connect.");
}
} catch (RestApiConnectionException e) {
throw new RuntimeException("Failed to connect.", e);
}
Histogram histogram = getHistogramByDayBucketing(connector, entity, watermarkColumn, partition);
// exchange the first histogram group key with the global low watermark to ensure that the low watermark is captured
// in the range of generated partitions
HistogramGroup firstGroup = histogram.get(0);
Date lwmDate = Utils.toDate(partition.getLowWatermark(), Partitioner.WATERMARKTIMEFORMAT);
histogram.getGroups().set(0, new HistogramGroup(Utils.epochToDate(lwmDate.getTime(), SECONDS_FORMAT),
firstGroup.getCount()));
// refine the histogram
if (state.getPropAsBoolean(ENABLE_DYNAMIC_PROBING)) {
histogram = getRefinedHistogram(connector, entity, watermarkColumn, state, partition, histogram);
}
return histogram;
} | java | private Histogram getHistogram(String entity, String watermarkColumn, SourceState state,
Partition partition) {
SalesforceConnector connector = getConnector(state);
try {
if (!connector.connect()) {
throw new RuntimeException("Failed to connect.");
}
} catch (RestApiConnectionException e) {
throw new RuntimeException("Failed to connect.", e);
}
Histogram histogram = getHistogramByDayBucketing(connector, entity, watermarkColumn, partition);
// exchange the first histogram group key with the global low watermark to ensure that the low watermark is captured
// in the range of generated partitions
HistogramGroup firstGroup = histogram.get(0);
Date lwmDate = Utils.toDate(partition.getLowWatermark(), Partitioner.WATERMARKTIMEFORMAT);
histogram.getGroups().set(0, new HistogramGroup(Utils.epochToDate(lwmDate.getTime(), SECONDS_FORMAT),
firstGroup.getCount()));
// refine the histogram
if (state.getPropAsBoolean(ENABLE_DYNAMIC_PROBING)) {
histogram = getRefinedHistogram(connector, entity, watermarkColumn, state, partition, histogram);
}
return histogram;
} | [
"private",
"Histogram",
"getHistogram",
"(",
"String",
"entity",
",",
"String",
"watermarkColumn",
",",
"SourceState",
"state",
",",
"Partition",
"partition",
")",
"{",
"SalesforceConnector",
"connector",
"=",
"getConnector",
"(",
"state",
")",
";",
"try",
"{",
"if",
"(",
"!",
"connector",
".",
"connect",
"(",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Failed to connect.\"",
")",
";",
"}",
"}",
"catch",
"(",
"RestApiConnectionException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Failed to connect.\"",
",",
"e",
")",
";",
"}",
"Histogram",
"histogram",
"=",
"getHistogramByDayBucketing",
"(",
"connector",
",",
"entity",
",",
"watermarkColumn",
",",
"partition",
")",
";",
"// exchange the first histogram group key with the global low watermark to ensure that the low watermark is captured",
"// in the range of generated partitions",
"HistogramGroup",
"firstGroup",
"=",
"histogram",
".",
"get",
"(",
"0",
")",
";",
"Date",
"lwmDate",
"=",
"Utils",
".",
"toDate",
"(",
"partition",
".",
"getLowWatermark",
"(",
")",
",",
"Partitioner",
".",
"WATERMARKTIMEFORMAT",
")",
";",
"histogram",
".",
"getGroups",
"(",
")",
".",
"set",
"(",
"0",
",",
"new",
"HistogramGroup",
"(",
"Utils",
".",
"epochToDate",
"(",
"lwmDate",
".",
"getTime",
"(",
")",
",",
"SECONDS_FORMAT",
")",
",",
"firstGroup",
".",
"getCount",
"(",
")",
")",
")",
";",
"// refine the histogram",
"if",
"(",
"state",
".",
"getPropAsBoolean",
"(",
"ENABLE_DYNAMIC_PROBING",
")",
")",
"{",
"histogram",
"=",
"getRefinedHistogram",
"(",
"connector",
",",
"entity",
",",
"watermarkColumn",
",",
"state",
",",
"partition",
",",
"histogram",
")",
";",
"}",
"return",
"histogram",
";",
"}"
] | Generate the histogram | [
"Generate",
"the",
"histogram"
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-salesforce/src/main/java/org/apache/gobblin/salesforce/SalesforceSource.java#L499-L526 |
25,855 | apache/incubator-gobblin | gobblin-core/src/main/java/org/apache/gobblin/writer/RetryWriter.java | RetryWriter.buildRetryer | private Retryer<Void> buildRetryer(State state) {
RetryerBuilder<Void> builder = null;
if (writer instanceof Retriable) {
builder = ((Retriable) writer).getRetryerBuilder();
} else {
builder = createRetryBuilder(state);
}
if (GobblinMetrics.isEnabled(state)) {
final Optional<Meter> retryMeter = Optional.of(Instrumented.getMetricContext(state, getClass()).meter(FAILED_RETRY_WRITES_METER));
builder.withRetryListener(new RetryListener() {
@Override
public <V> void onRetry(Attempt<V> attempt) {
if (attempt.hasException()) {
LOG.warn("Caught exception. This may be retried.", attempt.getExceptionCause());
Instrumented.markMeter(retryMeter);
failedWrites++;
}
}
});
}
return builder.build();
} | java | private Retryer<Void> buildRetryer(State state) {
RetryerBuilder<Void> builder = null;
if (writer instanceof Retriable) {
builder = ((Retriable) writer).getRetryerBuilder();
} else {
builder = createRetryBuilder(state);
}
if (GobblinMetrics.isEnabled(state)) {
final Optional<Meter> retryMeter = Optional.of(Instrumented.getMetricContext(state, getClass()).meter(FAILED_RETRY_WRITES_METER));
builder.withRetryListener(new RetryListener() {
@Override
public <V> void onRetry(Attempt<V> attempt) {
if (attempt.hasException()) {
LOG.warn("Caught exception. This may be retried.", attempt.getExceptionCause());
Instrumented.markMeter(retryMeter);
failedWrites++;
}
}
});
}
return builder.build();
} | [
"private",
"Retryer",
"<",
"Void",
">",
"buildRetryer",
"(",
"State",
"state",
")",
"{",
"RetryerBuilder",
"<",
"Void",
">",
"builder",
"=",
"null",
";",
"if",
"(",
"writer",
"instanceof",
"Retriable",
")",
"{",
"builder",
"=",
"(",
"(",
"Retriable",
")",
"writer",
")",
".",
"getRetryerBuilder",
"(",
")",
";",
"}",
"else",
"{",
"builder",
"=",
"createRetryBuilder",
"(",
"state",
")",
";",
"}",
"if",
"(",
"GobblinMetrics",
".",
"isEnabled",
"(",
"state",
")",
")",
"{",
"final",
"Optional",
"<",
"Meter",
">",
"retryMeter",
"=",
"Optional",
".",
"of",
"(",
"Instrumented",
".",
"getMetricContext",
"(",
"state",
",",
"getClass",
"(",
")",
")",
".",
"meter",
"(",
"FAILED_RETRY_WRITES_METER",
")",
")",
";",
"builder",
".",
"withRetryListener",
"(",
"new",
"RetryListener",
"(",
")",
"{",
"@",
"Override",
"public",
"<",
"V",
">",
"void",
"onRetry",
"(",
"Attempt",
"<",
"V",
">",
"attempt",
")",
"{",
"if",
"(",
"attempt",
".",
"hasException",
"(",
")",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Caught exception. This may be retried.\"",
",",
"attempt",
".",
"getExceptionCause",
"(",
")",
")",
";",
"Instrumented",
".",
"markMeter",
"(",
"retryMeter",
")",
";",
"failedWrites",
"++",
";",
"}",
"}",
"}",
")",
";",
"}",
"return",
"builder",
".",
"build",
"(",
")",
";",
"}"
] | Build Retryer.
- If Writer implements Retriable, it will use the RetryerBuilder from the writer.
- Otherwise, it will use DEFAULT writer builder.
- If Gobblin metrics is enabled, it will emit all failure count in to metrics.
@param state
@return | [
"Build",
"Retryer",
".",
"-",
"If",
"Writer",
"implements",
"Retriable",
"it",
"will",
"use",
"the",
"RetryerBuilder",
"from",
"the",
"writer",
".",
"-",
"Otherwise",
"it",
"will",
"use",
"DEFAULT",
"writer",
"builder",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-core/src/main/java/org/apache/gobblin/writer/RetryWriter.java#L83-L106 |
25,856 | apache/incubator-gobblin | gobblin-data-management/src/main/java/org/apache/gobblin/data/management/copy/hive/HiveUtils.java | HiveUtils.getPartitions | public static List<Partition> getPartitions(IMetaStoreClient client, Table table, Optional<String> filter)
throws IOException {
return getPartitions(client, table, filter, Optional.<HivePartitionExtendedFilter>absent());
} | java | public static List<Partition> getPartitions(IMetaStoreClient client, Table table, Optional<String> filter)
throws IOException {
return getPartitions(client, table, filter, Optional.<HivePartitionExtendedFilter>absent());
} | [
"public",
"static",
"List",
"<",
"Partition",
">",
"getPartitions",
"(",
"IMetaStoreClient",
"client",
",",
"Table",
"table",
",",
"Optional",
"<",
"String",
">",
"filter",
")",
"throws",
"IOException",
"{",
"return",
"getPartitions",
"(",
"client",
",",
"table",
",",
"filter",
",",
"Optional",
".",
"<",
"HivePartitionExtendedFilter",
">",
"absent",
"(",
")",
")",
";",
"}"
] | For backward compatibility when PathFilter is injected as a parameter.
@param client
@param table
@param filter
@return
@throws IOException | [
"For",
"backward",
"compatibility",
"when",
"PathFilter",
"is",
"injected",
"as",
"a",
"parameter",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-data-management/src/main/java/org/apache/gobblin/data/management/copy/hive/HiveUtils.java#L116-L119 |
25,857 | apache/incubator-gobblin | gobblin-data-management/src/main/java/org/apache/gobblin/data/management/copy/hive/HiveUtils.java | HiveUtils.getPaths | public static Set<Path> getPaths(InputFormat<?, ?> inputFormat, Path location) throws IOException {
JobConf jobConf = new JobConf(getHadoopConfiguration());
Set<Path> paths = Sets.newHashSet();
FileInputFormat.addInputPaths(jobConf, location.toString());
InputSplit[] splits = inputFormat.getSplits(jobConf, 1000);
for (InputSplit split : splits) {
if (!(split instanceof FileSplit)) {
throw new IOException("Not a file split. Found " + split.getClass().getName());
}
FileSplit fileSplit = (FileSplit) split;
paths.add(fileSplit.getPath());
}
return paths;
} | java | public static Set<Path> getPaths(InputFormat<?, ?> inputFormat, Path location) throws IOException {
JobConf jobConf = new JobConf(getHadoopConfiguration());
Set<Path> paths = Sets.newHashSet();
FileInputFormat.addInputPaths(jobConf, location.toString());
InputSplit[] splits = inputFormat.getSplits(jobConf, 1000);
for (InputSplit split : splits) {
if (!(split instanceof FileSplit)) {
throw new IOException("Not a file split. Found " + split.getClass().getName());
}
FileSplit fileSplit = (FileSplit) split;
paths.add(fileSplit.getPath());
}
return paths;
} | [
"public",
"static",
"Set",
"<",
"Path",
">",
"getPaths",
"(",
"InputFormat",
"<",
"?",
",",
"?",
">",
"inputFormat",
",",
"Path",
"location",
")",
"throws",
"IOException",
"{",
"JobConf",
"jobConf",
"=",
"new",
"JobConf",
"(",
"getHadoopConfiguration",
"(",
")",
")",
";",
"Set",
"<",
"Path",
">",
"paths",
"=",
"Sets",
".",
"newHashSet",
"(",
")",
";",
"FileInputFormat",
".",
"addInputPaths",
"(",
"jobConf",
",",
"location",
".",
"toString",
"(",
")",
")",
";",
"InputSplit",
"[",
"]",
"splits",
"=",
"inputFormat",
".",
"getSplits",
"(",
"jobConf",
",",
"1000",
")",
";",
"for",
"(",
"InputSplit",
"split",
":",
"splits",
")",
"{",
"if",
"(",
"!",
"(",
"split",
"instanceof",
"FileSplit",
")",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Not a file split. Found \"",
"+",
"split",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"}",
"FileSplit",
"fileSplit",
"=",
"(",
"FileSplit",
")",
"split",
";",
"paths",
".",
"add",
"(",
"fileSplit",
".",
"getPath",
"(",
")",
")",
";",
"}",
"return",
"paths",
";",
"}"
] | Get paths from a Hive location using the provided input format. | [
"Get",
"paths",
"from",
"a",
"Hive",
"location",
"using",
"the",
"provided",
"input",
"format",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-data-management/src/main/java/org/apache/gobblin/data/management/copy/hive/HiveUtils.java#L140-L156 |
25,858 | apache/incubator-gobblin | gobblin-utility/src/main/java/org/apache/gobblin/util/ForkOperatorUtils.java | ForkOperatorUtils.getPathForBranch | public static String getPathForBranch(State state, String path, int numBranches, int branchId) {
Preconditions.checkNotNull(state);
Preconditions.checkNotNull(path);
Preconditions.checkArgument(numBranches >= 0, "The number of branches is expected to be non-negative");
Preconditions.checkArgument(branchId >= 0, "The branch id is expected to be non-negative");
return numBranches > 1
? path + Path.SEPARATOR + state.getProp(ConfigurationKeys.FORK_BRANCH_NAME_KEY + "." + branchId,
ConfigurationKeys.DEFAULT_FORK_BRANCH_NAME + branchId)
: path;
} | java | public static String getPathForBranch(State state, String path, int numBranches, int branchId) {
Preconditions.checkNotNull(state);
Preconditions.checkNotNull(path);
Preconditions.checkArgument(numBranches >= 0, "The number of branches is expected to be non-negative");
Preconditions.checkArgument(branchId >= 0, "The branch id is expected to be non-negative");
return numBranches > 1
? path + Path.SEPARATOR + state.getProp(ConfigurationKeys.FORK_BRANCH_NAME_KEY + "." + branchId,
ConfigurationKeys.DEFAULT_FORK_BRANCH_NAME + branchId)
: path;
} | [
"public",
"static",
"String",
"getPathForBranch",
"(",
"State",
"state",
",",
"String",
"path",
",",
"int",
"numBranches",
",",
"int",
"branchId",
")",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"state",
")",
";",
"Preconditions",
".",
"checkNotNull",
"(",
"path",
")",
";",
"Preconditions",
".",
"checkArgument",
"(",
"numBranches",
">=",
"0",
",",
"\"The number of branches is expected to be non-negative\"",
")",
";",
"Preconditions",
".",
"checkArgument",
"(",
"branchId",
">=",
"0",
",",
"\"The branch id is expected to be non-negative\"",
")",
";",
"return",
"numBranches",
">",
"1",
"?",
"path",
"+",
"Path",
".",
"SEPARATOR",
"+",
"state",
".",
"getProp",
"(",
"ConfigurationKeys",
".",
"FORK_BRANCH_NAME_KEY",
"+",
"\".\"",
"+",
"branchId",
",",
"ConfigurationKeys",
".",
"DEFAULT_FORK_BRANCH_NAME",
"+",
"branchId",
")",
":",
"path",
";",
"}"
] | Get a new path with the given branch name as a sub directory.
@param numBranches number of branches (non-negative)
@param branchId branch id (non-negative)
@return a new path | [
"Get",
"a",
"new",
"path",
"with",
"the",
"given",
"branch",
"name",
"as",
"a",
"sub",
"directory",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-utility/src/main/java/org/apache/gobblin/util/ForkOperatorUtils.java#L92-L102 |
25,859 | apache/incubator-gobblin | gobblin-data-management/src/main/java/org/apache/gobblin/data/management/conversion/hive/source/HiveSource.java | HiveSource.getCreateTime | protected static long getCreateTime(Table table) {
return TimeUnit.MILLISECONDS.convert(table.getTTable().getCreateTime(), TimeUnit.SECONDS);
} | java | protected static long getCreateTime(Table table) {
return TimeUnit.MILLISECONDS.convert(table.getTTable().getCreateTime(), TimeUnit.SECONDS);
} | [
"protected",
"static",
"long",
"getCreateTime",
"(",
"Table",
"table",
")",
"{",
"return",
"TimeUnit",
".",
"MILLISECONDS",
".",
"convert",
"(",
"table",
".",
"getTTable",
"(",
")",
".",
"getCreateTime",
"(",
")",
",",
"TimeUnit",
".",
"SECONDS",
")",
";",
"}"
] | Convert createTime from seconds to milliseconds | [
"Convert",
"createTime",
"from",
"seconds",
"to",
"milliseconds"
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-data-management/src/main/java/org/apache/gobblin/data/management/conversion/hive/source/HiveSource.java#L435-L437 |
25,860 | apache/incubator-gobblin | gobblin-data-management/src/main/java/org/apache/gobblin/data/management/conversion/hive/source/HiveSource.java | HiveSource.silenceHiveLoggers | private void silenceHiveLoggers() {
List<String> loggers = ImmutableList.of("org.apache.hadoop.hive", "org.apache.hive", "hive.ql.parse");
for (String name : loggers) {
Logger logger = Logger.getLogger(name);
if (logger != null) {
logger.setLevel(Level.WARN);
}
}
} | java | private void silenceHiveLoggers() {
List<String> loggers = ImmutableList.of("org.apache.hadoop.hive", "org.apache.hive", "hive.ql.parse");
for (String name : loggers) {
Logger logger = Logger.getLogger(name);
if (logger != null) {
logger.setLevel(Level.WARN);
}
}
} | [
"private",
"void",
"silenceHiveLoggers",
"(",
")",
"{",
"List",
"<",
"String",
">",
"loggers",
"=",
"ImmutableList",
".",
"of",
"(",
"\"org.apache.hadoop.hive\"",
",",
"\"org.apache.hive\"",
",",
"\"hive.ql.parse\"",
")",
";",
"for",
"(",
"String",
"name",
":",
"loggers",
")",
"{",
"Logger",
"logger",
"=",
"Logger",
".",
"getLogger",
"(",
"name",
")",
";",
"if",
"(",
"logger",
"!=",
"null",
")",
"{",
"logger",
".",
"setLevel",
"(",
"Level",
".",
"WARN",
")",
";",
"}",
"}",
"}"
] | Hive logging is too verbose at INFO level. Currently hive does not have a way to set log level.
This is a workaround to set log level to WARN for hive loggers only | [
"Hive",
"logging",
"is",
"too",
"verbose",
"at",
"INFO",
"level",
".",
"Currently",
"hive",
"does",
"not",
"have",
"a",
"way",
"to",
"set",
"log",
"level",
".",
"This",
"is",
"a",
"workaround",
"to",
"set",
"log",
"level",
"to",
"WARN",
"for",
"hive",
"loggers",
"only"
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-data-management/src/main/java/org/apache/gobblin/data/management/conversion/hive/source/HiveSource.java#L464-L472 |
25,861 | apache/incubator-gobblin | gobblin-runtime/src/main/java/org/apache/gobblin/runtime/SafeDatasetCommit.java | SafeDatasetCommit.commitDataset | private void commitDataset(Collection<TaskState> taskStates, DataPublisher publisher) {
try {
publisher.publish(taskStates);
} catch (Throwable t) {
log.error("Failed to commit dataset", t);
setTaskFailureException(taskStates, t);
}
} | java | private void commitDataset(Collection<TaskState> taskStates, DataPublisher publisher) {
try {
publisher.publish(taskStates);
} catch (Throwable t) {
log.error("Failed to commit dataset", t);
setTaskFailureException(taskStates, t);
}
} | [
"private",
"void",
"commitDataset",
"(",
"Collection",
"<",
"TaskState",
">",
"taskStates",
",",
"DataPublisher",
"publisher",
")",
"{",
"try",
"{",
"publisher",
".",
"publish",
"(",
"taskStates",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"log",
".",
"error",
"(",
"\"Failed to commit dataset\"",
",",
"t",
")",
";",
"setTaskFailureException",
"(",
"taskStates",
",",
"t",
")",
";",
"}",
"}"
] | Commit the output data of a dataset. | [
"Commit",
"the",
"output",
"data",
"of",
"a",
"dataset",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-runtime/src/main/java/org/apache/gobblin/runtime/SafeDatasetCommit.java#L264-L272 |
25,862 | apache/incubator-gobblin | gobblin-runtime/src/main/java/org/apache/gobblin/runtime/SafeDatasetCommit.java | SafeDatasetCommit.canCommitDataset | private boolean canCommitDataset(JobState.DatasetState datasetState) {
// Only commit a dataset if 1) COMMIT_ON_PARTIAL_SUCCESS is used, or 2)
// COMMIT_ON_FULL_SUCCESS is used and all of the tasks of the dataset have succeeded.
return this.jobContext.getJobCommitPolicy() == JobCommitPolicy.COMMIT_ON_PARTIAL_SUCCESS
|| this.jobContext.getJobCommitPolicy() == JobCommitPolicy.COMMIT_SUCCESSFUL_TASKS || (
this.jobContext.getJobCommitPolicy() == JobCommitPolicy.COMMIT_ON_FULL_SUCCESS
&& datasetState.getState() == JobState.RunningState.SUCCESSFUL);
} | java | private boolean canCommitDataset(JobState.DatasetState datasetState) {
// Only commit a dataset if 1) COMMIT_ON_PARTIAL_SUCCESS is used, or 2)
// COMMIT_ON_FULL_SUCCESS is used and all of the tasks of the dataset have succeeded.
return this.jobContext.getJobCommitPolicy() == JobCommitPolicy.COMMIT_ON_PARTIAL_SUCCESS
|| this.jobContext.getJobCommitPolicy() == JobCommitPolicy.COMMIT_SUCCESSFUL_TASKS || (
this.jobContext.getJobCommitPolicy() == JobCommitPolicy.COMMIT_ON_FULL_SUCCESS
&& datasetState.getState() == JobState.RunningState.SUCCESSFUL);
} | [
"private",
"boolean",
"canCommitDataset",
"(",
"JobState",
".",
"DatasetState",
"datasetState",
")",
"{",
"// Only commit a dataset if 1) COMMIT_ON_PARTIAL_SUCCESS is used, or 2)",
"// COMMIT_ON_FULL_SUCCESS is used and all of the tasks of the dataset have succeeded.",
"return",
"this",
".",
"jobContext",
".",
"getJobCommitPolicy",
"(",
")",
"==",
"JobCommitPolicy",
".",
"COMMIT_ON_PARTIAL_SUCCESS",
"||",
"this",
".",
"jobContext",
".",
"getJobCommitPolicy",
"(",
")",
"==",
"JobCommitPolicy",
".",
"COMMIT_SUCCESSFUL_TASKS",
"||",
"(",
"this",
".",
"jobContext",
".",
"getJobCommitPolicy",
"(",
")",
"==",
"JobCommitPolicy",
".",
"COMMIT_ON_FULL_SUCCESS",
"&&",
"datasetState",
".",
"getState",
"(",
")",
"==",
"JobState",
".",
"RunningState",
".",
"SUCCESSFUL",
")",
";",
"}"
] | Check if it is OK to commit the output data of a dataset.
<p>
A dataset can be committed if and only if any of the following conditions is satisfied:
<ul>
<li>The {@link JobCommitPolicy#COMMIT_ON_PARTIAL_SUCCESS} policy is used.</li>
<li>The {@link JobCommitPolicy#COMMIT_SUCCESSFUL_TASKS} policy is used.</li>
<li>The {@link JobCommitPolicy#COMMIT_ON_FULL_SUCCESS} policy is used and all of the tasks succeed.</li>
</ul>
</p>
This method is thread-safe. | [
"Check",
"if",
"it",
"is",
"OK",
"to",
"commit",
"the",
"output",
"data",
"of",
"a",
"dataset",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-runtime/src/main/java/org/apache/gobblin/runtime/SafeDatasetCommit.java#L350-L357 |
25,863 | apache/incubator-gobblin | gobblin-runtime/src/main/java/org/apache/gobblin/runtime/SafeDatasetCommit.java | SafeDatasetCommit.persistDatasetState | private void persistDatasetState(String datasetUrn, JobState.DatasetState datasetState)
throws IOException {
log.info("Persisting dataset state for dataset " + datasetUrn);
this.jobContext.getDatasetStateStore().persistDatasetState(datasetUrn, datasetState);
} | java | private void persistDatasetState(String datasetUrn, JobState.DatasetState datasetState)
throws IOException {
log.info("Persisting dataset state for dataset " + datasetUrn);
this.jobContext.getDatasetStateStore().persistDatasetState(datasetUrn, datasetState);
} | [
"private",
"void",
"persistDatasetState",
"(",
"String",
"datasetUrn",
",",
"JobState",
".",
"DatasetState",
"datasetState",
")",
"throws",
"IOException",
"{",
"log",
".",
"info",
"(",
"\"Persisting dataset state for dataset \"",
"+",
"datasetUrn",
")",
";",
"this",
".",
"jobContext",
".",
"getDatasetStateStore",
"(",
")",
".",
"persistDatasetState",
"(",
"datasetUrn",
",",
"datasetState",
")",
";",
"}"
] | Persist dataset state of a given dataset identified by the dataset URN. | [
"Persist",
"dataset",
"state",
"of",
"a",
"given",
"dataset",
"identified",
"by",
"the",
"dataset",
"URN",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-runtime/src/main/java/org/apache/gobblin/runtime/SafeDatasetCommit.java#L415-L419 |
25,864 | apache/incubator-gobblin | gobblin-data-management/src/main/java/org/apache/gobblin/data/management/conversion/hive/avro/AvroSchemaManager.java | AvroSchemaManager.getOrGenerateSchemaFile | private Path getOrGenerateSchemaFile(Schema schema) throws IOException {
Preconditions.checkNotNull(schema, "Avro Schema should not be null");
String hashedSchema = Hashing.sha256().hashString(schema.toString(), StandardCharsets.UTF_8).toString();
if (!this.schemaPaths.containsKey(hashedSchema)) {
Path schemaFilePath = new Path(this.schemaDir, String.valueOf(System.currentTimeMillis() + ".avsc"));
AvroUtils.writeSchemaToFile(schema, schemaFilePath, fs, true);
this.schemaPaths.put(hashedSchema, schemaFilePath);
}
return this.schemaPaths.get(hashedSchema);
} | java | private Path getOrGenerateSchemaFile(Schema schema) throws IOException {
Preconditions.checkNotNull(schema, "Avro Schema should not be null");
String hashedSchema = Hashing.sha256().hashString(schema.toString(), StandardCharsets.UTF_8).toString();
if (!this.schemaPaths.containsKey(hashedSchema)) {
Path schemaFilePath = new Path(this.schemaDir, String.valueOf(System.currentTimeMillis() + ".avsc"));
AvroUtils.writeSchemaToFile(schema, schemaFilePath, fs, true);
this.schemaPaths.put(hashedSchema, schemaFilePath);
}
return this.schemaPaths.get(hashedSchema);
} | [
"private",
"Path",
"getOrGenerateSchemaFile",
"(",
"Schema",
"schema",
")",
"throws",
"IOException",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"schema",
",",
"\"Avro Schema should not be null\"",
")",
";",
"String",
"hashedSchema",
"=",
"Hashing",
".",
"sha256",
"(",
")",
".",
"hashString",
"(",
"schema",
".",
"toString",
"(",
")",
",",
"StandardCharsets",
".",
"UTF_8",
")",
".",
"toString",
"(",
")",
";",
"if",
"(",
"!",
"this",
".",
"schemaPaths",
".",
"containsKey",
"(",
"hashedSchema",
")",
")",
"{",
"Path",
"schemaFilePath",
"=",
"new",
"Path",
"(",
"this",
".",
"schemaDir",
",",
"String",
".",
"valueOf",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
"+",
"\".avsc\"",
")",
")",
";",
"AvroUtils",
".",
"writeSchemaToFile",
"(",
"schema",
",",
"schemaFilePath",
",",
"fs",
",",
"true",
")",
";",
"this",
".",
"schemaPaths",
".",
"put",
"(",
"hashedSchema",
",",
"schemaFilePath",
")",
";",
"}",
"return",
"this",
".",
"schemaPaths",
".",
"get",
"(",
"hashedSchema",
")",
";",
"}"
] | If url for schema already exists, return the url. If not create a new temporary schema file and return a the url. | [
"If",
"url",
"for",
"schema",
"already",
"exists",
"return",
"the",
"url",
".",
"If",
"not",
"create",
"a",
"new",
"temporary",
"schema",
"file",
"and",
"return",
"a",
"the",
"url",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-data-management/src/main/java/org/apache/gobblin/data/management/conversion/hive/avro/AvroSchemaManager.java#L185-L200 |
25,865 | apache/incubator-gobblin | gobblin-api/src/main/java/org/apache/gobblin/compat/hadoop/TextSerializer.java | TextSerializer.writeStringAsText | public static void writeStringAsText(DataOutput stream, String str) throws IOException {
byte[] utf8Encoded = str.getBytes(StandardCharsets.UTF_8);
writeVLong(stream, utf8Encoded.length);
stream.write(utf8Encoded);
} | java | public static void writeStringAsText(DataOutput stream, String str) throws IOException {
byte[] utf8Encoded = str.getBytes(StandardCharsets.UTF_8);
writeVLong(stream, utf8Encoded.length);
stream.write(utf8Encoded);
} | [
"public",
"static",
"void",
"writeStringAsText",
"(",
"DataOutput",
"stream",
",",
"String",
"str",
")",
"throws",
"IOException",
"{",
"byte",
"[",
"]",
"utf8Encoded",
"=",
"str",
".",
"getBytes",
"(",
"StandardCharsets",
".",
"UTF_8",
")",
";",
"writeVLong",
"(",
"stream",
",",
"utf8Encoded",
".",
"length",
")",
";",
"stream",
".",
"write",
"(",
"utf8Encoded",
")",
";",
"}"
] | Serialize a String using the same logic as a Hadoop Text object | [
"Serialize",
"a",
"String",
"using",
"the",
"same",
"logic",
"as",
"a",
"Hadoop",
"Text",
"object"
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-api/src/main/java/org/apache/gobblin/compat/hadoop/TextSerializer.java#L33-L37 |
25,866 | apache/incubator-gobblin | gobblin-api/src/main/java/org/apache/gobblin/compat/hadoop/TextSerializer.java | TextSerializer.readTextAsString | public static String readTextAsString(DataInput in) throws IOException {
int bufLen = (int)readVLong(in);
byte[] buf = new byte[bufLen];
in.readFully(buf);
return new String(buf, StandardCharsets.UTF_8);
} | java | public static String readTextAsString(DataInput in) throws IOException {
int bufLen = (int)readVLong(in);
byte[] buf = new byte[bufLen];
in.readFully(buf);
return new String(buf, StandardCharsets.UTF_8);
} | [
"public",
"static",
"String",
"readTextAsString",
"(",
"DataInput",
"in",
")",
"throws",
"IOException",
"{",
"int",
"bufLen",
"=",
"(",
"int",
")",
"readVLong",
"(",
"in",
")",
";",
"byte",
"[",
"]",
"buf",
"=",
"new",
"byte",
"[",
"bufLen",
"]",
";",
"in",
".",
"readFully",
"(",
"buf",
")",
";",
"return",
"new",
"String",
"(",
"buf",
",",
"StandardCharsets",
".",
"UTF_8",
")",
";",
"}"
] | Deserialize a Hadoop Text object into a String | [
"Deserialize",
"a",
"Hadoop",
"Text",
"object",
"into",
"a",
"String"
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-api/src/main/java/org/apache/gobblin/compat/hadoop/TextSerializer.java#L42-L48 |
25,867 | apache/incubator-gobblin | gobblin-api/src/main/java/org/apache/gobblin/compat/hadoop/TextSerializer.java | TextSerializer.writeVLong | private static void writeVLong(DataOutput stream, long i) throws IOException {
if (i >= -112 && i <= 127) {
stream.writeByte((byte)i);
return;
}
int len = -112;
if (i < 0) {
i ^= -1L; // take one's complement'
len = -120;
}
long tmp = i;
while (tmp != 0) {
tmp = tmp >> 8;
len--;
}
stream.writeByte((byte)len);
len = (len < -120) ? -(len + 120) : -(len + 112);
for (int idx = len; idx != 0; idx--) {
int shiftbits = (idx - 1) * 8;
long mask = 0xFFL << shiftbits;
stream.writeByte((byte)((i & mask) >> shiftbits));
}
} | java | private static void writeVLong(DataOutput stream, long i) throws IOException {
if (i >= -112 && i <= 127) {
stream.writeByte((byte)i);
return;
}
int len = -112;
if (i < 0) {
i ^= -1L; // take one's complement'
len = -120;
}
long tmp = i;
while (tmp != 0) {
tmp = tmp >> 8;
len--;
}
stream.writeByte((byte)len);
len = (len < -120) ? -(len + 120) : -(len + 112);
for (int idx = len; idx != 0; idx--) {
int shiftbits = (idx - 1) * 8;
long mask = 0xFFL << shiftbits;
stream.writeByte((byte)((i & mask) >> shiftbits));
}
} | [
"private",
"static",
"void",
"writeVLong",
"(",
"DataOutput",
"stream",
",",
"long",
"i",
")",
"throws",
"IOException",
"{",
"if",
"(",
"i",
">=",
"-",
"112",
"&&",
"i",
"<=",
"127",
")",
"{",
"stream",
".",
"writeByte",
"(",
"(",
"byte",
")",
"i",
")",
";",
"return",
";",
"}",
"int",
"len",
"=",
"-",
"112",
";",
"if",
"(",
"i",
"<",
"0",
")",
"{",
"i",
"^=",
"-",
"1L",
";",
"// take one's complement'",
"len",
"=",
"-",
"120",
";",
"}",
"long",
"tmp",
"=",
"i",
";",
"while",
"(",
"tmp",
"!=",
"0",
")",
"{",
"tmp",
"=",
"tmp",
">>",
"8",
";",
"len",
"--",
";",
"}",
"stream",
".",
"writeByte",
"(",
"(",
"byte",
")",
"len",
")",
";",
"len",
"=",
"(",
"len",
"<",
"-",
"120",
")",
"?",
"-",
"(",
"len",
"+",
"120",
")",
":",
"-",
"(",
"len",
"+",
"112",
")",
";",
"for",
"(",
"int",
"idx",
"=",
"len",
";",
"idx",
"!=",
"0",
";",
"idx",
"--",
")",
"{",
"int",
"shiftbits",
"=",
"(",
"idx",
"-",
"1",
")",
"*",
"8",
";",
"long",
"mask",
"=",
"0xFF",
"L",
"<<",
"shiftbits",
";",
"stream",
".",
"writeByte",
"(",
"(",
"byte",
")",
"(",
"(",
"i",
"&",
"mask",
")",
">>",
"shiftbits",
")",
")",
";",
"}",
"}"
] | From org.apache.hadoop.io.WritableUtis
Serializes a long to a binary stream with zero-compressed encoding.
For -112 <= i <= 127, only one byte is used with the actual value.
For other values of i, the first byte value indicates whether the
long is positive or negative, and the number of bytes that follow.
If the first byte value v is between -113 and -120, the following long
is positive, with number of bytes that follow are -(v+112).
If the first byte value v is between -121 and -128, the following long
is negative, with number of bytes that follow are -(v+120). Bytes are
stored in the high-non-zero-byte-first order.
@param stream Binary output stream
@param i Long to be serialized
@throws java.io.IOException | [
"From",
"org",
".",
"apache",
".",
"hadoop",
".",
"io",
".",
"WritableUtis"
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-api/src/main/java/org/apache/gobblin/compat/hadoop/TextSerializer.java#L67-L94 |
25,868 | apache/incubator-gobblin | gobblin-api/src/main/java/org/apache/gobblin/compat/hadoop/TextSerializer.java | TextSerializer.readVLong | private static long readVLong(DataInput stream) throws IOException {
byte firstByte = stream.readByte();
int len = decodeVIntSize(firstByte);
if (len == 1) {
return firstByte;
}
long i = 0;
for (int idx = 0; idx < len-1; idx++) {
byte b = stream.readByte();
i = i << 8;
i = i | (b & 0xFF);
}
return (isNegativeVInt(firstByte) ? (i ^ -1L) : i);
} | java | private static long readVLong(DataInput stream) throws IOException {
byte firstByte = stream.readByte();
int len = decodeVIntSize(firstByte);
if (len == 1) {
return firstByte;
}
long i = 0;
for (int idx = 0; idx < len-1; idx++) {
byte b = stream.readByte();
i = i << 8;
i = i | (b & 0xFF);
}
return (isNegativeVInt(firstByte) ? (i ^ -1L) : i);
} | [
"private",
"static",
"long",
"readVLong",
"(",
"DataInput",
"stream",
")",
"throws",
"IOException",
"{",
"byte",
"firstByte",
"=",
"stream",
".",
"readByte",
"(",
")",
";",
"int",
"len",
"=",
"decodeVIntSize",
"(",
"firstByte",
")",
";",
"if",
"(",
"len",
"==",
"1",
")",
"{",
"return",
"firstByte",
";",
"}",
"long",
"i",
"=",
"0",
";",
"for",
"(",
"int",
"idx",
"=",
"0",
";",
"idx",
"<",
"len",
"-",
"1",
";",
"idx",
"++",
")",
"{",
"byte",
"b",
"=",
"stream",
".",
"readByte",
"(",
")",
";",
"i",
"=",
"i",
"<<",
"8",
";",
"i",
"=",
"i",
"|",
"(",
"b",
"&",
"0xFF",
")",
";",
"}",
"return",
"(",
"isNegativeVInt",
"(",
"firstByte",
")",
"?",
"(",
"i",
"^",
"-",
"1L",
")",
":",
"i",
")",
";",
"}"
] | Reads a zero-compressed encoded long from input stream and returns it.
@param stream Binary input stream
@throws java.io.IOException
@return deserialized long from stream. | [
"Reads",
"a",
"zero",
"-",
"compressed",
"encoded",
"long",
"from",
"input",
"stream",
"and",
"returns",
"it",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-api/src/main/java/org/apache/gobblin/compat/hadoop/TextSerializer.java#L102-L115 |
25,869 | apache/incubator-gobblin | gobblin-service/src/main/java/org/apache/gobblin/service/modules/orchestration/Orchestrator.java | Orchestrator.canRun | private boolean canRun(String flowName, String flowGroup, boolean allowConcurrentExecution) {
if (allowConcurrentExecution) {
return true;
} else {
return !flowStatusGenerator.isFlowRunning(flowName, flowGroup);
}
} | java | private boolean canRun(String flowName, String flowGroup, boolean allowConcurrentExecution) {
if (allowConcurrentExecution) {
return true;
} else {
return !flowStatusGenerator.isFlowRunning(flowName, flowGroup);
}
} | [
"private",
"boolean",
"canRun",
"(",
"String",
"flowName",
",",
"String",
"flowGroup",
",",
"boolean",
"allowConcurrentExecution",
")",
"{",
"if",
"(",
"allowConcurrentExecution",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"!",
"flowStatusGenerator",
".",
"isFlowRunning",
"(",
"flowName",
",",
"flowGroup",
")",
";",
"}",
"}"
] | Check if the flow instance is allowed to run.
@param flowName
@param flowGroup
@param allowConcurrentExecution
@return true if the {@link FlowSpec} allows concurrent executions or if no other instance of the flow is currently RUNNING. | [
"Check",
"if",
"the",
"flow",
"instance",
"is",
"allowed",
"to",
"run",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-service/src/main/java/org/apache/gobblin/service/modules/orchestration/Orchestrator.java#L315-L321 |
25,870 | apache/incubator-gobblin | gobblin-modules/gobblin-kafka-common/src/main/java/org/apache/gobblin/source/extractor/extract/kafka/KafkaSource.java | KafkaSource.getAllPreviousOffsetState | private synchronized void getAllPreviousOffsetState(SourceState state) {
if (this.doneGettingAllPreviousOffsets) {
return;
}
this.previousOffsets.clear();
this.previousLowWatermarks.clear();
this.previousExpectedHighWatermarks.clear();
this.previousOffsetFetchEpochTimes.clear();
this.previousStartFetchEpochTimes.clear();
this.previousStopFetchEpochTimes.clear();
Map<String, Iterable<WorkUnitState>> workUnitStatesByDatasetUrns = state.getPreviousWorkUnitStatesByDatasetUrns();
if (!workUnitStatesByDatasetUrns.isEmpty() &&
!(workUnitStatesByDatasetUrns.size() == 1 && workUnitStatesByDatasetUrns.keySet().iterator().next()
.equals(""))) {
this.isDatasetStateEnabled.set(true);
}
for (WorkUnitState workUnitState : state.getPreviousWorkUnitStates()) {
List<KafkaPartition> partitions = KafkaUtils.getPartitions(workUnitState);
WorkUnit workUnit = workUnitState.getWorkunit();
MultiLongWatermark watermark = workUnitState.getActualHighWatermark(MultiLongWatermark.class);
MultiLongWatermark previousLowWatermark = workUnit.getLowWatermark(MultiLongWatermark.class);
MultiLongWatermark previousExpectedHighWatermark = workUnit.getExpectedHighWatermark(MultiLongWatermark.class);
Preconditions.checkArgument(partitions.size() == watermark.size(), String
.format("Num of partitions doesn't match number of watermarks: partitions=%s, watermarks=%s", partitions,
watermark));
for (int i = 0; i < partitions.size(); i++) {
KafkaPartition partition = partitions.get(i);
if (watermark.get(i) != ConfigurationKeys.DEFAULT_WATERMARK_VALUE) {
this.previousOffsets.put(partition, watermark.get(i));
}
if (previousLowWatermark.get(i) != ConfigurationKeys.DEFAULT_WATERMARK_VALUE) {
this.previousLowWatermarks.put(partition, previousLowWatermark.get(i));
}
if (previousExpectedHighWatermark.get(i) != ConfigurationKeys.DEFAULT_WATERMARK_VALUE) {
this.previousExpectedHighWatermarks.put(partition, previousExpectedHighWatermark.get(i));
}
this.previousOffsetFetchEpochTimes.put(partition,
KafkaUtils.getPropAsLongFromSingleOrMultiWorkUnitState(workUnitState, OFFSET_FETCH_EPOCH_TIME, i));
this.previousStartFetchEpochTimes.put(partition,
KafkaUtils.getPropAsLongFromSingleOrMultiWorkUnitState(workUnitState, START_FETCH_EPOCH_TIME, i));
this.previousStopFetchEpochTimes.put(partition,
KafkaUtils.getPropAsLongFromSingleOrMultiWorkUnitState(workUnitState, STOP_FETCH_EPOCH_TIME, i));
}
}
this.doneGettingAllPreviousOffsets = true;
} | java | private synchronized void getAllPreviousOffsetState(SourceState state) {
if (this.doneGettingAllPreviousOffsets) {
return;
}
this.previousOffsets.clear();
this.previousLowWatermarks.clear();
this.previousExpectedHighWatermarks.clear();
this.previousOffsetFetchEpochTimes.clear();
this.previousStartFetchEpochTimes.clear();
this.previousStopFetchEpochTimes.clear();
Map<String, Iterable<WorkUnitState>> workUnitStatesByDatasetUrns = state.getPreviousWorkUnitStatesByDatasetUrns();
if (!workUnitStatesByDatasetUrns.isEmpty() &&
!(workUnitStatesByDatasetUrns.size() == 1 && workUnitStatesByDatasetUrns.keySet().iterator().next()
.equals(""))) {
this.isDatasetStateEnabled.set(true);
}
for (WorkUnitState workUnitState : state.getPreviousWorkUnitStates()) {
List<KafkaPartition> partitions = KafkaUtils.getPartitions(workUnitState);
WorkUnit workUnit = workUnitState.getWorkunit();
MultiLongWatermark watermark = workUnitState.getActualHighWatermark(MultiLongWatermark.class);
MultiLongWatermark previousLowWatermark = workUnit.getLowWatermark(MultiLongWatermark.class);
MultiLongWatermark previousExpectedHighWatermark = workUnit.getExpectedHighWatermark(MultiLongWatermark.class);
Preconditions.checkArgument(partitions.size() == watermark.size(), String
.format("Num of partitions doesn't match number of watermarks: partitions=%s, watermarks=%s", partitions,
watermark));
for (int i = 0; i < partitions.size(); i++) {
KafkaPartition partition = partitions.get(i);
if (watermark.get(i) != ConfigurationKeys.DEFAULT_WATERMARK_VALUE) {
this.previousOffsets.put(partition, watermark.get(i));
}
if (previousLowWatermark.get(i) != ConfigurationKeys.DEFAULT_WATERMARK_VALUE) {
this.previousLowWatermarks.put(partition, previousLowWatermark.get(i));
}
if (previousExpectedHighWatermark.get(i) != ConfigurationKeys.DEFAULT_WATERMARK_VALUE) {
this.previousExpectedHighWatermarks.put(partition, previousExpectedHighWatermark.get(i));
}
this.previousOffsetFetchEpochTimes.put(partition,
KafkaUtils.getPropAsLongFromSingleOrMultiWorkUnitState(workUnitState, OFFSET_FETCH_EPOCH_TIME, i));
this.previousStartFetchEpochTimes.put(partition,
KafkaUtils.getPropAsLongFromSingleOrMultiWorkUnitState(workUnitState, START_FETCH_EPOCH_TIME, i));
this.previousStopFetchEpochTimes.put(partition,
KafkaUtils.getPropAsLongFromSingleOrMultiWorkUnitState(workUnitState, STOP_FETCH_EPOCH_TIME, i));
}
}
this.doneGettingAllPreviousOffsets = true;
} | [
"private",
"synchronized",
"void",
"getAllPreviousOffsetState",
"(",
"SourceState",
"state",
")",
"{",
"if",
"(",
"this",
".",
"doneGettingAllPreviousOffsets",
")",
"{",
"return",
";",
"}",
"this",
".",
"previousOffsets",
".",
"clear",
"(",
")",
";",
"this",
".",
"previousLowWatermarks",
".",
"clear",
"(",
")",
";",
"this",
".",
"previousExpectedHighWatermarks",
".",
"clear",
"(",
")",
";",
"this",
".",
"previousOffsetFetchEpochTimes",
".",
"clear",
"(",
")",
";",
"this",
".",
"previousStartFetchEpochTimes",
".",
"clear",
"(",
")",
";",
"this",
".",
"previousStopFetchEpochTimes",
".",
"clear",
"(",
")",
";",
"Map",
"<",
"String",
",",
"Iterable",
"<",
"WorkUnitState",
">",
">",
"workUnitStatesByDatasetUrns",
"=",
"state",
".",
"getPreviousWorkUnitStatesByDatasetUrns",
"(",
")",
";",
"if",
"(",
"!",
"workUnitStatesByDatasetUrns",
".",
"isEmpty",
"(",
")",
"&&",
"!",
"(",
"workUnitStatesByDatasetUrns",
".",
"size",
"(",
")",
"==",
"1",
"&&",
"workUnitStatesByDatasetUrns",
".",
"keySet",
"(",
")",
".",
"iterator",
"(",
")",
".",
"next",
"(",
")",
".",
"equals",
"(",
"\"\"",
")",
")",
")",
"{",
"this",
".",
"isDatasetStateEnabled",
".",
"set",
"(",
"true",
")",
";",
"}",
"for",
"(",
"WorkUnitState",
"workUnitState",
":",
"state",
".",
"getPreviousWorkUnitStates",
"(",
")",
")",
"{",
"List",
"<",
"KafkaPartition",
">",
"partitions",
"=",
"KafkaUtils",
".",
"getPartitions",
"(",
"workUnitState",
")",
";",
"WorkUnit",
"workUnit",
"=",
"workUnitState",
".",
"getWorkunit",
"(",
")",
";",
"MultiLongWatermark",
"watermark",
"=",
"workUnitState",
".",
"getActualHighWatermark",
"(",
"MultiLongWatermark",
".",
"class",
")",
";",
"MultiLongWatermark",
"previousLowWatermark",
"=",
"workUnit",
".",
"getLowWatermark",
"(",
"MultiLongWatermark",
".",
"class",
")",
";",
"MultiLongWatermark",
"previousExpectedHighWatermark",
"=",
"workUnit",
".",
"getExpectedHighWatermark",
"(",
"MultiLongWatermark",
".",
"class",
")",
";",
"Preconditions",
".",
"checkArgument",
"(",
"partitions",
".",
"size",
"(",
")",
"==",
"watermark",
".",
"size",
"(",
")",
",",
"String",
".",
"format",
"(",
"\"Num of partitions doesn't match number of watermarks: partitions=%s, watermarks=%s\"",
",",
"partitions",
",",
"watermark",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"partitions",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"KafkaPartition",
"partition",
"=",
"partitions",
".",
"get",
"(",
"i",
")",
";",
"if",
"(",
"watermark",
".",
"get",
"(",
"i",
")",
"!=",
"ConfigurationKeys",
".",
"DEFAULT_WATERMARK_VALUE",
")",
"{",
"this",
".",
"previousOffsets",
".",
"put",
"(",
"partition",
",",
"watermark",
".",
"get",
"(",
"i",
")",
")",
";",
"}",
"if",
"(",
"previousLowWatermark",
".",
"get",
"(",
"i",
")",
"!=",
"ConfigurationKeys",
".",
"DEFAULT_WATERMARK_VALUE",
")",
"{",
"this",
".",
"previousLowWatermarks",
".",
"put",
"(",
"partition",
",",
"previousLowWatermark",
".",
"get",
"(",
"i",
")",
")",
";",
"}",
"if",
"(",
"previousExpectedHighWatermark",
".",
"get",
"(",
"i",
")",
"!=",
"ConfigurationKeys",
".",
"DEFAULT_WATERMARK_VALUE",
")",
"{",
"this",
".",
"previousExpectedHighWatermarks",
".",
"put",
"(",
"partition",
",",
"previousExpectedHighWatermark",
".",
"get",
"(",
"i",
")",
")",
";",
"}",
"this",
".",
"previousOffsetFetchEpochTimes",
".",
"put",
"(",
"partition",
",",
"KafkaUtils",
".",
"getPropAsLongFromSingleOrMultiWorkUnitState",
"(",
"workUnitState",
",",
"OFFSET_FETCH_EPOCH_TIME",
",",
"i",
")",
")",
";",
"this",
".",
"previousStartFetchEpochTimes",
".",
"put",
"(",
"partition",
",",
"KafkaUtils",
".",
"getPropAsLongFromSingleOrMultiWorkUnitState",
"(",
"workUnitState",
",",
"START_FETCH_EPOCH_TIME",
",",
"i",
")",
")",
";",
"this",
".",
"previousStopFetchEpochTimes",
".",
"put",
"(",
"partition",
",",
"KafkaUtils",
".",
"getPropAsLongFromSingleOrMultiWorkUnitState",
"(",
"workUnitState",
",",
"STOP_FETCH_EPOCH_TIME",
",",
"i",
")",
")",
";",
"}",
"}",
"this",
".",
"doneGettingAllPreviousOffsets",
"=",
"true",
";",
"}"
] | this.previousOffsetFetchEpochTimes need to be initialized once | [
"this",
".",
"previousOffsetFetchEpochTimes",
"need",
"to",
"be",
"initialized",
"once"
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-kafka-common/src/main/java/org/apache/gobblin/source/extractor/extract/kafka/KafkaSource.java#L562-L618 |
25,871 | apache/incubator-gobblin | gobblin-core/src/main/java/org/apache/gobblin/source/extractor/utils/Utils.java | Utils.getCoalesceColumnNames | public static String getCoalesceColumnNames(String columnOrColumnList) {
if (Strings.isNullOrEmpty(columnOrColumnList)) {
return null;
}
if (columnOrColumnList.contains(",")) {
return "COALESCE(" + columnOrColumnList + ")";
}
return columnOrColumnList;
} | java | public static String getCoalesceColumnNames(String columnOrColumnList) {
if (Strings.isNullOrEmpty(columnOrColumnList)) {
return null;
}
if (columnOrColumnList.contains(",")) {
return "COALESCE(" + columnOrColumnList + ")";
}
return columnOrColumnList;
} | [
"public",
"static",
"String",
"getCoalesceColumnNames",
"(",
"String",
"columnOrColumnList",
")",
"{",
"if",
"(",
"Strings",
".",
"isNullOrEmpty",
"(",
"columnOrColumnList",
")",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"columnOrColumnList",
".",
"contains",
"(",
"\",\"",
")",
")",
"{",
"return",
"\"COALESCE(\"",
"+",
"columnOrColumnList",
"+",
"\")\"",
";",
"}",
"return",
"columnOrColumnList",
";",
"}"
] | Get coalesce of columns if there are multiple comma-separated columns | [
"Get",
"coalesce",
"of",
"columns",
"if",
"there",
"are",
"multiple",
"comma",
"-",
"separated",
"columns"
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-core/src/main/java/org/apache/gobblin/source/extractor/utils/Utils.java#L62-L70 |
25,872 | apache/incubator-gobblin | gobblin-core/src/main/java/org/apache/gobblin/source/extractor/utils/Utils.java | Utils.printTiming | public static String printTiming(long start, long end) {
long totalMillis = end - start;
long mins = TimeUnit.MILLISECONDS.toMinutes(totalMillis);
long secs = TimeUnit.MILLISECONDS.toSeconds(totalMillis) - TimeUnit.MINUTES.toSeconds(mins);
long millis =
TimeUnit.MILLISECONDS.toMillis(totalMillis) - TimeUnit.MINUTES.toMillis(mins) - TimeUnit.SECONDS.toMillis(secs);
return String.format("%d min, %d sec, %d millis", mins, secs, millis);
} | java | public static String printTiming(long start, long end) {
long totalMillis = end - start;
long mins = TimeUnit.MILLISECONDS.toMinutes(totalMillis);
long secs = TimeUnit.MILLISECONDS.toSeconds(totalMillis) - TimeUnit.MINUTES.toSeconds(mins);
long millis =
TimeUnit.MILLISECONDS.toMillis(totalMillis) - TimeUnit.MINUTES.toMillis(mins) - TimeUnit.SECONDS.toMillis(secs);
return String.format("%d min, %d sec, %d millis", mins, secs, millis);
} | [
"public",
"static",
"String",
"printTiming",
"(",
"long",
"start",
",",
"long",
"end",
")",
"{",
"long",
"totalMillis",
"=",
"end",
"-",
"start",
";",
"long",
"mins",
"=",
"TimeUnit",
".",
"MILLISECONDS",
".",
"toMinutes",
"(",
"totalMillis",
")",
";",
"long",
"secs",
"=",
"TimeUnit",
".",
"MILLISECONDS",
".",
"toSeconds",
"(",
"totalMillis",
")",
"-",
"TimeUnit",
".",
"MINUTES",
".",
"toSeconds",
"(",
"mins",
")",
";",
"long",
"millis",
"=",
"TimeUnit",
".",
"MILLISECONDS",
".",
"toMillis",
"(",
"totalMillis",
")",
"-",
"TimeUnit",
".",
"MINUTES",
".",
"toMillis",
"(",
"mins",
")",
"-",
"TimeUnit",
".",
"SECONDS",
".",
"toMillis",
"(",
"secs",
")",
";",
"return",
"String",
".",
"format",
"(",
"\"%d min, %d sec, %d millis\"",
",",
"mins",
",",
"secs",
",",
"millis",
")",
";",
"}"
] | Print time difference in minutes, seconds and milliseconds | [
"Print",
"time",
"difference",
"in",
"minutes",
"seconds",
"and",
"milliseconds"
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-core/src/main/java/org/apache/gobblin/source/extractor/utils/Utils.java#L205-L212 |
25,873 | apache/incubator-gobblin | gobblin-core/src/main/java/org/apache/gobblin/source/extractor/utils/Utils.java | Utils.getColumnListFromQuery | public static List<String> getColumnListFromQuery(String query) {
if (Strings.isNullOrEmpty(query)) {
return null;
}
String queryLowerCase = query.toLowerCase();
int startIndex = queryLowerCase.indexOf("select ") + 7;
int endIndex = queryLowerCase.indexOf(" from ");
if (startIndex < 0 || endIndex < 0) {
return null;
}
String[] inputQueryColumns = query.substring(startIndex, endIndex).toLowerCase().replaceAll(" ", "").split(",");
return Arrays.asList(inputQueryColumns);
} | java | public static List<String> getColumnListFromQuery(String query) {
if (Strings.isNullOrEmpty(query)) {
return null;
}
String queryLowerCase = query.toLowerCase();
int startIndex = queryLowerCase.indexOf("select ") + 7;
int endIndex = queryLowerCase.indexOf(" from ");
if (startIndex < 0 || endIndex < 0) {
return null;
}
String[] inputQueryColumns = query.substring(startIndex, endIndex).toLowerCase().replaceAll(" ", "").split(",");
return Arrays.asList(inputQueryColumns);
} | [
"public",
"static",
"List",
"<",
"String",
">",
"getColumnListFromQuery",
"(",
"String",
"query",
")",
"{",
"if",
"(",
"Strings",
".",
"isNullOrEmpty",
"(",
"query",
")",
")",
"{",
"return",
"null",
";",
"}",
"String",
"queryLowerCase",
"=",
"query",
".",
"toLowerCase",
"(",
")",
";",
"int",
"startIndex",
"=",
"queryLowerCase",
".",
"indexOf",
"(",
"\"select \"",
")",
"+",
"7",
";",
"int",
"endIndex",
"=",
"queryLowerCase",
".",
"indexOf",
"(",
"\" from \"",
")",
";",
"if",
"(",
"startIndex",
"<",
"0",
"||",
"endIndex",
"<",
"0",
")",
"{",
"return",
"null",
";",
"}",
"String",
"[",
"]",
"inputQueryColumns",
"=",
"query",
".",
"substring",
"(",
"startIndex",
",",
"endIndex",
")",
".",
"toLowerCase",
"(",
")",
".",
"replaceAll",
"(",
"\" \"",
",",
"\"\"",
")",
".",
"split",
"(",
"\",\"",
")",
";",
"return",
"Arrays",
".",
"asList",
"(",
"inputQueryColumns",
")",
";",
"}"
] | get column list from the user provided query to build schema with the respective columns
@param input query
@return list of columns | [
"get",
"column",
"list",
"from",
"the",
"user",
"provided",
"query",
"to",
"build",
"schema",
"with",
"the",
"respective",
"columns"
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-core/src/main/java/org/apache/gobblin/source/extractor/utils/Utils.java#L219-L231 |
25,874 | apache/incubator-gobblin | gobblin-core/src/main/java/org/apache/gobblin/source/extractor/utils/Utils.java | Utils.escapeSpecialCharacters | public static String escapeSpecialCharacters(String columnName, String escapeChars, String character) {
if (Strings.isNullOrEmpty(columnName)) {
return null;
}
if (StringUtils.isEmpty(escapeChars)) {
return columnName;
}
List<String> specialChars = Arrays.asList(escapeChars.split(","));
for (String specialChar : specialChars) {
columnName = columnName.replace(specialChar, character);
}
return columnName;
} | java | public static String escapeSpecialCharacters(String columnName, String escapeChars, String character) {
if (Strings.isNullOrEmpty(columnName)) {
return null;
}
if (StringUtils.isEmpty(escapeChars)) {
return columnName;
}
List<String> specialChars = Arrays.asList(escapeChars.split(","));
for (String specialChar : specialChars) {
columnName = columnName.replace(specialChar, character);
}
return columnName;
} | [
"public",
"static",
"String",
"escapeSpecialCharacters",
"(",
"String",
"columnName",
",",
"String",
"escapeChars",
",",
"String",
"character",
")",
"{",
"if",
"(",
"Strings",
".",
"isNullOrEmpty",
"(",
"columnName",
")",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"StringUtils",
".",
"isEmpty",
"(",
"escapeChars",
")",
")",
"{",
"return",
"columnName",
";",
"}",
"List",
"<",
"String",
">",
"specialChars",
"=",
"Arrays",
".",
"asList",
"(",
"escapeChars",
".",
"split",
"(",
"\",\"",
")",
")",
";",
"for",
"(",
"String",
"specialChar",
":",
"specialChars",
")",
"{",
"columnName",
"=",
"columnName",
".",
"replace",
"(",
"specialChar",
",",
"character",
")",
";",
"}",
"return",
"columnName",
";",
"}"
] | escape characters in column name or table name | [
"escape",
"characters",
"in",
"column",
"name",
"or",
"table",
"name"
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-core/src/main/java/org/apache/gobblin/source/extractor/utils/Utils.java#L261-L275 |
25,875 | apache/incubator-gobblin | gobblin-core/src/main/java/org/apache/gobblin/source/extractor/utils/Utils.java | Utils.getLongWithCurrentDate | public static long getLongWithCurrentDate(String value, String timezone) {
if (Strings.isNullOrEmpty(value)) {
return 0;
}
DateTime time = getCurrentTime(timezone);
DateTimeFormatter dtFormatter = DateTimeFormat.forPattern(CURRENT_DATE_FORMAT).withZone(time.getZone());
if (value.toUpperCase().startsWith(CURRENT_DAY)) {
return Long
.parseLong(dtFormatter.print(time.minusDays(Integer.parseInt(value.substring(CURRENT_DAY.length() + 1)))));
}
if (value.toUpperCase().startsWith(CURRENT_HOUR)) {
return Long
.parseLong(dtFormatter.print(time.minusHours(Integer.parseInt(value.substring(CURRENT_HOUR.length() + 1)))));
}
return Long.parseLong(value);
} | java | public static long getLongWithCurrentDate(String value, String timezone) {
if (Strings.isNullOrEmpty(value)) {
return 0;
}
DateTime time = getCurrentTime(timezone);
DateTimeFormatter dtFormatter = DateTimeFormat.forPattern(CURRENT_DATE_FORMAT).withZone(time.getZone());
if (value.toUpperCase().startsWith(CURRENT_DAY)) {
return Long
.parseLong(dtFormatter.print(time.minusDays(Integer.parseInt(value.substring(CURRENT_DAY.length() + 1)))));
}
if (value.toUpperCase().startsWith(CURRENT_HOUR)) {
return Long
.parseLong(dtFormatter.print(time.minusHours(Integer.parseInt(value.substring(CURRENT_HOUR.length() + 1)))));
}
return Long.parseLong(value);
} | [
"public",
"static",
"long",
"getLongWithCurrentDate",
"(",
"String",
"value",
",",
"String",
"timezone",
")",
"{",
"if",
"(",
"Strings",
".",
"isNullOrEmpty",
"(",
"value",
")",
")",
"{",
"return",
"0",
";",
"}",
"DateTime",
"time",
"=",
"getCurrentTime",
"(",
"timezone",
")",
";",
"DateTimeFormatter",
"dtFormatter",
"=",
"DateTimeFormat",
".",
"forPattern",
"(",
"CURRENT_DATE_FORMAT",
")",
".",
"withZone",
"(",
"time",
".",
"getZone",
"(",
")",
")",
";",
"if",
"(",
"value",
".",
"toUpperCase",
"(",
")",
".",
"startsWith",
"(",
"CURRENT_DAY",
")",
")",
"{",
"return",
"Long",
".",
"parseLong",
"(",
"dtFormatter",
".",
"print",
"(",
"time",
".",
"minusDays",
"(",
"Integer",
".",
"parseInt",
"(",
"value",
".",
"substring",
"(",
"CURRENT_DAY",
".",
"length",
"(",
")",
"+",
"1",
")",
")",
")",
")",
")",
";",
"}",
"if",
"(",
"value",
".",
"toUpperCase",
"(",
")",
".",
"startsWith",
"(",
"CURRENT_HOUR",
")",
")",
"{",
"return",
"Long",
".",
"parseLong",
"(",
"dtFormatter",
".",
"print",
"(",
"time",
".",
"minusHours",
"(",
"Integer",
".",
"parseInt",
"(",
"value",
".",
"substring",
"(",
"CURRENT_HOUR",
".",
"length",
"(",
")",
"+",
"1",
")",
")",
")",
")",
")",
";",
"}",
"return",
"Long",
".",
"parseLong",
"(",
"value",
")",
";",
"}"
] | Helper method for getting a value containing CURRENTDAY-1 or CURRENTHOUR-1 in the form yyyyMMddHHmmss
@param value
@param timezone
@return | [
"Helper",
"method",
"for",
"getting",
"a",
"value",
"containing",
"CURRENTDAY",
"-",
"1",
"or",
"CURRENTHOUR",
"-",
"1",
"in",
"the",
"form",
"yyyyMMddHHmmss"
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-core/src/main/java/org/apache/gobblin/source/extractor/utils/Utils.java#L283-L299 |
25,876 | apache/incubator-gobblin | gobblin-core/src/main/java/org/apache/gobblin/source/extractor/utils/Utils.java | Utils.dateTimeToString | public static String dateTimeToString(DateTime input, String format, String timezone) {
String tz = StringUtils.defaultString(timezone, ConfigurationKeys.DEFAULT_SOURCE_TIMEZONE);
DateTimeZone dateTimeZone = getTimeZone(tz);
DateTimeFormatter outputDtFormat = DateTimeFormat.forPattern(format).withZone(dateTimeZone);
return outputDtFormat.print(input);
} | java | public static String dateTimeToString(DateTime input, String format, String timezone) {
String tz = StringUtils.defaultString(timezone, ConfigurationKeys.DEFAULT_SOURCE_TIMEZONE);
DateTimeZone dateTimeZone = getTimeZone(tz);
DateTimeFormatter outputDtFormat = DateTimeFormat.forPattern(format).withZone(dateTimeZone);
return outputDtFormat.print(input);
} | [
"public",
"static",
"String",
"dateTimeToString",
"(",
"DateTime",
"input",
",",
"String",
"format",
",",
"String",
"timezone",
")",
"{",
"String",
"tz",
"=",
"StringUtils",
".",
"defaultString",
"(",
"timezone",
",",
"ConfigurationKeys",
".",
"DEFAULT_SOURCE_TIMEZONE",
")",
";",
"DateTimeZone",
"dateTimeZone",
"=",
"getTimeZone",
"(",
"tz",
")",
";",
"DateTimeFormatter",
"outputDtFormat",
"=",
"DateTimeFormat",
".",
"forPattern",
"(",
"format",
")",
".",
"withZone",
"(",
"dateTimeZone",
")",
";",
"return",
"outputDtFormat",
".",
"print",
"(",
"input",
")",
";",
"}"
] | Convert joda time to a string in the given format
@param input timestamp
@param format expected format
@param timezone time zone of timestamp
@return string format of timestamp | [
"Convert",
"joda",
"time",
"to",
"a",
"string",
"in",
"the",
"given",
"format"
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-core/src/main/java/org/apache/gobblin/source/extractor/utils/Utils.java#L308-L313 |
25,877 | apache/incubator-gobblin | gobblin-core/src/main/java/org/apache/gobblin/source/extractor/utils/Utils.java | Utils.getCurrentTime | public static DateTime getCurrentTime(String timezone) {
String tz = StringUtils.defaultString(timezone, ConfigurationKeys.DEFAULT_SOURCE_TIMEZONE);
DateTimeZone dateTimeZone = getTimeZone(tz);
DateTime currentTime = new DateTime(dateTimeZone);
return currentTime;
} | java | public static DateTime getCurrentTime(String timezone) {
String tz = StringUtils.defaultString(timezone, ConfigurationKeys.DEFAULT_SOURCE_TIMEZONE);
DateTimeZone dateTimeZone = getTimeZone(tz);
DateTime currentTime = new DateTime(dateTimeZone);
return currentTime;
} | [
"public",
"static",
"DateTime",
"getCurrentTime",
"(",
"String",
"timezone",
")",
"{",
"String",
"tz",
"=",
"StringUtils",
".",
"defaultString",
"(",
"timezone",
",",
"ConfigurationKeys",
".",
"DEFAULT_SOURCE_TIMEZONE",
")",
";",
"DateTimeZone",
"dateTimeZone",
"=",
"getTimeZone",
"(",
"tz",
")",
";",
"DateTime",
"currentTime",
"=",
"new",
"DateTime",
"(",
"dateTimeZone",
")",
";",
"return",
"currentTime",
";",
"}"
] | Get current time - joda
@param timezone time zone of current time
@return current datetime in the given timezone | [
"Get",
"current",
"time",
"-",
"joda"
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-core/src/main/java/org/apache/gobblin/source/extractor/utils/Utils.java#L320-L325 |
25,878 | apache/incubator-gobblin | gobblin-core/src/main/java/org/apache/gobblin/source/extractor/utils/Utils.java | Utils.toDateTime | public static DateTime toDateTime(String input, String format, String timezone) {
String tz = StringUtils.defaultString(timezone, ConfigurationKeys.DEFAULT_SOURCE_TIMEZONE);
DateTimeZone dateTimeZone = getTimeZone(tz);
DateTimeFormatter inputDtFormat = DateTimeFormat.forPattern(format).withZone(dateTimeZone);
DateTime outputDateTime = inputDtFormat.parseDateTime(input).withZone(dateTimeZone);
return outputDateTime;
} | java | public static DateTime toDateTime(String input, String format, String timezone) {
String tz = StringUtils.defaultString(timezone, ConfigurationKeys.DEFAULT_SOURCE_TIMEZONE);
DateTimeZone dateTimeZone = getTimeZone(tz);
DateTimeFormatter inputDtFormat = DateTimeFormat.forPattern(format).withZone(dateTimeZone);
DateTime outputDateTime = inputDtFormat.parseDateTime(input).withZone(dateTimeZone);
return outputDateTime;
} | [
"public",
"static",
"DateTime",
"toDateTime",
"(",
"String",
"input",
",",
"String",
"format",
",",
"String",
"timezone",
")",
"{",
"String",
"tz",
"=",
"StringUtils",
".",
"defaultString",
"(",
"timezone",
",",
"ConfigurationKeys",
".",
"DEFAULT_SOURCE_TIMEZONE",
")",
";",
"DateTimeZone",
"dateTimeZone",
"=",
"getTimeZone",
"(",
"tz",
")",
";",
"DateTimeFormatter",
"inputDtFormat",
"=",
"DateTimeFormat",
".",
"forPattern",
"(",
"format",
")",
".",
"withZone",
"(",
"dateTimeZone",
")",
";",
"DateTime",
"outputDateTime",
"=",
"inputDtFormat",
".",
"parseDateTime",
"(",
"input",
")",
".",
"withZone",
"(",
"dateTimeZone",
")",
";",
"return",
"outputDateTime",
";",
"}"
] | Convert timestamp in a string format to joda time
@param input timestamp
@param format timestamp format
@param timezone time zone of timestamp
@return joda time | [
"Convert",
"timestamp",
"in",
"a",
"string",
"format",
"to",
"joda",
"time"
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-core/src/main/java/org/apache/gobblin/source/extractor/utils/Utils.java#L334-L340 |
25,879 | apache/incubator-gobblin | gobblin-core/src/main/java/org/apache/gobblin/source/extractor/utils/Utils.java | Utils.toDateTime | public static DateTime toDateTime(long input, String format, String timezone) {
return toDateTime(Long.toString(input), format, timezone);
} | java | public static DateTime toDateTime(long input, String format, String timezone) {
return toDateTime(Long.toString(input), format, timezone);
} | [
"public",
"static",
"DateTime",
"toDateTime",
"(",
"long",
"input",
",",
"String",
"format",
",",
"String",
"timezone",
")",
"{",
"return",
"toDateTime",
"(",
"Long",
".",
"toString",
"(",
"input",
")",
",",
"format",
",",
"timezone",
")",
";",
"}"
] | Convert timestamp in a long format to joda time
@param input timestamp
@param format timestamp format
@param timezone time zone of timestamp
@return joda time | [
"Convert",
"timestamp",
"in",
"a",
"long",
"format",
"to",
"joda",
"time"
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-core/src/main/java/org/apache/gobblin/source/extractor/utils/Utils.java#L349-L351 |
25,880 | apache/incubator-gobblin | gobblin-core/src/main/java/org/apache/gobblin/source/extractor/utils/Utils.java | Utils.getTimeZone | private static DateTimeZone getTimeZone(String id) {
DateTimeZone zone;
try {
zone = DateTimeZone.forID(id);
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("TimeZone " + id + " not recognized");
}
return zone;
} | java | private static DateTimeZone getTimeZone(String id) {
DateTimeZone zone;
try {
zone = DateTimeZone.forID(id);
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("TimeZone " + id + " not recognized");
}
return zone;
} | [
"private",
"static",
"DateTimeZone",
"getTimeZone",
"(",
"String",
"id",
")",
"{",
"DateTimeZone",
"zone",
";",
"try",
"{",
"zone",
"=",
"DateTimeZone",
".",
"forID",
"(",
"id",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"e",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"TimeZone \"",
"+",
"id",
"+",
"\" not recognized\"",
")",
";",
"}",
"return",
"zone",
";",
"}"
] | Get time zone of time zone id
@param id timezone id
@return timezone | [
"Get",
"time",
"zone",
"of",
"time",
"zone",
"id"
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-core/src/main/java/org/apache/gobblin/source/extractor/utils/Utils.java#L358-L366 |
25,881 | apache/incubator-gobblin | gobblin-service/src/main/java/org/apache/gobblin/service/modules/scheduler/GobblinServiceJobScheduler.java | GobblinServiceJobScheduler.scheduleJob | @Override
public synchronized void scheduleJob(Properties jobProps, JobListener jobListener) throws JobException {
Map<String, Object> additionalJobDataMap = Maps.newHashMap();
additionalJobDataMap.put(ServiceConfigKeys.GOBBLIN_SERVICE_FLOWSPEC,
this.scheduledFlowSpecs.get(jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY)));
try {
scheduleJob(jobProps, jobListener, additionalJobDataMap, GobblinServiceJob.class);
} catch (Exception e) {
throw new JobException("Failed to schedule job " + jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY), e);
}
} | java | @Override
public synchronized void scheduleJob(Properties jobProps, JobListener jobListener) throws JobException {
Map<String, Object> additionalJobDataMap = Maps.newHashMap();
additionalJobDataMap.put(ServiceConfigKeys.GOBBLIN_SERVICE_FLOWSPEC,
this.scheduledFlowSpecs.get(jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY)));
try {
scheduleJob(jobProps, jobListener, additionalJobDataMap, GobblinServiceJob.class);
} catch (Exception e) {
throw new JobException("Failed to schedule job " + jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY), e);
}
} | [
"@",
"Override",
"public",
"synchronized",
"void",
"scheduleJob",
"(",
"Properties",
"jobProps",
",",
"JobListener",
"jobListener",
")",
"throws",
"JobException",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"additionalJobDataMap",
"=",
"Maps",
".",
"newHashMap",
"(",
")",
";",
"additionalJobDataMap",
".",
"put",
"(",
"ServiceConfigKeys",
".",
"GOBBLIN_SERVICE_FLOWSPEC",
",",
"this",
".",
"scheduledFlowSpecs",
".",
"get",
"(",
"jobProps",
".",
"getProperty",
"(",
"ConfigurationKeys",
".",
"JOB_NAME_KEY",
")",
")",
")",
";",
"try",
"{",
"scheduleJob",
"(",
"jobProps",
",",
"jobListener",
",",
"additionalJobDataMap",
",",
"GobblinServiceJob",
".",
"class",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"JobException",
"(",
"\"Failed to schedule job \"",
"+",
"jobProps",
".",
"getProperty",
"(",
"ConfigurationKeys",
".",
"JOB_NAME_KEY",
")",
",",
"e",
")",
";",
"}",
"}"
] | Synchronize the job scheduling because the same flowSpec can be scheduled by different threads. | [
"Synchronize",
"the",
"job",
"scheduling",
"because",
"the",
"same",
"flowSpec",
"can",
"be",
"scheduled",
"by",
"different",
"threads",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-service/src/main/java/org/apache/gobblin/service/modules/scheduler/GobblinServiceJobScheduler.java#L191-L202 |
25,882 | apache/incubator-gobblin | gobblin-modules/google-ingestion/src/main/java/org/apache/gobblin/ingestion/google/webmaster/UrlTriePrefixGrouper.java | UrlTriePrefixGrouper.groupToPages | public static ArrayList<String> groupToPages(Triple<String, GoogleWebmasterFilter.FilterOperator, UrlTrieNode> group) {
ArrayList<String> ret = new ArrayList<>();
if (group.getMiddle().equals(GoogleWebmasterFilter.FilterOperator.EQUALS)) {
if (group.getRight().isExist()) {
ret.add(group.getLeft());
}
} else if (group.getMiddle().equals(GoogleWebmasterFilter.FilterOperator.CONTAINS)) {
UrlTrie trie = new UrlTrie(group.getLeft(), group.getRight());
Iterator<Pair<String, UrlTrieNode>> iterator = new UrlTriePostOrderIterator(trie, 1);
while (iterator.hasNext()) {
Pair<String, UrlTrieNode> next = iterator.next();
if (next.getRight().isExist()) {
ret.add(next.getLeft());
}
}
}
return ret;
} | java | public static ArrayList<String> groupToPages(Triple<String, GoogleWebmasterFilter.FilterOperator, UrlTrieNode> group) {
ArrayList<String> ret = new ArrayList<>();
if (group.getMiddle().equals(GoogleWebmasterFilter.FilterOperator.EQUALS)) {
if (group.getRight().isExist()) {
ret.add(group.getLeft());
}
} else if (group.getMiddle().equals(GoogleWebmasterFilter.FilterOperator.CONTAINS)) {
UrlTrie trie = new UrlTrie(group.getLeft(), group.getRight());
Iterator<Pair<String, UrlTrieNode>> iterator = new UrlTriePostOrderIterator(trie, 1);
while (iterator.hasNext()) {
Pair<String, UrlTrieNode> next = iterator.next();
if (next.getRight().isExist()) {
ret.add(next.getLeft());
}
}
}
return ret;
} | [
"public",
"static",
"ArrayList",
"<",
"String",
">",
"groupToPages",
"(",
"Triple",
"<",
"String",
",",
"GoogleWebmasterFilter",
".",
"FilterOperator",
",",
"UrlTrieNode",
">",
"group",
")",
"{",
"ArrayList",
"<",
"String",
">",
"ret",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"if",
"(",
"group",
".",
"getMiddle",
"(",
")",
".",
"equals",
"(",
"GoogleWebmasterFilter",
".",
"FilterOperator",
".",
"EQUALS",
")",
")",
"{",
"if",
"(",
"group",
".",
"getRight",
"(",
")",
".",
"isExist",
"(",
")",
")",
"{",
"ret",
".",
"add",
"(",
"group",
".",
"getLeft",
"(",
")",
")",
";",
"}",
"}",
"else",
"if",
"(",
"group",
".",
"getMiddle",
"(",
")",
".",
"equals",
"(",
"GoogleWebmasterFilter",
".",
"FilterOperator",
".",
"CONTAINS",
")",
")",
"{",
"UrlTrie",
"trie",
"=",
"new",
"UrlTrie",
"(",
"group",
".",
"getLeft",
"(",
")",
",",
"group",
".",
"getRight",
"(",
")",
")",
";",
"Iterator",
"<",
"Pair",
"<",
"String",
",",
"UrlTrieNode",
">",
">",
"iterator",
"=",
"new",
"UrlTriePostOrderIterator",
"(",
"trie",
",",
"1",
")",
";",
"while",
"(",
"iterator",
".",
"hasNext",
"(",
")",
")",
"{",
"Pair",
"<",
"String",
",",
"UrlTrieNode",
">",
"next",
"=",
"iterator",
".",
"next",
"(",
")",
";",
"if",
"(",
"next",
".",
"getRight",
"(",
")",
".",
"isExist",
"(",
")",
")",
"{",
"ret",
".",
"add",
"(",
"next",
".",
"getLeft",
"(",
")",
")",
";",
"}",
"}",
"}",
"return",
"ret",
";",
"}"
] | Get the detailed pages under this group | [
"Get",
"the",
"detailed",
"pages",
"under",
"this",
"group"
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/google-ingestion/src/main/java/org/apache/gobblin/ingestion/google/webmaster/UrlTriePrefixGrouper.java#L78-L95 |
25,883 | apache/incubator-gobblin | gobblin-utility/src/main/java/org/apache/gobblin/util/HadoopUtils.java | HadoopUtils.deletePathByRegex | public static void deletePathByRegex(FileSystem fs, final Path path, final String regex) throws IOException {
FileStatus[] statusList = fs.listStatus(path, path1 -> path1.getName().matches(regex));
for (final FileStatus oldJobFile : statusList) {
HadoopUtils.deletePath(fs, oldJobFile.getPath(), true);
}
} | java | public static void deletePathByRegex(FileSystem fs, final Path path, final String regex) throws IOException {
FileStatus[] statusList = fs.listStatus(path, path1 -> path1.getName().matches(regex));
for (final FileStatus oldJobFile : statusList) {
HadoopUtils.deletePath(fs, oldJobFile.getPath(), true);
}
} | [
"public",
"static",
"void",
"deletePathByRegex",
"(",
"FileSystem",
"fs",
",",
"final",
"Path",
"path",
",",
"final",
"String",
"regex",
")",
"throws",
"IOException",
"{",
"FileStatus",
"[",
"]",
"statusList",
"=",
"fs",
".",
"listStatus",
"(",
"path",
",",
"path1",
"->",
"path1",
".",
"getName",
"(",
")",
".",
"matches",
"(",
"regex",
")",
")",
";",
"for",
"(",
"final",
"FileStatus",
"oldJobFile",
":",
"statusList",
")",
"{",
"HadoopUtils",
".",
"deletePath",
"(",
"fs",
",",
"oldJobFile",
".",
"getPath",
"(",
")",
",",
"true",
")",
";",
"}",
"}"
] | Delete files according to the regular expression provided
@param fs Filesystem object
@param path base path
@param regex regular expression to select files to delete
@throws IOException | [
"Delete",
"files",
"according",
"to",
"the",
"regular",
"expression",
"provided"
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-utility/src/main/java/org/apache/gobblin/util/HadoopUtils.java#L197-L203 |
25,884 | apache/incubator-gobblin | gobblin-utility/src/main/java/org/apache/gobblin/util/HadoopUtils.java | HadoopUtils.moveToTrash | public static void moveToTrash(FileSystem fs, Path path) throws IOException {
Trash trash = new Trash(fs, new Configuration());
trash.moveToTrash(path);
} | java | public static void moveToTrash(FileSystem fs, Path path) throws IOException {
Trash trash = new Trash(fs, new Configuration());
trash.moveToTrash(path);
} | [
"public",
"static",
"void",
"moveToTrash",
"(",
"FileSystem",
"fs",
",",
"Path",
"path",
")",
"throws",
"IOException",
"{",
"Trash",
"trash",
"=",
"new",
"Trash",
"(",
"fs",
",",
"new",
"Configuration",
"(",
")",
")",
";",
"trash",
".",
"moveToTrash",
"(",
"path",
")",
";",
"}"
] | Moves the object to the filesystem trash according to the file system policy.
@param fs FileSystem object
@param path Path to the object to be moved to trash.
@throws IOException | [
"Moves",
"the",
"object",
"to",
"the",
"filesystem",
"trash",
"according",
"to",
"the",
"file",
"system",
"policy",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-utility/src/main/java/org/apache/gobblin/util/HadoopUtils.java#L211-L214 |
25,885 | apache/incubator-gobblin | gobblin-utility/src/main/java/org/apache/gobblin/util/HadoopUtils.java | HadoopUtils.unsafeRenameIfNotExists | public static boolean unsafeRenameIfNotExists(FileSystem fs, Path from, Path to) throws IOException {
if (!fs.exists(to)) {
if (!fs.exists(to.getParent())) {
fs.mkdirs(to.getParent());
}
if (!renamePathHandleLocalFSRace(fs, from, to)) {
if (!fs.exists(to)) {
throw new IOException(String.format("Failed to rename %s to %s.", from, to));
}
return false;
}
return true;
}
return false;
} | java | public static boolean unsafeRenameIfNotExists(FileSystem fs, Path from, Path to) throws IOException {
if (!fs.exists(to)) {
if (!fs.exists(to.getParent())) {
fs.mkdirs(to.getParent());
}
if (!renamePathHandleLocalFSRace(fs, from, to)) {
if (!fs.exists(to)) {
throw new IOException(String.format("Failed to rename %s to %s.", from, to));
}
return false;
}
return true;
}
return false;
} | [
"public",
"static",
"boolean",
"unsafeRenameIfNotExists",
"(",
"FileSystem",
"fs",
",",
"Path",
"from",
",",
"Path",
"to",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"fs",
".",
"exists",
"(",
"to",
")",
")",
"{",
"if",
"(",
"!",
"fs",
".",
"exists",
"(",
"to",
".",
"getParent",
"(",
")",
")",
")",
"{",
"fs",
".",
"mkdirs",
"(",
"to",
".",
"getParent",
"(",
")",
")",
";",
"}",
"if",
"(",
"!",
"renamePathHandleLocalFSRace",
"(",
"fs",
",",
"from",
",",
"to",
")",
")",
"{",
"if",
"(",
"!",
"fs",
".",
"exists",
"(",
"to",
")",
")",
"{",
"throw",
"new",
"IOException",
"(",
"String",
".",
"format",
"(",
"\"Failed to rename %s to %s.\"",
",",
"from",
",",
"to",
")",
")",
";",
"}",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Renames from to to if to doesn't exist in a non-thread-safe way.
@param fs filesystem where rename will be executed.
@param from origin {@link Path}.
@param to target {@link Path}.
@return true if rename succeeded, false if the target already exists.
@throws IOException if rename failed for reasons other than target exists. | [
"Renames",
"from",
"to",
"to",
"if",
"to",
"doesn",
"t",
"exist",
"in",
"a",
"non",
"-",
"thread",
"-",
"safe",
"way",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-utility/src/main/java/org/apache/gobblin/util/HadoopUtils.java#L648-L664 |
25,886 | apache/incubator-gobblin | gobblin-utility/src/main/java/org/apache/gobblin/util/HadoopUtils.java | HadoopUtils.setGroup | public static void setGroup(FileSystem fs, Path path, String group) throws IOException {
fs.setOwner(path, fs.getFileStatus(path).getOwner(), group);
} | java | public static void setGroup(FileSystem fs, Path path, String group) throws IOException {
fs.setOwner(path, fs.getFileStatus(path).getOwner(), group);
} | [
"public",
"static",
"void",
"setGroup",
"(",
"FileSystem",
"fs",
",",
"Path",
"path",
",",
"String",
"group",
")",
"throws",
"IOException",
"{",
"fs",
".",
"setOwner",
"(",
"path",
",",
"fs",
".",
"getFileStatus",
"(",
"path",
")",
".",
"getOwner",
"(",
")",
",",
"group",
")",
";",
"}"
] | Set the group associated with a given path.
@param fs the {@link FileSystem} instance used to perform the file operation
@param path the given path
@param group the group associated with the path
@throws IOException | [
"Set",
"the",
"group",
"associated",
"with",
"a",
"given",
"path",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-utility/src/main/java/org/apache/gobblin/util/HadoopUtils.java#L779-L781 |
25,887 | apache/incubator-gobblin | gobblin-utility/src/main/java/org/apache/gobblin/util/HadoopUtils.java | HadoopUtils.setPermissions | public static void setPermissions(Path location, Optional<String> owner, Optional<String> group, FileSystem fs,
FsPermission permission) {
try {
if (!owner.isPresent()) {
return;
}
if (!group.isPresent()) {
return;
}
fs.setOwner(location, owner.get(), group.get());
fs.setPermission(location, permission);
if (!fs.isDirectory(location)) {
return;
}
for (FileStatus fileStatus : fs.listStatus(location)) {
setPermissions(fileStatus.getPath(), owner, group, fs, permission);
}
} catch (IOException e) {
log.warn("Exception occurred while trying to change permissions : " + e.getMessage());
}
} | java | public static void setPermissions(Path location, Optional<String> owner, Optional<String> group, FileSystem fs,
FsPermission permission) {
try {
if (!owner.isPresent()) {
return;
}
if (!group.isPresent()) {
return;
}
fs.setOwner(location, owner.get(), group.get());
fs.setPermission(location, permission);
if (!fs.isDirectory(location)) {
return;
}
for (FileStatus fileStatus : fs.listStatus(location)) {
setPermissions(fileStatus.getPath(), owner, group, fs, permission);
}
} catch (IOException e) {
log.warn("Exception occurred while trying to change permissions : " + e.getMessage());
}
} | [
"public",
"static",
"void",
"setPermissions",
"(",
"Path",
"location",
",",
"Optional",
"<",
"String",
">",
"owner",
",",
"Optional",
"<",
"String",
">",
"group",
",",
"FileSystem",
"fs",
",",
"FsPermission",
"permission",
")",
"{",
"try",
"{",
"if",
"(",
"!",
"owner",
".",
"isPresent",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"group",
".",
"isPresent",
"(",
")",
")",
"{",
"return",
";",
"}",
"fs",
".",
"setOwner",
"(",
"location",
",",
"owner",
".",
"get",
"(",
")",
",",
"group",
".",
"get",
"(",
")",
")",
";",
"fs",
".",
"setPermission",
"(",
"location",
",",
"permission",
")",
";",
"if",
"(",
"!",
"fs",
".",
"isDirectory",
"(",
"location",
")",
")",
"{",
"return",
";",
"}",
"for",
"(",
"FileStatus",
"fileStatus",
":",
"fs",
".",
"listStatus",
"(",
"location",
")",
")",
"{",
"setPermissions",
"(",
"fileStatus",
".",
"getPath",
"(",
")",
",",
"owner",
",",
"group",
",",
"fs",
",",
"permission",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"log",
".",
"warn",
"(",
"\"Exception occurred while trying to change permissions : \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | Try to set owner and permissions for the path. Will not throw exception. | [
"Try",
"to",
"set",
"owner",
"and",
"permissions",
"for",
"the",
"path",
".",
"Will",
"not",
"throw",
"exception",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-utility/src/main/java/org/apache/gobblin/util/HadoopUtils.java#L937-L957 |
25,888 | apache/incubator-gobblin | gobblin-data-management/src/main/java/org/apache/gobblin/data/management/conversion/hive/materializer/CopyTableQueryGenerator.java | CopyTableQueryGenerator.generateQueries | @Override
public List<String> generateQueries() {
ensureParentOfStagingPathExists();
List<String> hiveQueries = Lists.newArrayList();
/*
* Setting partition mode to 'nonstrict' is needed to improve readability of the code.
* If we do not set dynamic partition mode to nonstrict, we will have to write partition values also,
* and because hive considers partition as a virtual column, we also have to write each of the column
* name in the query (in place of *) to match source and target columns.
*/
hiveQueries.add("SET hive.exec.dynamic.partition.mode=nonstrict");
Preconditions.checkNotNull(this.workUnit, "Workunit must not be null");
EventWorkunitUtils.setBeginDDLBuildTimeMetadata(this.workUnit, System.currentTimeMillis());
HiveConverterUtils.createStagingDirectory(fs, outputTableMetadata.getDestinationDataPath(),
conversionEntity, this.workUnitState);
// Create DDL statement for table
String createStagingTableDDL =
HiveConverterUtils.generateCreateDuplicateTableDDL(
inputDbName,
inputTableName,
stagingTableName,
stagingDataLocation,
Optional.of(outputDatabaseName));
hiveQueries.add(createStagingTableDDL);
log.debug("Create staging table DDL:\n" + createStagingTableDDL);
String insertInStagingTableDML =
HiveConverterUtils
.generateTableCopy(
inputTableName,
stagingTableName,
conversionEntity.getTable().getDbName(),
outputDatabaseName,
Optional.of(partitionsDMLInfo));
hiveQueries.add(insertInStagingTableDML);
log.debug("Conversion staging DML: " + insertInStagingTableDML);
log.info("Conversion Queries {}\n", hiveQueries);
EventWorkunitUtils.setEndDDLBuildTimeMetadata(workUnit, System.currentTimeMillis());
return hiveQueries;
} | java | @Override
public List<String> generateQueries() {
ensureParentOfStagingPathExists();
List<String> hiveQueries = Lists.newArrayList();
/*
* Setting partition mode to 'nonstrict' is needed to improve readability of the code.
* If we do not set dynamic partition mode to nonstrict, we will have to write partition values also,
* and because hive considers partition as a virtual column, we also have to write each of the column
* name in the query (in place of *) to match source and target columns.
*/
hiveQueries.add("SET hive.exec.dynamic.partition.mode=nonstrict");
Preconditions.checkNotNull(this.workUnit, "Workunit must not be null");
EventWorkunitUtils.setBeginDDLBuildTimeMetadata(this.workUnit, System.currentTimeMillis());
HiveConverterUtils.createStagingDirectory(fs, outputTableMetadata.getDestinationDataPath(),
conversionEntity, this.workUnitState);
// Create DDL statement for table
String createStagingTableDDL =
HiveConverterUtils.generateCreateDuplicateTableDDL(
inputDbName,
inputTableName,
stagingTableName,
stagingDataLocation,
Optional.of(outputDatabaseName));
hiveQueries.add(createStagingTableDDL);
log.debug("Create staging table DDL:\n" + createStagingTableDDL);
String insertInStagingTableDML =
HiveConverterUtils
.generateTableCopy(
inputTableName,
stagingTableName,
conversionEntity.getTable().getDbName(),
outputDatabaseName,
Optional.of(partitionsDMLInfo));
hiveQueries.add(insertInStagingTableDML);
log.debug("Conversion staging DML: " + insertInStagingTableDML);
log.info("Conversion Queries {}\n", hiveQueries);
EventWorkunitUtils.setEndDDLBuildTimeMetadata(workUnit, System.currentTimeMillis());
return hiveQueries;
} | [
"@",
"Override",
"public",
"List",
"<",
"String",
">",
"generateQueries",
"(",
")",
"{",
"ensureParentOfStagingPathExists",
"(",
")",
";",
"List",
"<",
"String",
">",
"hiveQueries",
"=",
"Lists",
".",
"newArrayList",
"(",
")",
";",
"/*\n * Setting partition mode to 'nonstrict' is needed to improve readability of the code.\n * If we do not set dynamic partition mode to nonstrict, we will have to write partition values also,\n * and because hive considers partition as a virtual column, we also have to write each of the column\n * name in the query (in place of *) to match source and target columns.\n */",
"hiveQueries",
".",
"add",
"(",
"\"SET hive.exec.dynamic.partition.mode=nonstrict\"",
")",
";",
"Preconditions",
".",
"checkNotNull",
"(",
"this",
".",
"workUnit",
",",
"\"Workunit must not be null\"",
")",
";",
"EventWorkunitUtils",
".",
"setBeginDDLBuildTimeMetadata",
"(",
"this",
".",
"workUnit",
",",
"System",
".",
"currentTimeMillis",
"(",
")",
")",
";",
"HiveConverterUtils",
".",
"createStagingDirectory",
"(",
"fs",
",",
"outputTableMetadata",
".",
"getDestinationDataPath",
"(",
")",
",",
"conversionEntity",
",",
"this",
".",
"workUnitState",
")",
";",
"// Create DDL statement for table",
"String",
"createStagingTableDDL",
"=",
"HiveConverterUtils",
".",
"generateCreateDuplicateTableDDL",
"(",
"inputDbName",
",",
"inputTableName",
",",
"stagingTableName",
",",
"stagingDataLocation",
",",
"Optional",
".",
"of",
"(",
"outputDatabaseName",
")",
")",
";",
"hiveQueries",
".",
"add",
"(",
"createStagingTableDDL",
")",
";",
"log",
".",
"debug",
"(",
"\"Create staging table DDL:\\n\"",
"+",
"createStagingTableDDL",
")",
";",
"String",
"insertInStagingTableDML",
"=",
"HiveConverterUtils",
".",
"generateTableCopy",
"(",
"inputTableName",
",",
"stagingTableName",
",",
"conversionEntity",
".",
"getTable",
"(",
")",
".",
"getDbName",
"(",
")",
",",
"outputDatabaseName",
",",
"Optional",
".",
"of",
"(",
"partitionsDMLInfo",
")",
")",
";",
"hiveQueries",
".",
"add",
"(",
"insertInStagingTableDML",
")",
";",
"log",
".",
"debug",
"(",
"\"Conversion staging DML: \"",
"+",
"insertInStagingTableDML",
")",
";",
"log",
".",
"info",
"(",
"\"Conversion Queries {}\\n\"",
",",
"hiveQueries",
")",
";",
"EventWorkunitUtils",
".",
"setEndDDLBuildTimeMetadata",
"(",
"workUnit",
",",
"System",
".",
"currentTimeMillis",
"(",
")",
")",
";",
"return",
"hiveQueries",
";",
"}"
] | Returns hive queries to be run as a part of a hive task.
This does not include publish queries.
@return | [
"Returns",
"hive",
"queries",
"to",
"be",
"run",
"as",
"a",
"part",
"of",
"a",
"hive",
"task",
".",
"This",
"does",
"not",
"include",
"publish",
"queries",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-data-management/src/main/java/org/apache/gobblin/data/management/conversion/hive/materializer/CopyTableQueryGenerator.java#L50-L97 |
25,889 | apache/incubator-gobblin | gobblin-modules/gobblin-kafka-common/src/main/java/org/apache/gobblin/source/extractor/extract/kafka/workunit/packer/KafkaWorkUnitPacker.java | KafkaWorkUnitPacker.setWorkUnitEstSizes | public double setWorkUnitEstSizes(Map<String, List<WorkUnit>> workUnitsByTopic) {
double totalEstDataSize = 0;
for (List<WorkUnit> workUnitsForTopic : workUnitsByTopic.values()) {
for (WorkUnit workUnit : workUnitsForTopic) {
setWorkUnitEstSize(workUnit);
totalEstDataSize += getWorkUnitEstSize(workUnit);
}
}
return totalEstDataSize;
} | java | public double setWorkUnitEstSizes(Map<String, List<WorkUnit>> workUnitsByTopic) {
double totalEstDataSize = 0;
for (List<WorkUnit> workUnitsForTopic : workUnitsByTopic.values()) {
for (WorkUnit workUnit : workUnitsForTopic) {
setWorkUnitEstSize(workUnit);
totalEstDataSize += getWorkUnitEstSize(workUnit);
}
}
return totalEstDataSize;
} | [
"public",
"double",
"setWorkUnitEstSizes",
"(",
"Map",
"<",
"String",
",",
"List",
"<",
"WorkUnit",
">",
">",
"workUnitsByTopic",
")",
"{",
"double",
"totalEstDataSize",
"=",
"0",
";",
"for",
"(",
"List",
"<",
"WorkUnit",
">",
"workUnitsForTopic",
":",
"workUnitsByTopic",
".",
"values",
"(",
")",
")",
"{",
"for",
"(",
"WorkUnit",
"workUnit",
":",
"workUnitsForTopic",
")",
"{",
"setWorkUnitEstSize",
"(",
"workUnit",
")",
";",
"totalEstDataSize",
"+=",
"getWorkUnitEstSize",
"(",
"workUnit",
")",
";",
"}",
"}",
"return",
"totalEstDataSize",
";",
"}"
] | Calculate the total size of the workUnits and set the estimated size for each workUnit
@param workUnitsByTopic
@return the total size of the input workUnits | [
"Calculate",
"the",
"total",
"size",
"of",
"the",
"workUnits",
"and",
"set",
"the",
"estimated",
"size",
"for",
"each",
"workUnit"
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-kafka-common/src/main/java/org/apache/gobblin/source/extractor/extract/kafka/workunit/packer/KafkaWorkUnitPacker.java#L370-L379 |
25,890 | apache/incubator-gobblin | gobblin-restli/gobblin-flow-config-service/gobblin-flow-config-service-client/src/main/java/org/apache/gobblin/service/FlowStatusClient.java | FlowStatusClient.getFlowStatus | public FlowStatus getFlowStatus(FlowStatusId flowStatusId)
throws RemoteInvocationException {
LOG.debug("getFlowConfig with groupName " + flowStatusId.getFlowGroup() + " flowName " +
flowStatusId.getFlowName());
GetRequest<FlowStatus> getRequest = _flowstatusesRequestBuilders.get()
.id(new ComplexResourceKey<>(flowStatusId, new EmptyRecord())).build();
Response<FlowStatus> response =
_restClient.get().sendRequest(getRequest).getResponse();
return response.getEntity();
} | java | public FlowStatus getFlowStatus(FlowStatusId flowStatusId)
throws RemoteInvocationException {
LOG.debug("getFlowConfig with groupName " + flowStatusId.getFlowGroup() + " flowName " +
flowStatusId.getFlowName());
GetRequest<FlowStatus> getRequest = _flowstatusesRequestBuilders.get()
.id(new ComplexResourceKey<>(flowStatusId, new EmptyRecord())).build();
Response<FlowStatus> response =
_restClient.get().sendRequest(getRequest).getResponse();
return response.getEntity();
} | [
"public",
"FlowStatus",
"getFlowStatus",
"(",
"FlowStatusId",
"flowStatusId",
")",
"throws",
"RemoteInvocationException",
"{",
"LOG",
".",
"debug",
"(",
"\"getFlowConfig with groupName \"",
"+",
"flowStatusId",
".",
"getFlowGroup",
"(",
")",
"+",
"\" flowName \"",
"+",
"flowStatusId",
".",
"getFlowName",
"(",
")",
")",
";",
"GetRequest",
"<",
"FlowStatus",
">",
"getRequest",
"=",
"_flowstatusesRequestBuilders",
".",
"get",
"(",
")",
".",
"id",
"(",
"new",
"ComplexResourceKey",
"<>",
"(",
"flowStatusId",
",",
"new",
"EmptyRecord",
"(",
")",
")",
")",
".",
"build",
"(",
")",
";",
"Response",
"<",
"FlowStatus",
">",
"response",
"=",
"_restClient",
".",
"get",
"(",
")",
".",
"sendRequest",
"(",
"getRequest",
")",
".",
"getResponse",
"(",
")",
";",
"return",
"response",
".",
"getEntity",
"(",
")",
";",
"}"
] | Get a flow status
@param flowStatusId identifier of flow status to get
@return a {@link FlowStatus} with the flow status
@throws RemoteInvocationException | [
"Get",
"a",
"flow",
"status"
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-restli/gobblin-flow-config-service/gobblin-flow-config-service-client/src/main/java/org/apache/gobblin/service/FlowStatusClient.java#L88-L99 |
25,891 | apache/incubator-gobblin | gobblin-cluster/src/main/java/org/apache/gobblin/cluster/GobblinHelixJobLauncher.java | GobblinHelixJobLauncher.submitJobToHelix | private void submitJobToHelix(JobConfig.Builder jobConfigBuilder) throws Exception {
HelixUtils.submitJobToWorkFlow(jobConfigBuilder,
this.helixWorkFlowName,
this.jobContext.getJobId(),
this.helixTaskDriver,
this.helixManager,
this.workFlowExpiryTimeSeconds);
} | java | private void submitJobToHelix(JobConfig.Builder jobConfigBuilder) throws Exception {
HelixUtils.submitJobToWorkFlow(jobConfigBuilder,
this.helixWorkFlowName,
this.jobContext.getJobId(),
this.helixTaskDriver,
this.helixManager,
this.workFlowExpiryTimeSeconds);
} | [
"private",
"void",
"submitJobToHelix",
"(",
"JobConfig",
".",
"Builder",
"jobConfigBuilder",
")",
"throws",
"Exception",
"{",
"HelixUtils",
".",
"submitJobToWorkFlow",
"(",
"jobConfigBuilder",
",",
"this",
".",
"helixWorkFlowName",
",",
"this",
".",
"jobContext",
".",
"getJobId",
"(",
")",
",",
"this",
".",
"helixTaskDriver",
",",
"this",
".",
"helixManager",
",",
"this",
".",
"workFlowExpiryTimeSeconds",
")",
";",
"}"
] | Submit a job to run. | [
"Submit",
"a",
"job",
"to",
"run",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-cluster/src/main/java/org/apache/gobblin/cluster/GobblinHelixJobLauncher.java#L343-L350 |
25,892 | apache/incubator-gobblin | gobblin-cluster/src/main/java/org/apache/gobblin/cluster/GobblinHelixJobLauncher.java | GobblinHelixJobLauncher.addAdditionalMetadataTags | private static List<? extends Tag<?>> addAdditionalMetadataTags(Properties jobProps, List<? extends Tag<?>> inputTags) {
List<Tag<?>> metadataTags = Lists.newArrayList(inputTags);
String jobId;
// generate job id if not already set
if (jobProps.containsKey(ConfigurationKeys.JOB_ID_KEY)) {
jobId = jobProps.getProperty(ConfigurationKeys.JOB_ID_KEY);
} else {
jobId = JobLauncherUtils.newJobId(JobState.getJobNameFromProps(jobProps));
jobProps.put(ConfigurationKeys.JOB_ID_KEY, jobId);
}
String jobExecutionId = Long.toString(Id.Job.parse(jobId).getSequence());
// only inject flow tags if a flow name is defined
if (jobProps.containsKey(ConfigurationKeys.FLOW_NAME_KEY)) {
metadataTags.add(new Tag<>(TimingEvent.FlowEventConstants.FLOW_GROUP_FIELD,
jobProps.getProperty(ConfigurationKeys.FLOW_GROUP_KEY, "")));
metadataTags.add(
new Tag<>(TimingEvent.FlowEventConstants.FLOW_NAME_FIELD, jobProps.getProperty(ConfigurationKeys.FLOW_NAME_KEY)));
// use job execution id if flow execution id is not present
metadataTags.add(new Tag<>(TimingEvent.FlowEventConstants.FLOW_EXECUTION_ID_FIELD,
jobProps.getProperty(ConfigurationKeys.FLOW_EXECUTION_ID_KEY, jobExecutionId)));
}
metadataTags.add(new Tag<>(TimingEvent.FlowEventConstants.JOB_GROUP_FIELD,
jobProps.getProperty(ConfigurationKeys.JOB_GROUP_KEY, "")));
metadataTags.add(new Tag<>(TimingEvent.FlowEventConstants.JOB_NAME_FIELD,
jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY, "")));
metadataTags.add(new Tag<>(TimingEvent.FlowEventConstants.JOB_EXECUTION_ID_FIELD, jobExecutionId));
LOGGER.debug("GobblinHelixJobLauncher.addAdditionalMetadataTags: metadataTags {}", metadataTags);
return metadataTags;
} | java | private static List<? extends Tag<?>> addAdditionalMetadataTags(Properties jobProps, List<? extends Tag<?>> inputTags) {
List<Tag<?>> metadataTags = Lists.newArrayList(inputTags);
String jobId;
// generate job id if not already set
if (jobProps.containsKey(ConfigurationKeys.JOB_ID_KEY)) {
jobId = jobProps.getProperty(ConfigurationKeys.JOB_ID_KEY);
} else {
jobId = JobLauncherUtils.newJobId(JobState.getJobNameFromProps(jobProps));
jobProps.put(ConfigurationKeys.JOB_ID_KEY, jobId);
}
String jobExecutionId = Long.toString(Id.Job.parse(jobId).getSequence());
// only inject flow tags if a flow name is defined
if (jobProps.containsKey(ConfigurationKeys.FLOW_NAME_KEY)) {
metadataTags.add(new Tag<>(TimingEvent.FlowEventConstants.FLOW_GROUP_FIELD,
jobProps.getProperty(ConfigurationKeys.FLOW_GROUP_KEY, "")));
metadataTags.add(
new Tag<>(TimingEvent.FlowEventConstants.FLOW_NAME_FIELD, jobProps.getProperty(ConfigurationKeys.FLOW_NAME_KEY)));
// use job execution id if flow execution id is not present
metadataTags.add(new Tag<>(TimingEvent.FlowEventConstants.FLOW_EXECUTION_ID_FIELD,
jobProps.getProperty(ConfigurationKeys.FLOW_EXECUTION_ID_KEY, jobExecutionId)));
}
metadataTags.add(new Tag<>(TimingEvent.FlowEventConstants.JOB_GROUP_FIELD,
jobProps.getProperty(ConfigurationKeys.JOB_GROUP_KEY, "")));
metadataTags.add(new Tag<>(TimingEvent.FlowEventConstants.JOB_NAME_FIELD,
jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY, "")));
metadataTags.add(new Tag<>(TimingEvent.FlowEventConstants.JOB_EXECUTION_ID_FIELD, jobExecutionId));
LOGGER.debug("GobblinHelixJobLauncher.addAdditionalMetadataTags: metadataTags {}", metadataTags);
return metadataTags;
} | [
"private",
"static",
"List",
"<",
"?",
"extends",
"Tag",
"<",
"?",
">",
">",
"addAdditionalMetadataTags",
"(",
"Properties",
"jobProps",
",",
"List",
"<",
"?",
"extends",
"Tag",
"<",
"?",
">",
">",
"inputTags",
")",
"{",
"List",
"<",
"Tag",
"<",
"?",
">",
">",
"metadataTags",
"=",
"Lists",
".",
"newArrayList",
"(",
"inputTags",
")",
";",
"String",
"jobId",
";",
"// generate job id if not already set",
"if",
"(",
"jobProps",
".",
"containsKey",
"(",
"ConfigurationKeys",
".",
"JOB_ID_KEY",
")",
")",
"{",
"jobId",
"=",
"jobProps",
".",
"getProperty",
"(",
"ConfigurationKeys",
".",
"JOB_ID_KEY",
")",
";",
"}",
"else",
"{",
"jobId",
"=",
"JobLauncherUtils",
".",
"newJobId",
"(",
"JobState",
".",
"getJobNameFromProps",
"(",
"jobProps",
")",
")",
";",
"jobProps",
".",
"put",
"(",
"ConfigurationKeys",
".",
"JOB_ID_KEY",
",",
"jobId",
")",
";",
"}",
"String",
"jobExecutionId",
"=",
"Long",
".",
"toString",
"(",
"Id",
".",
"Job",
".",
"parse",
"(",
"jobId",
")",
".",
"getSequence",
"(",
")",
")",
";",
"// only inject flow tags if a flow name is defined",
"if",
"(",
"jobProps",
".",
"containsKey",
"(",
"ConfigurationKeys",
".",
"FLOW_NAME_KEY",
")",
")",
"{",
"metadataTags",
".",
"add",
"(",
"new",
"Tag",
"<>",
"(",
"TimingEvent",
".",
"FlowEventConstants",
".",
"FLOW_GROUP_FIELD",
",",
"jobProps",
".",
"getProperty",
"(",
"ConfigurationKeys",
".",
"FLOW_GROUP_KEY",
",",
"\"\"",
")",
")",
")",
";",
"metadataTags",
".",
"add",
"(",
"new",
"Tag",
"<>",
"(",
"TimingEvent",
".",
"FlowEventConstants",
".",
"FLOW_NAME_FIELD",
",",
"jobProps",
".",
"getProperty",
"(",
"ConfigurationKeys",
".",
"FLOW_NAME_KEY",
")",
")",
")",
";",
"// use job execution id if flow execution id is not present",
"metadataTags",
".",
"add",
"(",
"new",
"Tag",
"<>",
"(",
"TimingEvent",
".",
"FlowEventConstants",
".",
"FLOW_EXECUTION_ID_FIELD",
",",
"jobProps",
".",
"getProperty",
"(",
"ConfigurationKeys",
".",
"FLOW_EXECUTION_ID_KEY",
",",
"jobExecutionId",
")",
")",
")",
";",
"}",
"metadataTags",
".",
"add",
"(",
"new",
"Tag",
"<>",
"(",
"TimingEvent",
".",
"FlowEventConstants",
".",
"JOB_GROUP_FIELD",
",",
"jobProps",
".",
"getProperty",
"(",
"ConfigurationKeys",
".",
"JOB_GROUP_KEY",
",",
"\"\"",
")",
")",
")",
";",
"metadataTags",
".",
"add",
"(",
"new",
"Tag",
"<>",
"(",
"TimingEvent",
".",
"FlowEventConstants",
".",
"JOB_NAME_FIELD",
",",
"jobProps",
".",
"getProperty",
"(",
"ConfigurationKeys",
".",
"JOB_NAME_KEY",
",",
"\"\"",
")",
")",
")",
";",
"metadataTags",
".",
"add",
"(",
"new",
"Tag",
"<>",
"(",
"TimingEvent",
".",
"FlowEventConstants",
".",
"JOB_EXECUTION_ID_FIELD",
",",
"jobExecutionId",
")",
")",
";",
"LOGGER",
".",
"debug",
"(",
"\"GobblinHelixJobLauncher.addAdditionalMetadataTags: metadataTags {}\"",
",",
"metadataTags",
")",
";",
"return",
"metadataTags",
";",
"}"
] | Inject in some additional properties
@param jobProps job properties
@param inputTags list of metadata tags
@return | [
"Inject",
"in",
"some",
"additional",
"properties"
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-cluster/src/main/java/org/apache/gobblin/cluster/GobblinHelixJobLauncher.java#L470-L505 |
25,893 | apache/incubator-gobblin | gobblin-utility/src/main/java/org/apache/gobblin/util/ClusterNameTags.java | ClusterNameTags.getClusterNameTags | public static Map<String, String> getClusterNameTags(Configuration conf) {
ImmutableMap.Builder<String, String> tagMap = ImmutableMap.builder();
String clusterIdentifierTag = ClustersNames.getInstance().getClusterName(conf);
if (!Strings.isNullOrEmpty(clusterIdentifierTag)) {
tagMap.put(CLUSTER_IDENTIFIER_TAG_NAME, clusterIdentifierTag);
}
return tagMap.build();
} | java | public static Map<String, String> getClusterNameTags(Configuration conf) {
ImmutableMap.Builder<String, String> tagMap = ImmutableMap.builder();
String clusterIdentifierTag = ClustersNames.getInstance().getClusterName(conf);
if (!Strings.isNullOrEmpty(clusterIdentifierTag)) {
tagMap.put(CLUSTER_IDENTIFIER_TAG_NAME, clusterIdentifierTag);
}
return tagMap.build();
} | [
"public",
"static",
"Map",
"<",
"String",
",",
"String",
">",
"getClusterNameTags",
"(",
"Configuration",
"conf",
")",
"{",
"ImmutableMap",
".",
"Builder",
"<",
"String",
",",
"String",
">",
"tagMap",
"=",
"ImmutableMap",
".",
"builder",
"(",
")",
";",
"String",
"clusterIdentifierTag",
"=",
"ClustersNames",
".",
"getInstance",
"(",
")",
".",
"getClusterName",
"(",
"conf",
")",
";",
"if",
"(",
"!",
"Strings",
".",
"isNullOrEmpty",
"(",
"clusterIdentifierTag",
")",
")",
"{",
"tagMap",
".",
"put",
"(",
"CLUSTER_IDENTIFIER_TAG_NAME",
",",
"clusterIdentifierTag",
")",
";",
"}",
"return",
"tagMap",
".",
"build",
"(",
")",
";",
"}"
] | Gets all useful Hadoop cluster metrics.
@param conf a Hadoop {@link Configuration} to collect the metadata from
@return a {@link Map} of key, value pairs containing the cluster metadata | [
"Gets",
"all",
"useful",
"Hadoop",
"cluster",
"metrics",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-utility/src/main/java/org/apache/gobblin/util/ClusterNameTags.java#L53-L61 |
25,894 | apache/incubator-gobblin | gobblin-runtime/src/main/java/org/apache/gobblin/runtime/api/FlowSpec.java | FlowSpec.builder | public static FlowSpec.Builder builder(URI catalogURI, Properties flowProps) {
String name = flowProps.getProperty(ConfigurationKeys.FLOW_NAME_KEY);
String group = flowProps.getProperty(ConfigurationKeys.FLOW_GROUP_KEY, "default");
try {
URI flowURI = new URI(catalogURI.getScheme(), catalogURI.getAuthority(),
"/" + group + "/" + name, null);
FlowSpec.Builder builder = new FlowSpec.Builder(flowURI).withConfigAsProperties(flowProps);
String descr = flowProps.getProperty(ConfigurationKeys.FLOW_DESCRIPTION_KEY, null);
if (null != descr) {
builder = builder.withDescription(descr);
}
return builder;
} catch (URISyntaxException e) {
throw new RuntimeException("Unable to create a FlowSpec URI: " + e, e);
}
} | java | public static FlowSpec.Builder builder(URI catalogURI, Properties flowProps) {
String name = flowProps.getProperty(ConfigurationKeys.FLOW_NAME_KEY);
String group = flowProps.getProperty(ConfigurationKeys.FLOW_GROUP_KEY, "default");
try {
URI flowURI = new URI(catalogURI.getScheme(), catalogURI.getAuthority(),
"/" + group + "/" + name, null);
FlowSpec.Builder builder = new FlowSpec.Builder(flowURI).withConfigAsProperties(flowProps);
String descr = flowProps.getProperty(ConfigurationKeys.FLOW_DESCRIPTION_KEY, null);
if (null != descr) {
builder = builder.withDescription(descr);
}
return builder;
} catch (URISyntaxException e) {
throw new RuntimeException("Unable to create a FlowSpec URI: " + e, e);
}
} | [
"public",
"static",
"FlowSpec",
".",
"Builder",
"builder",
"(",
"URI",
"catalogURI",
",",
"Properties",
"flowProps",
")",
"{",
"String",
"name",
"=",
"flowProps",
".",
"getProperty",
"(",
"ConfigurationKeys",
".",
"FLOW_NAME_KEY",
")",
";",
"String",
"group",
"=",
"flowProps",
".",
"getProperty",
"(",
"ConfigurationKeys",
".",
"FLOW_GROUP_KEY",
",",
"\"default\"",
")",
";",
"try",
"{",
"URI",
"flowURI",
"=",
"new",
"URI",
"(",
"catalogURI",
".",
"getScheme",
"(",
")",
",",
"catalogURI",
".",
"getAuthority",
"(",
")",
",",
"\"/\"",
"+",
"group",
"+",
"\"/\"",
"+",
"name",
",",
"null",
")",
";",
"FlowSpec",
".",
"Builder",
"builder",
"=",
"new",
"FlowSpec",
".",
"Builder",
"(",
"flowURI",
")",
".",
"withConfigAsProperties",
"(",
"flowProps",
")",
";",
"String",
"descr",
"=",
"flowProps",
".",
"getProperty",
"(",
"ConfigurationKeys",
".",
"FLOW_DESCRIPTION_KEY",
",",
"null",
")",
";",
"if",
"(",
"null",
"!=",
"descr",
")",
"{",
"builder",
"=",
"builder",
".",
"withDescription",
"(",
"descr",
")",
";",
"}",
"return",
"builder",
";",
"}",
"catch",
"(",
"URISyntaxException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Unable to create a FlowSpec URI: \"",
"+",
"e",
",",
"e",
")",
";",
"}",
"}"
] | Creates a builder for the FlowSpec based on values in a flow properties config. | [
"Creates",
"a",
"builder",
"for",
"the",
"FlowSpec",
"based",
"on",
"values",
"in",
"a",
"flow",
"properties",
"config",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-runtime/src/main/java/org/apache/gobblin/runtime/api/FlowSpec.java#L90-L107 |
25,895 | apache/incubator-gobblin | gobblin-compaction/src/main/java/org/apache/gobblin/compaction/dataset/TimeBasedSubDirDatasetsFinder.java | TimeBasedSubDirDatasetsFinder.folderWithinAllowedPeriod | protected boolean folderWithinAllowedPeriod(Path inputFolder, DateTime folderTime) {
DateTime currentTime = new DateTime(this.timeZone);
PeriodFormatter periodFormatter = getPeriodFormatter();
DateTime earliestAllowedFolderTime = getEarliestAllowedFolderTime(currentTime, periodFormatter);
DateTime latestAllowedFolderTime = getLatestAllowedFolderTime(currentTime, periodFormatter);
if (folderTime.isBefore(earliestAllowedFolderTime)) {
log.info(String.format("Folder time for %s is %s, earlier than the earliest allowed folder time, %s. Skipping",
inputFolder, folderTime, earliestAllowedFolderTime));
return false;
} else if (folderTime.isAfter(latestAllowedFolderTime)) {
log.info(String.format("Folder time for %s is %s, later than the latest allowed folder time, %s. Skipping",
inputFolder, folderTime, latestAllowedFolderTime));
return false;
} else {
return true;
}
} | java | protected boolean folderWithinAllowedPeriod(Path inputFolder, DateTime folderTime) {
DateTime currentTime = new DateTime(this.timeZone);
PeriodFormatter periodFormatter = getPeriodFormatter();
DateTime earliestAllowedFolderTime = getEarliestAllowedFolderTime(currentTime, periodFormatter);
DateTime latestAllowedFolderTime = getLatestAllowedFolderTime(currentTime, periodFormatter);
if (folderTime.isBefore(earliestAllowedFolderTime)) {
log.info(String.format("Folder time for %s is %s, earlier than the earliest allowed folder time, %s. Skipping",
inputFolder, folderTime, earliestAllowedFolderTime));
return false;
} else if (folderTime.isAfter(latestAllowedFolderTime)) {
log.info(String.format("Folder time for %s is %s, later than the latest allowed folder time, %s. Skipping",
inputFolder, folderTime, latestAllowedFolderTime));
return false;
} else {
return true;
}
} | [
"protected",
"boolean",
"folderWithinAllowedPeriod",
"(",
"Path",
"inputFolder",
",",
"DateTime",
"folderTime",
")",
"{",
"DateTime",
"currentTime",
"=",
"new",
"DateTime",
"(",
"this",
".",
"timeZone",
")",
";",
"PeriodFormatter",
"periodFormatter",
"=",
"getPeriodFormatter",
"(",
")",
";",
"DateTime",
"earliestAllowedFolderTime",
"=",
"getEarliestAllowedFolderTime",
"(",
"currentTime",
",",
"periodFormatter",
")",
";",
"DateTime",
"latestAllowedFolderTime",
"=",
"getLatestAllowedFolderTime",
"(",
"currentTime",
",",
"periodFormatter",
")",
";",
"if",
"(",
"folderTime",
".",
"isBefore",
"(",
"earliestAllowedFolderTime",
")",
")",
"{",
"log",
".",
"info",
"(",
"String",
".",
"format",
"(",
"\"Folder time for %s is %s, earlier than the earliest allowed folder time, %s. Skipping\"",
",",
"inputFolder",
",",
"folderTime",
",",
"earliestAllowedFolderTime",
")",
")",
";",
"return",
"false",
";",
"}",
"else",
"if",
"(",
"folderTime",
".",
"isAfter",
"(",
"latestAllowedFolderTime",
")",
")",
"{",
"log",
".",
"info",
"(",
"String",
".",
"format",
"(",
"\"Folder time for %s is %s, later than the latest allowed folder time, %s. Skipping\"",
",",
"inputFolder",
",",
"folderTime",
",",
"latestAllowedFolderTime",
")",
")",
";",
"return",
"false",
";",
"}",
"else",
"{",
"return",
"true",
";",
"}",
"}"
] | Return true iff input folder time is between compaction.timebased.min.time.ago and
compaction.timebased.max.time.ago. | [
"Return",
"true",
"iff",
"input",
"folder",
"time",
"is",
"between",
"compaction",
".",
"timebased",
".",
"min",
".",
"time",
".",
"ago",
"and",
"compaction",
".",
"timebased",
".",
"max",
".",
"time",
".",
"ago",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-compaction/src/main/java/org/apache/gobblin/compaction/dataset/TimeBasedSubDirDatasetsFinder.java#L220-L237 |
25,896 | apache/incubator-gobblin | gobblin-compaction/src/main/java/org/apache/gobblin/compaction/verify/CompactionThresholdVerifier.java | CompactionThresholdVerifier.verify | public Result verify (FileSystemDataset dataset) {
Map<String, Double> thresholdMap = RecompactionConditionBasedOnRatio.
getDatasetRegexAndRecompactThreshold (state.getProp(MRCompactor.COMPACTION_LATEDATA_THRESHOLD_FOR_RECOMPACT_PER_DATASET,
StringUtils.EMPTY));
CompactionPathParser.CompactionParserResult result = new CompactionPathParser(state).parse(dataset);
double threshold = RecompactionConditionBasedOnRatio.getRatioThresholdByDatasetName(result.getDatasetName(), thresholdMap);
log.debug ("Threshold is {} for dataset {}", threshold, result.getDatasetName());
InputRecordCountHelper helper = new InputRecordCountHelper(state);
try {
double newRecords = helper.calculateRecordCount (Lists.newArrayList(new Path(dataset.datasetURN())));
double oldRecords = helper.readRecordCount (new Path(result.getDstAbsoluteDir()));
if (oldRecords == 0) {
return new Result(true, "");
}
if ((newRecords - oldRecords) / oldRecords > threshold) {
log.debug ("Dataset {} records exceeded the threshold {}", dataset.datasetURN(), threshold);
return new Result(true, "");
}
return new Result(false, String.format("%s is failed for dataset %s. Prev=%f, Cur=%f, not reaching to threshold %f", this.getName(), result.getDatasetName(), oldRecords, newRecords, threshold));
} catch (IOException e) {
return new Result(false, ExceptionUtils.getFullStackTrace(e));
}
} | java | public Result verify (FileSystemDataset dataset) {
Map<String, Double> thresholdMap = RecompactionConditionBasedOnRatio.
getDatasetRegexAndRecompactThreshold (state.getProp(MRCompactor.COMPACTION_LATEDATA_THRESHOLD_FOR_RECOMPACT_PER_DATASET,
StringUtils.EMPTY));
CompactionPathParser.CompactionParserResult result = new CompactionPathParser(state).parse(dataset);
double threshold = RecompactionConditionBasedOnRatio.getRatioThresholdByDatasetName(result.getDatasetName(), thresholdMap);
log.debug ("Threshold is {} for dataset {}", threshold, result.getDatasetName());
InputRecordCountHelper helper = new InputRecordCountHelper(state);
try {
double newRecords = helper.calculateRecordCount (Lists.newArrayList(new Path(dataset.datasetURN())));
double oldRecords = helper.readRecordCount (new Path(result.getDstAbsoluteDir()));
if (oldRecords == 0) {
return new Result(true, "");
}
if ((newRecords - oldRecords) / oldRecords > threshold) {
log.debug ("Dataset {} records exceeded the threshold {}", dataset.datasetURN(), threshold);
return new Result(true, "");
}
return new Result(false, String.format("%s is failed for dataset %s. Prev=%f, Cur=%f, not reaching to threshold %f", this.getName(), result.getDatasetName(), oldRecords, newRecords, threshold));
} catch (IOException e) {
return new Result(false, ExceptionUtils.getFullStackTrace(e));
}
} | [
"public",
"Result",
"verify",
"(",
"FileSystemDataset",
"dataset",
")",
"{",
"Map",
"<",
"String",
",",
"Double",
">",
"thresholdMap",
"=",
"RecompactionConditionBasedOnRatio",
".",
"getDatasetRegexAndRecompactThreshold",
"(",
"state",
".",
"getProp",
"(",
"MRCompactor",
".",
"COMPACTION_LATEDATA_THRESHOLD_FOR_RECOMPACT_PER_DATASET",
",",
"StringUtils",
".",
"EMPTY",
")",
")",
";",
"CompactionPathParser",
".",
"CompactionParserResult",
"result",
"=",
"new",
"CompactionPathParser",
"(",
"state",
")",
".",
"parse",
"(",
"dataset",
")",
";",
"double",
"threshold",
"=",
"RecompactionConditionBasedOnRatio",
".",
"getRatioThresholdByDatasetName",
"(",
"result",
".",
"getDatasetName",
"(",
")",
",",
"thresholdMap",
")",
";",
"log",
".",
"debug",
"(",
"\"Threshold is {} for dataset {}\"",
",",
"threshold",
",",
"result",
".",
"getDatasetName",
"(",
")",
")",
";",
"InputRecordCountHelper",
"helper",
"=",
"new",
"InputRecordCountHelper",
"(",
"state",
")",
";",
"try",
"{",
"double",
"newRecords",
"=",
"helper",
".",
"calculateRecordCount",
"(",
"Lists",
".",
"newArrayList",
"(",
"new",
"Path",
"(",
"dataset",
".",
"datasetURN",
"(",
")",
")",
")",
")",
";",
"double",
"oldRecords",
"=",
"helper",
".",
"readRecordCount",
"(",
"new",
"Path",
"(",
"result",
".",
"getDstAbsoluteDir",
"(",
")",
")",
")",
";",
"if",
"(",
"oldRecords",
"==",
"0",
")",
"{",
"return",
"new",
"Result",
"(",
"true",
",",
"\"\"",
")",
";",
"}",
"if",
"(",
"(",
"newRecords",
"-",
"oldRecords",
")",
"/",
"oldRecords",
">",
"threshold",
")",
"{",
"log",
".",
"debug",
"(",
"\"Dataset {} records exceeded the threshold {}\"",
",",
"dataset",
".",
"datasetURN",
"(",
")",
",",
"threshold",
")",
";",
"return",
"new",
"Result",
"(",
"true",
",",
"\"\"",
")",
";",
"}",
"return",
"new",
"Result",
"(",
"false",
",",
"String",
".",
"format",
"(",
"\"%s is failed for dataset %s. Prev=%f, Cur=%f, not reaching to threshold %f\"",
",",
"this",
".",
"getName",
"(",
")",
",",
"result",
".",
"getDatasetName",
"(",
")",
",",
"oldRecords",
",",
"newRecords",
",",
"threshold",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"return",
"new",
"Result",
"(",
"false",
",",
"ExceptionUtils",
".",
"getFullStackTrace",
"(",
"e",
")",
")",
";",
"}",
"}"
] | There are two record count we are comparing here
1) The new record count in the input folder
2) The record count we compacted previously from last run
Calculate two numbers difference and compare with a predefined threshold.
(Alternatively we can save the previous record count to a state store. However each input
folder is a dataset. We may end up with loading too many redundant job level state for each
dataset. To avoid scalability issue, we choose a stateless approach where each dataset tracks
record count by themselves and persist it in the file system)
@return true iff the difference exceeds the threshold or this is the first time compaction | [
"There",
"are",
"two",
"record",
"count",
"we",
"are",
"comparing",
"here",
"1",
")",
"The",
"new",
"record",
"count",
"in",
"the",
"input",
"folder",
"2",
")",
"The",
"record",
"count",
"we",
"compacted",
"previously",
"from",
"last",
"run",
"Calculate",
"two",
"numbers",
"difference",
"and",
"compare",
"with",
"a",
"predefined",
"threshold",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-compaction/src/main/java/org/apache/gobblin/compaction/verify/CompactionThresholdVerifier.java#L64-L92 |
25,897 | apache/incubator-gobblin | gobblin-data-management/src/main/java/org/apache/gobblin/data/management/retention/policy/RawDatasetRetentionPolicy.java | RawDatasetRetentionPolicy.listQualifiedRawFileSystemDatasetVersions | protected Collection<FileSystemDatasetVersion> listQualifiedRawFileSystemDatasetVersions(Collection<FileSystemDatasetVersion> allVersions) {
return Lists.newArrayList(Collections2.filter(allVersions, new Predicate<FileSystemDatasetVersion>() {
@Override
public boolean apply(FileSystemDatasetVersion version) {
Iterable<Path> refinedDatasetPaths = getRefinedDatasetPaths(version);
try {
Optional<Long> latestRawDatasetModTime = getLatestModTime(version.getPaths());
Optional<Long> latestRefinedDatasetModTime = getLatestModTime(refinedDatasetPaths);
return latestRawDatasetModTime.isPresent() && latestRefinedDatasetModTime.isPresent()
&& latestRawDatasetModTime.get() <= latestRefinedDatasetModTime.get();
} catch (IOException e) {
throw new RuntimeException("Failed to get modification time", e);
}
}
}));
} | java | protected Collection<FileSystemDatasetVersion> listQualifiedRawFileSystemDatasetVersions(Collection<FileSystemDatasetVersion> allVersions) {
return Lists.newArrayList(Collections2.filter(allVersions, new Predicate<FileSystemDatasetVersion>() {
@Override
public boolean apply(FileSystemDatasetVersion version) {
Iterable<Path> refinedDatasetPaths = getRefinedDatasetPaths(version);
try {
Optional<Long> latestRawDatasetModTime = getLatestModTime(version.getPaths());
Optional<Long> latestRefinedDatasetModTime = getLatestModTime(refinedDatasetPaths);
return latestRawDatasetModTime.isPresent() && latestRefinedDatasetModTime.isPresent()
&& latestRawDatasetModTime.get() <= latestRefinedDatasetModTime.get();
} catch (IOException e) {
throw new RuntimeException("Failed to get modification time", e);
}
}
}));
} | [
"protected",
"Collection",
"<",
"FileSystemDatasetVersion",
">",
"listQualifiedRawFileSystemDatasetVersions",
"(",
"Collection",
"<",
"FileSystemDatasetVersion",
">",
"allVersions",
")",
"{",
"return",
"Lists",
".",
"newArrayList",
"(",
"Collections2",
".",
"filter",
"(",
"allVersions",
",",
"new",
"Predicate",
"<",
"FileSystemDatasetVersion",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"apply",
"(",
"FileSystemDatasetVersion",
"version",
")",
"{",
"Iterable",
"<",
"Path",
">",
"refinedDatasetPaths",
"=",
"getRefinedDatasetPaths",
"(",
"version",
")",
";",
"try",
"{",
"Optional",
"<",
"Long",
">",
"latestRawDatasetModTime",
"=",
"getLatestModTime",
"(",
"version",
".",
"getPaths",
"(",
")",
")",
";",
"Optional",
"<",
"Long",
">",
"latestRefinedDatasetModTime",
"=",
"getLatestModTime",
"(",
"refinedDatasetPaths",
")",
";",
"return",
"latestRawDatasetModTime",
".",
"isPresent",
"(",
")",
"&&",
"latestRefinedDatasetModTime",
".",
"isPresent",
"(",
")",
"&&",
"latestRawDatasetModTime",
".",
"get",
"(",
")",
"<=",
"latestRefinedDatasetModTime",
".",
"get",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Failed to get modification time\"",
",",
"e",
")",
";",
"}",
"}",
"}",
")",
")",
";",
"}"
] | A raw dataset version is qualified to be deleted, iff the corresponding refined paths exist, and the latest
mod time of all files is in the raw dataset is earlier than the latest mod time of all files in the refined paths. | [
"A",
"raw",
"dataset",
"version",
"is",
"qualified",
"to",
"be",
"deleted",
"iff",
"the",
"corresponding",
"refined",
"paths",
"exist",
"and",
"the",
"latest",
"mod",
"time",
"of",
"all",
"files",
"is",
"in",
"the",
"raw",
"dataset",
"is",
"earlier",
"than",
"the",
"latest",
"mod",
"time",
"of",
"all",
"files",
"in",
"the",
"refined",
"paths",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-data-management/src/main/java/org/apache/gobblin/data/management/retention/policy/RawDatasetRetentionPolicy.java#L73-L88 |
25,898 | apache/incubator-gobblin | gobblin-modules/gobblin-sql/src/main/java/org/apache/gobblin/converter/jdbc/AvroToJdbcEntryConverter.java | AvroToJdbcEntryConverter.convertSchema | @Override
public JdbcEntrySchema convertSchema(Schema inputSchema, WorkUnitState workUnit) throws SchemaConversionException {
LOG.info("Converting schema " + inputSchema);
Preconditions.checkArgument(Type.RECORD.equals(inputSchema.getType()),
"%s is expected for the first level element in Avro schema %s",
Type.RECORD, inputSchema);
Map<String, Type> avroColumnType = flatten(inputSchema);
String jsonStr = Preconditions.checkNotNull(workUnit.getProp(CONVERTER_AVRO_JDBC_DATE_FIELDS));
java.lang.reflect.Type typeOfMap = new TypeToken<Map<String, JdbcType>>() {}.getType();
Map<String, JdbcType> dateColumnMapping = new Gson().fromJson(jsonStr, typeOfMap);
LOG.info("Date column mapping: " + dateColumnMapping);
List<JdbcEntryMetaDatum> jdbcEntryMetaData = Lists.newArrayList();
for (Map.Entry<String, Type> avroEntry : avroColumnType.entrySet()) {
String colName = tryConvertAvroColNameToJdbcColName(avroEntry.getKey());
JdbcType JdbcType = dateColumnMapping.get(colName);
if (JdbcType == null) {
JdbcType = AVRO_TYPE_JDBC_TYPE_MAPPING.get(avroEntry.getValue());
}
Preconditions.checkNotNull(JdbcType, "Failed to convert " + avroEntry + " AVRO_TYPE_JDBC_TYPE_MAPPING: "
+ AVRO_TYPE_JDBC_TYPE_MAPPING + " , dateColumnMapping: " + dateColumnMapping);
jdbcEntryMetaData.add(new JdbcEntryMetaDatum(colName, JdbcType));
}
JdbcEntrySchema converted = new JdbcEntrySchema(jdbcEntryMetaData);
LOG.info("Converted schema into " + converted);
return converted;
} | java | @Override
public JdbcEntrySchema convertSchema(Schema inputSchema, WorkUnitState workUnit) throws SchemaConversionException {
LOG.info("Converting schema " + inputSchema);
Preconditions.checkArgument(Type.RECORD.equals(inputSchema.getType()),
"%s is expected for the first level element in Avro schema %s",
Type.RECORD, inputSchema);
Map<String, Type> avroColumnType = flatten(inputSchema);
String jsonStr = Preconditions.checkNotNull(workUnit.getProp(CONVERTER_AVRO_JDBC_DATE_FIELDS));
java.lang.reflect.Type typeOfMap = new TypeToken<Map<String, JdbcType>>() {}.getType();
Map<String, JdbcType> dateColumnMapping = new Gson().fromJson(jsonStr, typeOfMap);
LOG.info("Date column mapping: " + dateColumnMapping);
List<JdbcEntryMetaDatum> jdbcEntryMetaData = Lists.newArrayList();
for (Map.Entry<String, Type> avroEntry : avroColumnType.entrySet()) {
String colName = tryConvertAvroColNameToJdbcColName(avroEntry.getKey());
JdbcType JdbcType = dateColumnMapping.get(colName);
if (JdbcType == null) {
JdbcType = AVRO_TYPE_JDBC_TYPE_MAPPING.get(avroEntry.getValue());
}
Preconditions.checkNotNull(JdbcType, "Failed to convert " + avroEntry + " AVRO_TYPE_JDBC_TYPE_MAPPING: "
+ AVRO_TYPE_JDBC_TYPE_MAPPING + " , dateColumnMapping: " + dateColumnMapping);
jdbcEntryMetaData.add(new JdbcEntryMetaDatum(colName, JdbcType));
}
JdbcEntrySchema converted = new JdbcEntrySchema(jdbcEntryMetaData);
LOG.info("Converted schema into " + converted);
return converted;
} | [
"@",
"Override",
"public",
"JdbcEntrySchema",
"convertSchema",
"(",
"Schema",
"inputSchema",
",",
"WorkUnitState",
"workUnit",
")",
"throws",
"SchemaConversionException",
"{",
"LOG",
".",
"info",
"(",
"\"Converting schema \"",
"+",
"inputSchema",
")",
";",
"Preconditions",
".",
"checkArgument",
"(",
"Type",
".",
"RECORD",
".",
"equals",
"(",
"inputSchema",
".",
"getType",
"(",
")",
")",
",",
"\"%s is expected for the first level element in Avro schema %s\"",
",",
"Type",
".",
"RECORD",
",",
"inputSchema",
")",
";",
"Map",
"<",
"String",
",",
"Type",
">",
"avroColumnType",
"=",
"flatten",
"(",
"inputSchema",
")",
";",
"String",
"jsonStr",
"=",
"Preconditions",
".",
"checkNotNull",
"(",
"workUnit",
".",
"getProp",
"(",
"CONVERTER_AVRO_JDBC_DATE_FIELDS",
")",
")",
";",
"java",
".",
"lang",
".",
"reflect",
".",
"Type",
"typeOfMap",
"=",
"new",
"TypeToken",
"<",
"Map",
"<",
"String",
",",
"JdbcType",
">",
">",
"(",
")",
"{",
"}",
".",
"getType",
"(",
")",
";",
"Map",
"<",
"String",
",",
"JdbcType",
">",
"dateColumnMapping",
"=",
"new",
"Gson",
"(",
")",
".",
"fromJson",
"(",
"jsonStr",
",",
"typeOfMap",
")",
";",
"LOG",
".",
"info",
"(",
"\"Date column mapping: \"",
"+",
"dateColumnMapping",
")",
";",
"List",
"<",
"JdbcEntryMetaDatum",
">",
"jdbcEntryMetaData",
"=",
"Lists",
".",
"newArrayList",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"Type",
">",
"avroEntry",
":",
"avroColumnType",
".",
"entrySet",
"(",
")",
")",
"{",
"String",
"colName",
"=",
"tryConvertAvroColNameToJdbcColName",
"(",
"avroEntry",
".",
"getKey",
"(",
")",
")",
";",
"JdbcType",
"JdbcType",
"=",
"dateColumnMapping",
".",
"get",
"(",
"colName",
")",
";",
"if",
"(",
"JdbcType",
"==",
"null",
")",
"{",
"JdbcType",
"=",
"AVRO_TYPE_JDBC_TYPE_MAPPING",
".",
"get",
"(",
"avroEntry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"Preconditions",
".",
"checkNotNull",
"(",
"JdbcType",
",",
"\"Failed to convert \"",
"+",
"avroEntry",
"+",
"\" AVRO_TYPE_JDBC_TYPE_MAPPING: \"",
"+",
"AVRO_TYPE_JDBC_TYPE_MAPPING",
"+",
"\" , dateColumnMapping: \"",
"+",
"dateColumnMapping",
")",
";",
"jdbcEntryMetaData",
".",
"add",
"(",
"new",
"JdbcEntryMetaDatum",
"(",
"colName",
",",
"JdbcType",
")",
")",
";",
"}",
"JdbcEntrySchema",
"converted",
"=",
"new",
"JdbcEntrySchema",
"(",
"jdbcEntryMetaData",
")",
";",
"LOG",
".",
"info",
"(",
"\"Converted schema into \"",
"+",
"converted",
")",
";",
"return",
"converted",
";",
"}"
] | Converts Avro schema to JdbcEntrySchema.
Few precondition to the Avro schema
1. Avro schema should have one entry type record at first depth.
2. Avro schema can recurse by having record inside record.
3. Supported Avro primitive types and conversion
boolean --> java.lang.Boolean
int --> java.lang.Integer
long --> java.lang.Long or java.sql.Date , java.sql.Time , java.sql.Timestamp
float --> java.lang.Float
double --> java.lang.Double
bytes --> byte[]
string --> java.lang.String
null: only allowed if it's within union (see complex types for more details)
4. Supported Avro complex types
Records: Supports nested record type as well.
Enum --> java.lang.String
Unions --> Only allowed if it have one primitive type in it, along with Record type, or null type with one primitive type where null will be ignored.
Once Union is narrowed down to one primitive type, it will follow conversion of primitive type above.
{@inheritDoc}
5. In order to make conversion from Avro long type to java.sql.Date or java.sql.Time or java.sql.Timestamp,
converter will get table metadata from JDBC.
6. As it needs JDBC connection from condition 5, it also assumes that it will use JDBC publisher where it will get connection information from.
7. Conversion assumes that both schema, Avro and JDBC, uses same column name where name space in Avro is ignored.
For case sensitivity, Avro is case sensitive where it differs in JDBC based on underlying database. As Avro is case sensitive, column name equality also take case sensitive in to account.
@see org.apache.gobblin.converter.Converter#convertSchema(java.lang.Object, org.apache.gobblin.configuration.WorkUnitState) | [
"Converts",
"Avro",
"schema",
"to",
"JdbcEntrySchema",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-sql/src/main/java/org/apache/gobblin/converter/jdbc/AvroToJdbcEntryConverter.java#L176-L205 |
25,899 | apache/incubator-gobblin | gobblin-modules/gobblin-sql/src/main/java/org/apache/gobblin/converter/jdbc/AvroToJdbcEntryConverter.java | AvroToJdbcEntryConverter.tryConvertAvroColNameToJdbcColName | private String tryConvertAvroColNameToJdbcColName(String avroColName) {
if (!avroToJdbcColPairs.isPresent()) {
String converted = avroColName.replaceAll(AVRO_NESTED_COLUMN_DELIMITER_REGEX_COMPATIBLE, JDBC_FLATTENED_COLUMN_DELIMITER);
jdbcToAvroColPairs.put(converted, avroColName);
return converted;
}
String converted = avroToJdbcColPairs.get().get(avroColName);
converted = converted != null ? converted : avroColName;
jdbcToAvroColPairs.put(converted, avroColName);
return converted;
} | java | private String tryConvertAvroColNameToJdbcColName(String avroColName) {
if (!avroToJdbcColPairs.isPresent()) {
String converted = avroColName.replaceAll(AVRO_NESTED_COLUMN_DELIMITER_REGEX_COMPATIBLE, JDBC_FLATTENED_COLUMN_DELIMITER);
jdbcToAvroColPairs.put(converted, avroColName);
return converted;
}
String converted = avroToJdbcColPairs.get().get(avroColName);
converted = converted != null ? converted : avroColName;
jdbcToAvroColPairs.put(converted, avroColName);
return converted;
} | [
"private",
"String",
"tryConvertAvroColNameToJdbcColName",
"(",
"String",
"avroColName",
")",
"{",
"if",
"(",
"!",
"avroToJdbcColPairs",
".",
"isPresent",
"(",
")",
")",
"{",
"String",
"converted",
"=",
"avroColName",
".",
"replaceAll",
"(",
"AVRO_NESTED_COLUMN_DELIMITER_REGEX_COMPATIBLE",
",",
"JDBC_FLATTENED_COLUMN_DELIMITER",
")",
";",
"jdbcToAvroColPairs",
".",
"put",
"(",
"converted",
",",
"avroColName",
")",
";",
"return",
"converted",
";",
"}",
"String",
"converted",
"=",
"avroToJdbcColPairs",
".",
"get",
"(",
")",
".",
"get",
"(",
"avroColName",
")",
";",
"converted",
"=",
"converted",
"!=",
"null",
"?",
"converted",
":",
"avroColName",
";",
"jdbcToAvroColPairs",
".",
"put",
"(",
"converted",
",",
"avroColName",
")",
";",
"return",
"converted",
";",
"}"
] | Convert Avro column name to JDBC column name. If name mapping is defined, follow it. Otherwise, just return avro column name,
while replacing nested column delimiter, dot, to underscore.
This method also updates, mapping from JDBC column name to Avro column name for reverse look up.
@param avroColName
@return | [
"Convert",
"Avro",
"column",
"name",
"to",
"JDBC",
"column",
"name",
".",
"If",
"name",
"mapping",
"is",
"defined",
"follow",
"it",
".",
"Otherwise",
"just",
"return",
"avro",
"column",
"name",
"while",
"replacing",
"nested",
"column",
"delimiter",
"dot",
"to",
"underscore",
".",
"This",
"method",
"also",
"updates",
"mapping",
"from",
"JDBC",
"column",
"name",
"to",
"Avro",
"column",
"name",
"for",
"reverse",
"look",
"up",
"."
] | f029b4c0fea0fe4aa62f36dda2512344ff708bae | https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-sql/src/main/java/org/apache/gobblin/converter/jdbc/AvroToJdbcEntryConverter.java#L214-L225 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.