Skip to content

Commit

Permalink
feat: create partitions if needed
Browse files Browse the repository at this point in the history
Do not send create partition commands to the HSMC if partition already
exists. Reduces traffic on the HMS.
  • Loading branch information
giovtorres committed Dec 27, 2023
1 parent f47bf6c commit 35063a3
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.mcneilio.shokuyoku.driver;


import com.mcneilio.shokuyoku.util.PartitionManager;
import com.mcneilio.shokuyoku.util.Statsd;
import com.timgroup.statsd.StatsDClient;
import org.apache.hadoop.conf.Configuration;
Expand Down Expand Up @@ -154,7 +154,12 @@ public String flush(boolean deleteFile) {
if (storageDriver != null){
storageDriver.addFile(date, eventName, fileName, Paths.get(fileName));
}
//TODO: create hive partition

String s3_prefix = System.getenv("S3_PREFIX");
String prefix = s3_prefix.endsWith("/") ? s3_prefix : s3_prefix + "/";
String tablePath = "s3a://" + System.getenv("S3_BUCKET") + "/" + prefix + System.getenv("HIVE_DATABASE");
PartitionManager.createPartitionIfNeeded(tablePath, eventName, date);

if(deleteFile)
new File(fileName).delete();
this.fileName = null;
Expand Down

0 comments on commit 35063a3

Please sign in to comment.