Code Monkey home page Code Monkey logo

top100's Introduction

top100

top100 is a tiny external sorting library under 1G memory usage

Basic

./top100 a.urls

This will print the top 100 most frequently occurring urls with count.

Output:

1 https://wwww.google.com

2 https://github.com

Command line options

-h [ --help ] Produce help message

-v [ --version ] Print version details

-i [ --input ] arg Input file

Customization

Get the top 200 most frequently occurring urls

Edit counter.hpp:22, replace the constant 100 with 200 or whatever you want

Keep the sorted file

The ExternalSorter::sort takes a callback arg, which can be used to record the url in order

Use as a lib

CMake

git clone https://github.com/condy0919/top100

Include top100/sorter.hpp in your main file:

#include "top100/sorter.hpp"
#include <fstream>
#include <iostream>

int main() {
    top100::ExternalSorter sorter{std::ifstream("test")};

    sorter.sort([](std::string s) {
        std::cout << s << '\n';
    });
}

Edit CMakeLists.txt, let it generate a static top100 library. Replace add_executable with add_library

Add add_subdirectory(top100) in your CMakeLists.txt

Enjoy :)

Other build systems

DIY

TODO

  • using aio to write tmp file
  • improve CPU utilization rate

top100's People

Contributors

condy0919 avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.