Class Densify

java.lang.Object
dev.morphia.aggregation.stages.Stage
dev.morphia.aggregation.stages.Densify

public class Densify extends Stage
Creates new documents in a sequence of documents where certain values in a field are missing.

You can use $densify to:

  • Fill gaps in time series data.
  • Add missing values between groups of data.
  • Populate your data with a specified range of values.
Since:
2.3
Since server release
5.1
  • Method Details

    • densify

      public static Densify densify(String field, Densify.Range range)
      Creates new documents in a sequence of documents where certain values in a field are missing.

      You can use $densify to:

      • Fill gaps in time series data.
      • Add missing values between groups of data.
      • Populate your data with a specified range of values.
      Parameters:
      field - The field to densify. The values of the specified field must either be all numeric values or all dates.
      range - specifies how the data is densified.
      Returns:
      the new stage
      Since:
      2.3
      MongoDB documentation
      Aggregration Pipeline Stage: $densify
      Since server release
      5.1
    • partitionByFields

      public Densify partitionByFields(String... partitionByFields)
      The set of fields to act as the compound key to group the documents. In the $densify stage, each group of documents is known as a partition.

      If you omit this field, $densify uses one partition for the entire collection.

      Parameters:
      partitionByFields - the fields to partition by
      Returns:
      this