>From Hussain Towaileb <[email protected]>:
Hussain Towaileb has uploaded this change for review. (
https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/17690 )
Change subject: [NO ISSUE][EXT]: Refactor external data prefix class
......................................................................
[NO ISSUE][EXT]: Refactor external data prefix class
Change-Id: I6305ae6f9cd1cf38a2299d8bd7fa21e80610bcc8
---
M
asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/ExternalDataPrefix.java
1 file changed, 29 insertions(+), 36 deletions(-)
git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb
refs/changes/90/17690/1
diff --git
a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/ExternalDataPrefix.java
b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/ExternalDataPrefix.java
index c2a047b..6b0cdb6 100644
---
a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/ExternalDataPrefix.java
+++
b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/ExternalDataPrefix.java
@@ -36,6 +36,7 @@
import org.apache.asterix.common.exceptions.CompilationException;
import org.apache.asterix.common.exceptions.ErrorCode;
import org.apache.asterix.om.types.ARecordType;
+import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.BuiltinTypeMap;
import org.apache.asterix.om.types.IAType;
@@ -52,11 +53,11 @@
private final ComputedFieldDetails computedFieldDetails;
public static final String PREFIX_ROOT_FIELD_NAME = "prefix-root";
- public static final Set<IAType> supportedTypes = new HashSet<>();
+ public static final Set<ATypeTag> supportedTypes = new HashSet<>();
static {
- supportedTypes.add(BuiltinType.ASTRING);
- supportedTypes.add(BuiltinType.AINT32);
+ supportedTypes.add(BuiltinType.ASTRING.getTypeTag());
+ supportedTypes.add(BuiltinType.AINT32.getTypeTag());
}
public ExternalDataPrefix(String prefix) throws AlgebricksException {
@@ -116,42 +117,25 @@
List<Integer> computedFieldIndexes = new ArrayList<>();
// check if there are any segments before doing any testing
- if (segments.size() != 0) {
+ if (!segments.isEmpty()) {
// search for computed fields in each segment
- Matcher matcher = COMPUTED_FIELD_PATTERN.matcher(segments.get(0));
- if (matcher.find()) {
- String computedField = matcher.group();
- String[] splits = computedField.split(":");
- String namePart = splits[0].substring(1);
- String typePart = splits[1].substring(0, splits[1].length() -
1);
+ Matcher matcher = COMPUTED_FIELD_PATTERN.matcher("");
+ for (int i = 0; i < segments.size(); i++) {
+ matcher.reset(segments.get(i));
- IAType type =
BuiltinTypeMap.getBuiltinType(typePart.substring(0, typePart.length() - 1));
- validateSupported(type);
+ while (matcher.find()) {
+ String computedField = matcher.group();
+ String[] splits = computedField.split(":");
+ String namePart = splits[0].substring(1);
+ String typePart = splits[1].substring(0,
splits[1].length() - 1);
- List<String> nameParts = List.of(namePart.substring(1,
segments.indexOf(":") - 1).split("\\."));
- computedFieldsNames.add(nameParts);
- computedFieldTypes.add(type);
- computedFieldIndexes.add(0);
- }
+ IAType type = BuiltinTypeMap.getBuiltinType(typePart);
+ validateSupported(type);
- if (segments.size() > 1) {
- for (int i = 1; i < segments.size(); i++) {
- matcher.reset(segments.get(i));
-
- while (matcher.find()) {
- String computedField = matcher.group();
- String[] splits = computedField.split(":");
- String namePart = splits[0].substring(1);
- String typePart = splits[1].substring(0,
splits[1].length() - 1);
-
- IAType type = BuiltinTypeMap.getBuiltinType(typePart);
- validateSupported(type);
-
- List<String> nameParts =
List.of(namePart.split("\\."));
- computedFieldsNames.add(nameParts);
- computedFieldTypes.add(type);
- computedFieldIndexes.add(i);
- }
+ List<String> nameParts = List.of(namePart.split("\\."));
+ computedFieldsNames.add(nameParts);
+ computedFieldTypes.add(type);
+ computedFieldIndexes.add(i);
}
}
}
@@ -204,7 +188,7 @@
* @return true if type is supported, false otherwise
*/
public static boolean isSupportedType(IAType type) {
- return supportedTypes.contains(type);
+ return supportedTypes.contains(type.getTypeTag());
}
public static class ComputedFieldDetails {
--
To view, visit https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/17690
To unsubscribe, or for help writing mail filters, visit
https://asterix-gerrit.ics.uci.edu/settings
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Change-Id: I6305ae6f9cd1cf38a2299d8bd7fa21e80610bcc8
Gerrit-Change-Number: 17690
Gerrit-PatchSet: 1
Gerrit-Owner: Hussain Towaileb <[email protected]>
Gerrit-MessageType: newchange