[
https://issues.apache.org/jira/browse/AVRO-3001?focusedWorklogId=803099&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-803099
]
ASF GitHub Bot logged work on AVRO-3001:
----------------------------------------
Author: ASF GitHub Bot
Created on: 24/Aug/22 04:45
Start Date: 24/Aug/22 04:45
Worklog Time Spent: 10m
Work Description: rayokota commented on code in PR #1833:
URL: https://github.com/apache/avro/pull/1833#discussion_r953338257
##########
lang/csharp/src/apache/main/IO/Parsing/Parser.cs:
##########
@@ -0,0 +1,229 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Avro.IO.Parsing
+{
+ /// <summary>
+ /// Parser is the class that maintains the stack for parsing. This class
is used
+ /// by encoders, which are not required to skip.
+ /// </summary>
+ public class Parser
+ {
+ /// <summary>
+ /// The parser knows how to handle the terminal and non-terminal
symbols. But it
+ /// needs help from outside to handle implicit and explicit actions.
The clients
+ /// implement this interface to provide this help.
+ /// </summary>
+ public interface IActionHandler
+ {
+ /// <summary>
+ /// Handle the action symbol <tt>top</tt> when the <tt>input</tt>
is sought to be
+ /// taken off the stack.
+ /// </summary>
+ /// <param name="input"> The input symbol from the caller of
advance </param>
+ /// <param name="top"> The symbol at the top the stack. </param>
+ /// <returns> <tt>null</tt> if advance() is to continue processing
the stack. If
+ /// not <tt>null</tt> the return value will be returned by
advance(). </returns>
+ Symbol DoAction(Symbol input, Symbol top);
+ }
+
+ private readonly IActionHandler symbolHandler;
+ /// <summary>
+ /// Stack of symbols.
+ /// </summary>
+ protected Symbol[] Stack;
+ /// <summary>
+ /// Position of the stack.
+ /// </summary>
+ protected int Pos;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="Parser"/> class.
+ /// </summary>
+ public Parser(Symbol root, IActionHandler symbolHandler)
+ {
+ this.symbolHandler = symbolHandler;
+ this.Stack = new Symbol[5]; // Start small to make sure expansion
code works
+ this.Stack[0] = root;
+ this.Pos = 1;
+ }
+
+ /// <summary>
+ /// If there is no sufficient room in the stack, use this expand it.
+ /// </summary>
+ private void expandStack()
+ {
+ Array.Resize(ref Stack, Stack.Length + Math.Max(Stack.Length,
1024));
+ }
+
+ /// <summary>
+ /// Recursively replaces the symbol at the top of the stack with its
production,
+ /// until the top is a terminal. Then checks if the top symbol matches
the
+ /// terminal symbol supplied <tt>terminal</tt>.
Review Comment:
Done
##########
lang/csharp/src/apache/main/IO/Parsing/SkipParser.cs:
##########
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System.Diagnostics;
+
+namespace Avro.IO.Parsing
+{
+ /// <summary>
+ /// A parser that capable of skipping as well read and write. This class
is used
+ /// by decoders who (unlink encoders) are required to implement methods to
skip.
Review Comment:
Done
Issue Time Tracking
-------------------
Worklog Id: (was: 803099)
Time Spent: 4.5h (was: 4h 20m)
> JsonEncode Decode support for C#
> --------------------------------
>
> Key: AVRO-3001
> URL: https://issues.apache.org/jira/browse/AVRO-3001
> Project: Apache Avro
> Issue Type: Improvement
> Components: csharp
> Affects Versions: 1.10.0, 1.11.0
> Reporter: Krishnan Unni
> Assignee: Robert Yokota
> Priority: Major
> Labels: pull-request-available
> Time Spent: 4.5h
> Remaining Estimate: 0h
>
> The C# library for avro currently supports only the Binary encoding and also
> with compile time types (Generic support only). As part of a project I am
> doing I need to validate the avro schema against the incoming json data on
> the fly without a predefined type (generated class). So basically comparing
> an avro schema (string/json representation) against a raw json string. It is
> possible with the Java library since it supports both non generic types and
> streams as well as json encoding. With C# currently this is not possible. Is
> there a plan to extend the C# library to provide these features? If yes, is
> there a timeline? If not is there any alternative to achieve this?
--
This message was sent by Atlassian Jira
(v8.20.10#820010)