You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2018/12/10 20:53:00 UTC

[jira] [Commented] (AVRO-2007) for avro-c enable getting enum size (i.e. number of symbols at enum schema)

    [ https://issues.apache.org/jira/browse/AVRO-2007?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16715543#comment-16715543 ] 

ASF GitHub Bot commented on AVRO-2007:
--------------------------------------

dkulp closed pull request #167:  AVRO-2007: enable getting schema enum size (i.e. number of symbols at enum schema). 
URL: https://github.com/apache/avro/pull/167
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/lang/c/src/avro/schema.h b/lang/c/src/avro/schema.h
index 41dd8ea48..0c67deda8 100644
--- a/lang/c/src/avro/schema.h
+++ b/lang/c/src/avro/schema.h
@@ -61,6 +61,7 @@ int avro_schema_enum_get_by_name(const avro_schema_t enump,
 				 const char *symbol_name);
 int avro_schema_enum_symbol_append(const avro_schema_t
 				   enump, const char *symbol);
+size_t avro_schema_enum_size(const avro_schema_t enump);
 
 avro_schema_t avro_schema_fixed(const char *name, const int64_t len);
 avro_schema_t avro_schema_fixed_ns(const char *name, const char *space,
diff --git a/lang/c/src/schema.c b/lang/c/src/schema.c
index 3ade1140e..f1968e1e3 100644
--- a/lang/c/src/schema.c
+++ b/lang/c/src/schema.c
@@ -574,6 +574,11 @@ avro_schema_enum_symbol_append(const avro_schema_t enum_schema,
 	return 0;
 }
 
+size_t avro_schema_enum_size( const avro_schema_t enump )
+{
+	return avro_schema_to_enum(enump)->symbols->num_entries;
+}
+
 int
 avro_schema_record_field_append(const avro_schema_t record_schema,
 				const char *field_name,


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> for avro-c enable getting enum size (i.e. number of symbols at enum schema)
> ---------------------------------------------------------------------------
>
>                 Key: AVRO-2007
>                 URL: https://issues.apache.org/jira/browse/AVRO-2007
>             Project: Apache Avro
>          Issue Type: Improvement
>          Components: c
>    Affects Versions: 1.8.1
>            Reporter: Eliyahu Machluf
>            Priority: Minor
>             Fix For: 1.9.0
>
>
> Avro-c library stores internaly enum as int value, there is no validation, when setting an enum value, it match the schema.
> Therefore, I want to enable getting enum size (i.e. number of symbols at enum schema), in order to enable validating (when using the instance) that the value is at enum range.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)