Skip to content

Add bloom filters to parquet statistics #1468

Closed

Description

@asfimport

For row groups with no dictionary, we could still produce a bloom filter. This could be very useful in filtering entire row groups.
Pull request:
#215

Reporter: Alex Levenson / @isnotinvain
Assignee: Junjie Chen / @chenjunjiedada

Subtasks:

Related issues:

PRs and other links:

Note: This issue was originally created as PARQUET-41. Please see the migration documentation for further details.

Activity

  1. asfimport commented on Mar 5, 2015

    @asfimport
    Author

    Alex Levenson / @isnotinvain:
    This will require some planning and discussion around parquet-format.
    We need to choose how we will serialize a bloom filter into parquet statistics, how it's size will be configured, etc.
    But ultimately it needs to be a bloom filter easily deserialized from C++, and it needs to be durable (so java.io.Serializable or anything similar won't work here.)

  2. asfimport commented on Mar 7, 2015

    @asfimport
    Author

    Daniel Weeks / @danielcweeks:
    While it would be great to have them be compatible between java/C++/etc, that shouldn't necessarily be a requirement. A bloom filter is an optimization, so if the reader doesn't know how to interpret it, it can simply be ignored.

  3. asfimport commented on Mar 7, 2015

    @asfimport
    Author

    Antonios Chalkiopoulos / @Antwnis:
    I don't know if it helps - but in scala , using algebird, when i want to serialize a Bloom Filter into a file and then be able to re-read it from another job i do:

    def serialize(dataStructure: Any): Array[Byte] = {
    val stream = new ByteArrayOutputStream()
    val out = new ObjectOutputStream(stream)
    out.writeObject(dataStructure)
    out.close()
    stream.close()
    stream.toByteArray
    }

    def deserialize[T](byteArray: Array[Byte]): T = {
    val is = new ObjectInputStream(new ByteArrayInputStream(byteArray))
    is.readObject().asInstanceOf[T]
    }

    and then from i.e. Scalding

    pipe.mapTo('bloom -> 'serialized) { bf:BF => io.scalding.approximations.Utils.serialize(bf) }.write( ... )
    pipe.mapTo('bloom -> 'serialized) { bf:BF => new String(io.scalding.approximations.Utils.serialize(bf)) }.write( ... )

    Where BF is actually com.twitter.algebird.BF

  4. asfimport commented on Mar 7, 2015

    @asfimport
    Author

    Alex Levenson / @isnotinvain:
    If the data for the bloom filter is going to be stored in the parquet-format thrift statistics schema, I think it should be well a well defined format, that is not specific to java (for example, the format should not be whatever comes out of an ObjectOutputStream).
    I think it's fine that the two runtimes support different features, but so far we have maintained binary compatibility between the two.

    Even if we didn't care about interoperability, we still need a well defined binary format for the bloom filter that is durable over time, unlike plain java.io serialization.

  5. asfimport commented on Mar 7, 2015

    @asfimport
    Author

    Alex Levenson / @isnotinvain:
    Right, so while this works for temporary storage / transport of java objects, it's not a durable format with guaranteed stability over time. If the algebird bloom filter changes later, it will serialize differently, etc. So I think we need to still define a thrift / binary format for storing the bloom filter.

  6. asfimport commented on Mar 7, 2015

    @asfimport
    Author

    Alex Levenson / @isnotinvain:
    To clarify, I'm not saying the C++ has to use the bloom filter at runtime right away, but we should not use a binary format that would make it impossible / difficult for the C++ impl to use it if it wanted to. And I think it would also be bad news if each impl serialized bloom filters in their own way.

  7. asfimport commented on Mar 9, 2015

    @asfimport
    Author

    Ferdinand Xu / @winningsix:
    Hi @isnotinvain and @Antwnis, thank you for your comments.
    I'd like to have a short summary for your summary. We should implement the BF by thrift other than some unstable framework library.
    Regards to the size of bloom filter, I think we should configure it from the upper level since user can have a better understanding of the size of column numbers. Any thought about the size configuration?

  8. asfimport commented on Mar 9, 2015

    @asfimport
    Author

    Julien Le Dem / @julienledem:
    The first step is to specify how we would store the Bloom Filter in parquet-format.
    As @isnotinvain mentioned it should be defined at the binary level.
    A bloom filter is just a byte array (or possibly a few) and probably the spec of the hash functions used so it should not be that hard to defined.

    Alternatively there are custom properties that can be added for non standard things but I would recommend going the way defined above for bloom filters as they are a standard we want to define.

    listing a few folks that should probably review the format for this (from Impala, Drill, SparkSQL): [~marcelk] @nongli [~pipfiddle] @jaltekruse @rdblue [~marmbrus]

  9. asfimport commented on Mar 9, 2015

    @asfimport
    Author

    Ryan Blue / @rdblue:

    As Alex Levenson mentioned it should be defined at the binary level . . . and probably the spec of the hash functions used so it should not be that hard to defined.

    +1

  10. asfimport commented on Mar 9, 2015

    @asfimport
    Author

    Alex Levenson / @isnotinvain:
    Yes, I was just thinking, the hash functions for each data type need to be well defined too but Julien beat me to it :)

    So I would say next steps are:

    1. Define a binary format for serializing a bloom filter into a byte array, including any configuration data (like size), and also discuss whether that should be global (stored once) or repeated into each bloom filter.

    2. Define the hash function used for each data type

    3. Create a java implementation of the above, possibly borrowing code snippets from Algebird or Guava

  11. asfimport commented on Mar 9, 2015

    @asfimport
    Author

    Jacques Nadeau / @jacques-n:
    Agree with @isnotinvain, @julienledem, and @rdblue. We need non-language-specific binary specification. I'd also argue that we need to see highly performant proof of concept code in C and Java before we can decide that a particular specification is acceptable.

  12. asfimport commented on Mar 18, 2015

    @asfimport
    Author

    Prateek Rungta:
    ORC implemented bloom filters recently. Their design doc - 1 - is worth a gander.

  13. asfimport commented on Mar 31, 2015

    @asfimport
    Author

    Ryan Blue / @rdblue:
    Thanks [~prateekrungta]! Looks like I need to go read "Less Hashing, Same Performance: Building a Better Bloom Filter" by Kirsch et. al. now.

  14. asfimport commented on Apr 2, 2015

    @asfimport
    Author

    Ryan Blue / @rdblue:
    @winningsix does the info about ORC or the paper help at all?

  15. asfimport commented on Apr 3, 2015

    @asfimport
    Author

    Ferdinand Xu / @winningsix:
    Thanks @rdblue and [~prateekrungta] for this information, I will take time look at it.

  16. 61 remaining items

  17. asfimport commented on Jun 15, 2018

    @asfimport
    Author

    Jim Apple / @jbapple:
    I took a look at that benchmark and I now believe that in the case where the number of distinct values is the same as the number of values, or close to it, that this can provide some performance benefit.

    Junjie also shared with me the following resources:

    More benchmarks results: https://docs.google.com/spreadsheets/d/1LQqGZ1EQSkPBXtdi9nyANiQOhwNFwqiiFe8Sazclf5Y/edit#gid=0

    Fork with BF enabled: https://github.com/cjjnjust/parquet-mr/tree/parquet-41-base-1.8.x

    Data generator: https://github.com/cjjnjust/SQLDataGen

  18. asfimport commented on Jun 15, 2018

    @asfimport
    Author

    Junjie Chen / @chenjunjiedada:
    Thanks @jbapple

    Since the jira may contains several components, I 'd like to separate this task into more small tasks.

  19. asfimport commented on Jun 19, 2018

    @asfimport
    Author

    Jim Apple / @jbapple:
    @chenjunjiedada, is there an updated PR for parquet-format that matches the open PRs for parquet-mr and parquet-cpp?

  20. asfimport commented on Jun 20, 2018

    @asfimport
    Author

    Junjie Chen / @chenjunjiedada:
    @jbapple, I just created a new parquet-format PR since original one contains a lot of rebasing message. New PR: apache/parquet-format#99.

  21. asfimport commented on Jul 20, 2018

    @asfimport
    Author

    Aniket Namadeo Mokashi:
    @chenjunjiedada - thanks for driving this project! Are you planning to actively work on this? I would like to volunteer to help in taking this project forward.

  22. asfimport commented on Jul 20, 2018

    @asfimport
    Author

    Junjie Chen / @chenjunjiedada:
    [~aniket486], Thanks for watching this.

    Yes, I 'm still working on updating PR for both parquet-mr and parquet-cpp side and Jim is working on reviewing. While some of sub tasks I haven't start, such as reader/writer in parquet-cpp side, so I think you could start to help on that part. Also welcome to review on any PRs.

  23. asfimport commented on Feb 26, 2020

    @asfimport
    Author

    Gabor Szadovszky / @gszadovszky:
    @chenjunjiedada, feature branch for parquet-mr has been merged to master. Please resolve the sub-tasks and this jira accordingly.

  24. asfimport commented on Feb 27, 2020

    @asfimport
    Author

    Gabor Szadovszky / @gszadovszky:
    Removing 1.11.1 from Fix Version/s. (1.11.1 is a maintenance release and won't include any new features.)

  25. asfimport commented on Mar 16, 2020

    @asfimport
    Author

    Jun Ma:
    @gszadovszky/ @chenjunjiedada, what's the release timeline for this feature? 

  26. asfimport commented on Mar 18, 2020

    @asfimport
    Author

    Gabor Szadovszky / @gszadovszky:
    [~junma], the target release for this feature is 1.12.0. The main content of 1.12.0 would be this feature and the column encryption (PARQUET-1178). Both are under development so I would not give any deadlines for the release.

  27. asfimport commented on Feb 2, 2021

    @asfimport
    Author

    Nicholas Chammas:
    Where is the user documentation for all the bloom filter-related functionality that will be released as part of parquet-mr 1.12? I'm thinking of user settings like parquet.filter.bloom.enabled and parquet.bloom.filter.*, along with anything else a user might care about.

    For example, if a Spark user wants to use or configure bloom filters on their Parquet data, what documentation should they reference?

  28. asfimport commented on Feb 2, 2021

    @asfimport
    Author

    Yuming Wang / @wangyum:
    [~nchammas] You can check the related configuration parameters: https://github.com/apache/parquet-mr/tree/master/parquet-hadoop This is an example:

    val numRows = 1024 * 1024 * 15
    val df = spark.range(numRows).selectExpr(
      "id",
      "cast(id as string) as s",
      "cast(id as timestamp) as ts",
      "cast(cast(id as timestamp) as date) as td",
      "cast(id as decimal) as dec")
    val benchmark = new org.apache.spark.benchmark.Benchmark(
      "Benchmark bloom filter write",
      numRows,
      minNumIters = 5)
    
    benchmark.addCase("default") { _ =>
      withSQLConf() {
        df.write.mode("overwrite").parquet("/tmp/spark/parquet")
      }
    }
    
    benchmark.addCase("Build bloom filter for ts column") { _ =>
      withSQLConf(
        org.apache.parquet.hadoop.ParquetOutputFormat.BLOOM_FILTER_ENABLED -> "false",
        org.apache.parquet.hadoop.ParquetOutputFormat.BLOOM_FILTER_ENABLED + "#ts" -> "true") {
        df.write.mode("overwrite").parquet("/tmp/spark/parquet")
      }
    }
    
    benchmark.addCase("Build bloom filter for ts and dec column") { _ =>
      withSQLConf(
        org.apache.parquet.hadoop.ParquetOutputFormat.BLOOM_FILTER_ENABLED -> "false",
        org.apache.parquet.hadoop.ParquetOutputFormat.BLOOM_FILTER_ENABLED + "#ts" -> "true",
        org.apache.parquet.hadoop.ParquetOutputFormat.BLOOM_FILTER_ENABLED + "#dec" -> "true") {
        df.write.mode("overwrite").parquet("/tmp/spark/parquet")
      }
    }
    
    benchmark.addCase("Build bloom filter for all column") { _ =>
      withSQLConf(
        org.apache.parquet.hadoop.ParquetOutputFormat.BLOOM_FILTER_ENABLED -> "true") {
        df.write.mode("overwrite").parquet("/tmp/spark/parquet")
      }
    }
    benchmark.run()
  29. asfimport commented on Feb 2, 2021

    @asfimport
    Author

    Nicholas Chammas:
    Thanks for the link @wangyum. That README is what I was looking for.

    Are these docs published on the documentation site anywhere, or is the README file on GitHub the canonical reference?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions