File Name Query Using Binary Search in Pre-sorted Directory Blocks
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing file systems, such as those with hash tree and B+ tree structures, face inefficiencies in querying file names and low storage space utilization in read-only file systems, leading to slow query efficiency and suboptimal storage usage.
Innovation Solution
A data query method that uses binary search algorithms to determine the target directory block by sequentially arranging directory entries and file names in a preset order, allowing for efficient comparison and narrowing down the search range, thereby improving query speed and storage utilization.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Productivity
If hash tree structure with multi-level hash table is used, then file name storage is achieved, but query efficiency is low and storage space utilization is low
Solution Approach 1:
The patent pre-sorts file names in directory entries in ascending order before query operations. This preliminary arrangement enables efficient binary search during file name queries, eliminating the need to traverse all hash values sequentially. The pre-sorted state allows the system to quickly narrow down search ranges, significantly reducing query time while maintaining storage efficiency.
2Quantity of substance
If hash tree structure is used, then file name storage is achieved, but storage space utilization is low due to large quantity of hash values
Solution Approach 1:
The patent extracts and removes the unnecessary hash value components from the directory structure. Instead of storing complete hash values that occupy significant space, the invention retains only the essential file name information in pre-sorted order. This extraction eliminates redundant data while preserving the core functionality of file name storage and retrieval, thereby improving storage space utilization.
3Productivity
If n-order B+ tree structure is used, then file name storage is achieved, but query efficiency is low and storage space utilization is low
Solution Approach 1:
The patent replaces the complex, multi-layered B+ tree structure with a simpler, flat pre-sorted array structure. This simplified structure acts as a more efficient 'disposable' solution that doesn't require the overhead of tree node management, pointer chasing, and complex traversal logic. The pre-sorted flat structure achieves comparable or better query performance with significantly reduced structural complexity and lower memory overhead.
Data Source
Figure 1
Figure 2
Figure 3
AI summary
A data query method and apparatus are disclosed. The data query method and apparatus relate to the field of computer technologies, to resolve a problem of comparatively low efficiency for querying a to-be-accessed file name. The method includes: determining a target directory block including m directory entries and m file names, where the m directory entries one-to-one correspond to the m file names, and the m directory entries and the m file names are sequentially arranged according to a preset rule; determining a current first set and a current second set based on a binary search algorithm and the target directory block, where the current first set includes x consecutive file names in the m file names, the current second set includes the x file names, a first file name, and a second file name, and m ≥ x≥ 1; determining a first common prefix between the to-be-accessed file name and a file name in the current second set; comparing the to-be-accessed file name with a third file name character by character from a first character after the first common prefix; and if the to-be-accessed file name is the same as the third file name, obtaining data of a to-be-accessed file based on a directory entry corresponding to the third file name.