Stream Processing Number Comparison Using State Machine
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing number comparison methods in computers require conversion of ASCII representations to integer or decimal formats, which is time-consuming and inefficient, especially in stream processing applications where low latency is crucial, such as telecom call detail record processing.
Innovation Solution
A state machine-based method that compares numbers directly from their ASCII representation using a preset state transition table, generating an index from digit pairs and determining comparison results without converting the numbers, allowing for efficient comparison of large numbers by skipping leading zeros and handling decimal places and separators.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If numbers are converted from ASCII to integer/decimal format before comparison, then comparison can be performed using standard computer number formats, but the conversion process takes significant time
Solution Approach 1:
The patent extracts and compares only the necessary digit information directly from ASCII representations without converting the entire number to computer format. By extracting digit pairs and comparing them directly, the solution eliminates the time-consuming conversion step while maintaining comparison accuracy.
Solution Approach 2:
The patent replaces the mechanical conversion process (ASCII to integer/decimal transformation) with a direct comparison mechanism that operates on ASCII digit representations. This substitution eliminates the intermediate conversion step and achieves faster comparison results.
2Reliability
If traditional number conversion method is used, then comparison can be performed with standard computer number formats, but the processing time exceeds available time in stream processing applications
Solution Approach 1:
The patent segments the number comparison process into digit pair comparisons. Instead of converting entire numbers, it processes numbers as sequences of digits, comparing corresponding digit pairs from both numbers. This segmentation enables parallel processing and significantly reduces processing time while maintaining valid comparison results.
Solution Approach 2:
The patent performs preliminary preparation by pre-defining the comparison logic and state transition table before actual number comparison. This preliminary setup allows for rapid execution during stream processing without the need for time-consuming conversion operations at runtime.
3Ease of operation
If ASCII to number conversion is performed for range checking, then standard comparison operators can be used, but the time required for conversion prevents efficient stream processing
Solution Approach 1:
The patent extracts digit information directly from ASCII representations and performs range checking by comparing these extracted digits against predefined range boundaries. This extraction approach eliminates the need for full number conversion while maintaining the simplicity of comparison operations.
Solution Approach 2:
The patent introduces a state machine as an intermediary that manages the comparison process. The state machine transitions through defined states based on digit pair comparisons, providing a simple and efficient mechanism for range checking without requiring number conversion.
Data Source
AI summary
Embodiments of the invention provide a method and system for comparing a given number and a target number. The method comprises: generating a current index associated with the given number based on a current digit pair including a first current digit from the given number and a second current digit from the target number, and a current state information associated with the given number; looking up the generated current index in a preset state transition table to identify a next state information, wherein the preset state transition table maintains a plurality of mappings, each mapping is between an index and a next state information; if the current digit pair includes a last digit of any of the two numbers, determining a final comparison result based on the next state information; otherwise, taking on the next state information as the current state information for comparison of a next digit pair.


