mirror of
https://github.com/datahub-project/datahub.git
synced 2025-08-18 06:06:55 +00:00
Remove unused Elasticsearch util classes
This commit is contained in:
parent
216e24c164
commit
fa8f8bbdaf
@ -1,86 +0,0 @@
|
||||
package com.linkedin.metadata.utils.elasticsearch;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.annotation.Nonnull;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
|
||||
public class ElasticsearchUtil {
|
||||
|
||||
public enum AccessCountType {
|
||||
LOW, MEDIUM, HIGH
|
||||
}
|
||||
// TODO: Move these to config eventually
|
||||
static final Map<String, Character> PLATFORM_DELIMITER_MAP = ImmutableMap.<String, Character>builder()
|
||||
.put("ambry", '.')
|
||||
.put("couchbase", '.')
|
||||
.put("dalids", '.')
|
||||
.put("espresso", '.')
|
||||
.put("external", '.')
|
||||
.put("followfeed", '.')
|
||||
.put("hdfs", '/')
|
||||
.put("hive", '.')
|
||||
.put("kafka", '.')
|
||||
.put("kafka-lc", '.')
|
||||
.put("mongo", '.')
|
||||
.put("mysql", '.')
|
||||
.put("oracle", '.')
|
||||
.put("pinot", '.')
|
||||
.put("presto", '.')
|
||||
.put("seas-cloud", '.')
|
||||
.put("seas-deployed", '/')
|
||||
.put("seas-hdfs", '/')
|
||||
.put("teradata", '.')
|
||||
.put("ump", '.')
|
||||
.put("vector", '.')
|
||||
.put("venice", '.')
|
||||
.put("voldemort", '.')
|
||||
.build();
|
||||
|
||||
private ElasticsearchUtil() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a dataset name, extract the prefix
|
||||
*
|
||||
* @param datasetName name of the dataset
|
||||
* @return prefix name from the dataset name
|
||||
*/
|
||||
@Nonnull
|
||||
public static String getPrefixFromDatasetName(@Nonnull String datasetName) {
|
||||
Pattern pattern = Pattern.compile("^(\\/.*?)[\\/].*");
|
||||
Matcher matcher = pattern.matcher(datasetName);
|
||||
if (matcher.matches()) {
|
||||
return matcher.group(1);
|
||||
}
|
||||
return StringUtils.substringBefore(datasetName, ".");
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static String constructPath(@Nonnull String dataOrigin, @Nonnull String platform, @Nonnull String dataset) {
|
||||
if (PLATFORM_DELIMITER_MAP.containsKey(platform)) {
|
||||
Character delimiter = PLATFORM_DELIMITER_MAP.get(platform);
|
||||
if (delimiter.equals('/')) {
|
||||
return "/" + dataOrigin + "/" + platform + dataset;
|
||||
}
|
||||
return ("/" + dataOrigin + "/" + platform + "/" + dataset).replace(delimiter, '/');
|
||||
}
|
||||
return "/" + dataOrigin + "/" + platform + "/" + dataset;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static AccessCountType getAccessType(long accessCount) {
|
||||
// TODO: move these ranges to a config file
|
||||
if (accessCount == 0) {
|
||||
return AccessCountType.LOW;
|
||||
} else if (accessCount > 10000) {
|
||||
return AccessCountType.HIGH;
|
||||
} else {
|
||||
return AccessCountType.MEDIUM;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
package com.linkedin.metadata.utils.elasticsearch;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.testng.Assert.*;
|
||||
|
||||
public class ElasticsearchUtilTest {
|
||||
|
||||
@Test
|
||||
public void testPrefixFromDatasetName() throws Exception {
|
||||
assertEquals(ElasticsearchUtil.getPrefixFromDatasetName("/jobs/act/takeout/follows/OTHER/empty_users_new"), "/jobs");
|
||||
assertEquals(ElasticsearchUtil.getPrefixFromDatasetName("tracking.pageviewevent"), "tracking");
|
||||
assertEquals(ElasticsearchUtil.getPrefixFromDatasetName("adAnalyticsEvent"), "adAnalyticsEvent");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testconstructPath() throws Exception {
|
||||
assertEquals(ElasticsearchUtil.constructPath("prod", "hdfs", "/user/shyland/u_shyland.db/sh_cp_9"), "/prod/hdfs/user/shyland/u_shyland.db/sh_cp_9");
|
||||
assertEquals(ElasticsearchUtil.constructPath("ei", "seas-deployed", "/foo/bar.baz"), "/ei/seas-deployed/foo/bar.baz");
|
||||
assertEquals(ElasticsearchUtil.constructPath("corp", "hive", "u_scxu.prefilled_skills"), "/corp/hive/u_scxu/prefilled_skills");
|
||||
assertEquals(ElasticsearchUtil.constructPath("prod", "pinot", "foo"), "/prod/pinot/foo");
|
||||
assertEquals(ElasticsearchUtil.constructPath("ei", "testPlatform", "foo"), "/ei/testPlatform/foo");
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user