Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Unique IPv4 Address Counter

This Java project efficiently counts the number of unique IPv4 addresses from a large input file using low memory and high performance techniques. It's built to scale to files containing tens or hundreds of gigabytes of IP data.


πŸš€ Features

  • Processes unlimited size files line-by-line using Java Streams
  • Custom IP address to int converter (IPToIntConvertor)
  • Efficient deduplication using a memory-optimized BitSetContainer
  • Uses only Java standard library (no external dependencies)
  • IP addresses are stored as 32-bit signed integers (int)
  • Supports reading input file from classpath via ClassLoader

πŸ“‚ Project Structure

src
└── main
β”œβ”€β”€ java
β”‚Β Β  └── com
β”‚Β Β      └── guseyn
β”‚Β Β          β”œβ”€β”€ App.java # Entry point: counts unique IPv4 addresses using classloader
β”‚Β Β          β”œβ”€β”€ BitSetContainer.java  # Efficient int container using BitSet array for deduplication
β”‚Β Β          β”œβ”€β”€ IntContainer.java  # Interface for custom integer containers
β”‚Β Β          β”œβ”€β”€ IpWriter.java # Fast, memory-efficient converter from IPv4 string to int
β”‚Β Β          └── IPToIntConverter.java
└── resources
└── ips.txt # Input file containing IPv4 addresses, one per line

Usage

  • Run IpWriter to generate your list of IPv4 addresses in the file: src/main/resources/ips.txt (One IP address per line, e.g., 192.168.1.1) or place your file.
  • Run App to get unique number of IP addresses.

Shout-out

Main principals are learnt from the article written by Jegors Čemisovs: https://jc.id.lv/posts/counting-unique-ipv4-addresses/

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages