Code Fingerprinting Search for Similar Snippet Reuse
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Identifying and reusing similar code across large collections of programs and applications within an organization is difficult, leading to inefficiencies and increased code generation costs.
Innovation Solution
A system and method for fingerprinting code snippets, involving normalization, k-gram computation, hashing, and winnowing to generate fingerprints, which are used to search and rank similar code snippets, excluding sanctioned software like library and boilerplate code.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Difficulty of detecting and measuring
If code search is performed in large data stores without fingerprinting, then code discovery capability is limited, but system complexity and processing time increase significantly
Solution Approach 1:
The code is segmented into k-grams (subsequences of tokens) to create fingerprints. This segmentation transforms the complex task of comparing entire code files into simpler comparisons of smaller fingerprint segments, enabling efficient code discovery without overwhelming system complexity
Solution Approach 2:
Fingerprints serve as an intermediary representation between the original code and the search mechanism. Instead of directly comparing large code stores, the system uses computed fingerprints as mediators to enable efficient similarity detection while reducing computational burden
2Measurement precision
If fingerprinting is applied to all code including library and boilerplate, then search completeness is high, but result quality deteriorates due to false positives
Solution Approach 1:
Sanctioned code (library code, boilerplate, and other excluded code) is extracted and removed from the search index. This extraction prevents these common code patterns from generating false positive matches, improving search accuracy by focusing only on original, organization-specific code
Solution Approach 2:
Different quality standards are applied to different portions of code. Original code is indexed with full fingerprinting for accurate matching, while sanctioned code is excluded from indexing. This local differentiation ensures that search results reflect only meaningful, organization-specific code patterns
3Measurement precision
If exact code matching is used, then precision is high, but adaptability to code variations decreases
Solution Approach 1:
The fingerprinting process transforms code by changing parameters such as tokenization granularity (k-gram size) and hashing functions. These parameter transformations enable the system to match code semantically rather than exactly, accommodating variations in naming conventions, formatting, and minor syntax differences while maintaining matching precision
Data Source
AI summary
Systems and methods for identifying associations between a code snippet query and stored computer code stored. The method can receive a code query identifying a code snippet to search for, determine a fingerprint of the query code snippet, and search the stored software using the fingerprint to identify software results of code similar to the query code snippet. The fingerprint can be determined by generating k-grams of the code snippet. The k-grams used for the search can be down-selected based on a winnowing process. The method can remove from the software results code that is associated with sanctioned software. The method can include coalescing the software results to produce a subset of the software results, generating a code search user interface comprising information indicative of the subset of software results, and causing presentation of the code search user interface and displaying the subset of software results.


