-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: supports meta join in agg (#794)
- Loading branch information
Showing
17 changed files
with
352 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
server/agg/agg-core/src/main/java/io/holoinsight/server/agg/v1/core/conf/JoinMeta.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. | ||
*/ | ||
package io.holoinsight.server.agg.v1.core.conf; | ||
|
||
import java.util.Map; | ||
|
||
import lombok.Data; | ||
|
||
/** | ||
* <p> | ||
* created at 2024/1/10 | ||
* | ||
* @author xzchaoo | ||
*/ | ||
@Data | ||
public class JoinMeta { | ||
private String metaTable; | ||
|
||
/** | ||
* <code> | ||
* { | ||
* "app": { | ||
* "type": "const", | ||
* "value: "foobar" | ||
* }, | ||
* "env": { | ||
* "type": "const", | ||
* "value": "PROD" | ||
* }, | ||
* "ip": { | ||
* "type": "tag", | ||
* "value": "ip" | ||
* } | ||
* } | ||
* </code> | ||
*/ | ||
private Map<String, Value> condition; | ||
|
||
/** | ||
* When no metadata is joined, whether to discard the current data | ||
*/ | ||
private boolean discardIfUnmatch; | ||
|
||
@Data | ||
public static class Value { | ||
/** | ||
* <ul> | ||
* <li>const: {@link #value} is a const</li> | ||
* <li>tag: {@link #value} is a tag name</li> | ||
* </ul> | ||
*/ | ||
private String type; | ||
private String value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...executor/src/main/java/io/holoinsight/server/agg/v1/executor/executor/AggMetaService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. | ||
*/ | ||
package io.holoinsight.server.agg.v1.executor.executor; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* <p> | ||
* created at 2024/1/10 | ||
* | ||
* @author xzchaoo | ||
*/ | ||
public interface AggMetaService { | ||
/** | ||
* | ||
* @param metaTable | ||
* @param condition | ||
* @return | ||
*/ | ||
List<Map<String, Object>> find(String metaTable, Map<String, Object> condition); | ||
} |
55 changes: 55 additions & 0 deletions
55
...utor/src/main/java/io/holoinsight/server/agg/v1/executor/executor/AggMetaServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. | ||
*/ | ||
package io.holoinsight.server.agg.v1.executor.executor; | ||
|
||
import java.time.Duration; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
import com.github.benmanes.caffeine.cache.Cache; | ||
import com.github.benmanes.caffeine.cache.Caffeine; | ||
|
||
import io.holoinsight.server.meta.common.model.QueryExample; | ||
import io.holoinsight.server.meta.facade.service.DataClientService; | ||
import lombok.Data; | ||
|
||
/** | ||
* <p> | ||
* created at 2024/1/11 | ||
* | ||
* @author xiangfeng.xzc | ||
*/ | ||
public class AggMetaServiceImpl implements AggMetaService { | ||
private DataClientService dataClientService; | ||
|
||
private Cache<CacheKey, List<Map<String, Object>>> cache = Caffeine.newBuilder() // | ||
.expireAfterWrite(Duration.ofMinutes(1)) // | ||
.softValues() // | ||
.build(); | ||
|
||
public AggMetaServiceImpl(DataClientService dataClientService) { | ||
this.dataClientService = Objects.requireNonNull(dataClientService); | ||
} | ||
|
||
@Override | ||
public List<Map<String, Object>> find(String metaTable, Map<String, Object> condition) { | ||
CacheKey cacheKey = new CacheKey(metaTable, condition); | ||
List<Map<String, Object>> cached = cache.getIfPresent(cacheKey); | ||
if (cached != null) { | ||
return cached; | ||
} | ||
QueryExample example = new QueryExample(); | ||
example.setParams(condition); | ||
List<Map<String, Object>> ret = dataClientService.queryByExample(metaTable, example); | ||
cache.put(cacheKey, ret); | ||
return ret; | ||
} | ||
|
||
@Data | ||
private static final class CacheKey { | ||
private final String metaTable; | ||
private final Map<String, Object> condition; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.