How andreswang0703/bloomfilter works
Main components
• Command Entry Point: The "cmd" directory containing main.go. This is where execution begins.
• Core Bloom Filter Package: In the pkg/bloomfilter directory. It contains the key logic for creating and managing Bloom Filters (bit_array.go, bloom_filter.go, factory.go, option.go).
• Hash Utilities: The pkg/hash directory, which provides composite hashing functions used by the bloom filter.
• Parser Module: The pkg/parser directory, which likely handles input parsing (for example, reading or converting URL lists or other input data).
• Data Input: The "data" directory with urlList.txt, which serves as an input resource for demonstration or testing purposes.
Relationships and Interactions
• The main.go (cmd/main.go) acts as the orchestrator. It initializes the Bloom Filter using the factory pattern (likely defined in pkg/bloomfilter/factory.go) and interacts with various components.
• The Bloom Filter itself depends on:
• The bit array logic (pkg/bloomfilter/bit_array.go) to manage bits efficiently.
• The configuration and option settings (pkg/bloomfilter/option.go) to tune the filter.
• The hash utilities (pkg/hash) that provide underlying hash functions required for setting/checking bits.
• The Parser (pkg/parser/parser.go) is used to ingest and parse input data (e.g., urlList.txt from the data directory), feeding the Bloom Filter with items.
• The dependencies are relatively lightweight, each module playing a clear, interlocking role.
Architectural Patterns
• Modular design with separation of concerns: Each package in the "pkg" directory handles a single responsibility (Bloom Filter logic, hashing, parsing).
• Factory Pattern: The use of a factory (in pkg/bloomfilter/factory.go) suggests that object creation (likely of Bloom Filter instances) is abstracted for flexibility.
• Utility-driven library design: This is more of a tool or library than a full application, with clear, reusable components.