Abstract Algebra for Scala
Clone or download
Latest commit 5fdb079 Aug 10, 2018
Failed to load latest commit information.
algebird-benchmark Use scalafmt to test formatting after running tests (#656) May 12, 2018
algebird-bijection/src remove unused imports, fix bug (#660) May 15, 2018
algebird-core/src use builder in SetMonoid (#662) Aug 4, 2018
algebird-generic/src Use scalafmt to test formatting after running tests (#656) May 12, 2018
algebird-spark/src Use scalafmt to test formatting after running tests (#656) May 12, 2018
algebird-test/src remove unused imports, fix bug (#660) May 15, 2018
algebird-util/src remove unused imports, fix bug (#660) May 15, 2018
docs/src/main Polymorphic Bloom filters (#607) Jan 4, 2017
project bump plugin versions (#658) May 12, 2018
scripts handle empty in product/tuple generators (#597) Dec 3, 2016
.gitignore Generate Algebird microsite via sbt-microsites (#556) Nov 4, 2016
.jvmopts Convert all laws to take Equiv instances, deprecate Equiv versions (#595 Dec 5, 2016
.scalafmt.conf Use scalafmt to test formatting after running tests (#656) May 12, 2018
.travis.yml bump plugin versions (#658) May 12, 2018
CHANGES.md prepare for release Dec 2, 2016
COMMITTERS.md Remove self from committers list (#644) Sep 14, 2017
CONTRIBUTING.md Fixed Spelling. Aug 27, 2018
LICENSE strut out sbt project. Aug 2, 2012
NOTICE Generate Algebird microsite via sbt-microsites (#556) Nov 4, 2016
README.md Add Apple to 'Projects using Algebird' (#663) Aug 9, 2018
build.sbt bump plugin versions (#658) May 12, 2018
sbt Add cross-build for Scala 2.12 (#600) Dec 11, 2016
version.sbt Setting version to 0.13.5-SNAPSHOT Feb 22, 2018



Build status Codecov branch Latest version Chat


Abstract algebra for Scala. This code is targeted at building aggregation systems (via Scalding or Apache Storm). It was originally developed as part of Scalding's Matrix API, where Matrices had values which are elements of Monoids, Groups, or Rings. Subsequently, it was clear that the code had broader application within Scalding and on other projects within Twitter.

See the Algebird website for more information.

What can you do with this code?

> ./sbt algebird-core/console

Welcome to Scala version 2.10.5 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_40).
Type in expressions to have them evaluated.
Type :help for more information.

scala> import com.twitter.algebird._
import com.twitter.algebird._

scala> import com.twitter.algebird.Operators._
import com.twitter.algebird.Operators._

scala> Map(1 -> Max(2)) + Map(1 -> Max(3)) + Map(2 -> Max(4))
res0: scala.collection.immutable.Map[Int,com.twitter.algebird.Max[Int]] = Map(2 -> Max(4), 1 -> Max(3))

In the above, the class Max[T] signifies that the + operator should actually be max (this is accomplished by providing an implicit instance of a typeclass for Max that handles +).

  • Model a wide class of "reductions" as a sum on some iterator of a particular value type. For example, average, moving average, max/min, set union, approximate set size (in much less memory with HyperLogLog), approximate item counting (using CountMinSketch).
  • All of these combine naturally in tuples, vectors, maps, options and more standard scala classes.
  • Implementations of Monoids for interesting approximation algorithms, such as Bloom filter, HyperLogLog and CountMinSketch. These allow you to think of these sophisticated operations like you might numbers, and add them up in hadoop or online to produce powerful statistics and analytics.


To learn more and find links to tutorials and information around the web, check out the Algebird website.

The latest API docs are hosted on Algebird's ScalaDoc index.

Get Involved + Code of Conduct

Pull requests and bug reports are always welcome! Check out our Contributing guide for information on what we most need help with and how you can get started contributing.

Discussion occurs primarily on the Algebird Gitter channel: Chat

We also monitor the Algebird mailing list.

Issues should be reported on the GitHub issue tracker.

We use a lightweight form of project governance inspired by the one used by Apache projects.

Please see Contributing and Committership for our code of conduct and our pull request review process.

The TL;DR is send us a pull request, iterate on the feedback + discussion, and get a +1 from a Committer in order to get your PR accepted.

The current list of active committers (who can +1 a pull request) can be found here: Committers

A list of contributors to the project can be found here: Contributors


Algebird modules are available on maven central. The current groupid and version for all modules is, respectively, "com.twitter" and 0.13.0.

See Algebird's page on the Scaladex for information on all published artifacts and their associated Scala versions. Algebird currently supports Scala 2.10, 2.11 and 2.12.

Projects using Algebird

Other projects built with Algebird, as compiled by the Scaladex: Scaladex Dependents



Copyright 2016 Twitter, Inc.

Licensed under the Apache License, Version 2.0.