private void analyzeElements(
     DmdlSemantics environment,
     AstAttribute attribute,
     Map<String, AstAttributeElement> elements,
     HiveFieldTrait trait) {
   trait.setTimestampTypeInfo();
   environment.reportAll(AttributeUtil.reportInvalidElements(attribute, elements.values()));
 }
 @Override
 public void process(
     DmdlSemantics environment, ModelDeclaration declaration, AstAttribute attribute) {
   Map<String, AstAttributeElement> elements = AttributeUtil.getElementMap(attribute);
   Configuration conf = analyzeConfig(environment, attribute, elements);
   if (conf != null) {
     declaration.putTrait(TsvFormatTrait.class, new TsvFormatTrait(attribute, conf));
   }
 }
Esempio n. 3
0
 @Override
 public void process(
     DmdlSemantics environment, PropertyDeclaration declaration, AstAttribute attribute) {
   environment.reportAll(AttributeUtil.reportInvalidElements(attribute, attribute.elements));
   CsvFieldDriver.checkFieldType(environment, declaration, attribute, BasicTypeKind.TEXT);
   if (CsvFieldDriver.checkConflict(environment, declaration, attribute)) {
     declaration.putTrait(CsvFieldTrait.class, new CsvFieldTrait(attribute, Kind.FILE_NAME, null));
   }
 }
 @Override
 public void process(
     DmdlSemantics environment, PropertyDeclaration declaration, AstAttribute attribute) {
   if (Util.checkProperty(environment, declaration, attribute, HiveFieldTrait.TypeKind.TIMESTAMP)
       == false) {
     return;
   }
   HiveFieldTrait trait = HiveFieldTrait.get(declaration);
   trait.setOriginalAst(attribute, false);
   Map<String, AstAttributeElement> elements = AttributeUtil.getElementMap(attribute);
   analyzeElements(environment, attribute, elements, trait);
 }
  private Configuration analyzeConfig(
      DmdlSemantics environment,
      AstAttribute attribute,
      Map<String, AstAttributeElement> elements) {
    AstLiteral charset = take(environment, elements, ELEMENT_CHARSET_NAME, LiteralKind.STRING);
    AstLiteral header = take(environment, elements, ELEMENT_HAS_HEADER_NAME, LiteralKind.BOOLEAN);
    AstLiteral codec = take(environment, elements, ELEMENT_CODEC_NAME, LiteralKind.STRING);
    environment.reportAll(AttributeUtil.reportInvalidElements(attribute, elements.values()));

    Configuration result = new Configuration();
    if (charset != null && checkNotEmpty(environment, ELEMENT_CHARSET_NAME, charset)) {
      result.setCharsetName(charset.toStringValue());
    }
    if (header != null) {
      result.setEnableHeader(header.toBooleanValue());
    }
    if (codec != null && checkNotEmpty(environment, ELEMENT_CODEC_NAME, codec)) {
      result.setCodecName(codec.toStringValue());
    }
    return result;
  }