Binary Search on Variable-Length Text Files

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Conventional binary search techniques are inadequate for text files with lines of varying lengths, and generating binary trees for such files can be difficult, especially in dynamic environments like log files where data is frequently added or updated.

Innovation Solution

A search device that sets up a binary search range within a text file by initializing a predecessor and successor length, calculates a middle position, acquires a middle line from the text file, and adjusts the search range based on key comparisons to efficiently find matching patterns across lines of different lengths.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Productivity

If conventional binary search is applied to text files with lines of varying lengths, then the search can be performed, but the search efficiency deteriorates because the data pieces are not of equal data size

Engineering Contradiction:
Improvesearch efficiencyVSAvoidadaptability to variable line lengths
Core Design Contradiction:
ProductivityVSAdaptability or versatility

Solution Approach 1:

The patent changes the parameter of data size uniformity by introducing a virtual transformation that maps variable-length lines to a standardized representation. Each line is associated with a virtual position and the search algorithm operates on these virtual positions rather than actual byte offsets, enabling binary search to work correctly with lines of different lengths.

Inventive Principle:
Principle #35Parameter changes

Solution Approach 2:

The patent introduces a virtual coordinate system as an intermediary between the physical file structure and the search algorithm. This virtual system assigns logical positions to lines based on their order in the file, allowing the binary search to operate on these logical positions rather than directly on the variable-length byte sequences, thus resolving the incompatibility between fixed binary search and variable line lengths.

Inventive Principle:
Principle #24Intermediary (Mediator)

2Speed

If binary trees are generated for text data to enable fast search, then search speed improves, but the device complexity increases and it becomes difficult to handle dynamic or large files

Engineering Contradiction:
Improvesearch speedVSAvoidcomplexity of binary tree generation
Core Design Contradiction:
SpeedVSDevice complexity

Solution Approach 1:

The patent extracts the essential ordering information from the text file (the sequence of lines sorted by key) and represents it using a simple virtual coordinate system rather than constructing a complex binary tree structure. This extraction approach retains the sorted order needed for binary search while avoiding the overhead of tree construction, maintenance, and traversal.

Inventive Principle:
Principle #2Taking out (Extraction)

Solution Approach 2:

Instead of creating a physical copy of the data structure (binary tree) that would require significant memory and processing resources, the patent creates a virtual representation using mathematical coordinate transformations. This virtual copying approach allows binary search to proceed without actually constructing or storing a tree structure, thereby maintaining search speed while dramatically reducing complexity.

Inventive Principle:
Principle #26Copying

Data Source

PatentUS11645040B2Text file binary search device, search method, program, and information recording medium
Publication Date: 2023.05.09 RAKUTEN GROUP INC
  • US11645040B2 patent drawing
  • US11645040B2 patent drawing
  • US11645040B2 patent drawing

AI summary

A device searches a file being recorded that includes lines sorted in accordance with keys included in the lines to find a line that matches a pattern. When the device receives a pattern, it initializes upper and lower limits of a search range and calculates a middle position between the limits. It acquires, from the file, a middle line that starts at or before the middle position and ends after it. If the key included in the middle line matches the pattern, it outputs the middle line and re-sets the upper or lower limit based on whether the key included in the middle line is greater or less than the pattern and, if there is a distance greater than a length of a newline between the limits, repeats the procedure starting from the middle position. Otherwise, it outputs a result to the effect that no matching line has been found.