Skip to content

Latest commit

 

History

History
117 lines (92 loc) · 2.11 KB

File metadata and controls

117 lines (92 loc) · 2.11 KB

description: Promote an expression to be a child of its grandparent.

Module: expression_impl.promote

View source on GitHub

Promote an expression to be a child of its grandparent.

Promote is part of the standard flattening of data, promote_and_broadcast, which takes structured data and flattens it. By directly accessing promote, one can perform simpler operations.

For example, suppose an expr represents:

+
|
+-session*   (stars indicate repeated)
     |
     +-event*
         |
         +-val*-int64

session: {
  event: {
    val: 111
  }
  event: {
    val: 121
    val: 122
  }
}

session: {
  event: {
    val: 10
    val: 7
  }
  event: {
    val: 1
  }
}

promote.promote(expr, path.Path(["session", "event", "val"]), nval)

produces:

+
|
+-session*   (stars indicate repeated)
     |
     +-event*
     |    |
     |    +-val*-int64
     |
     +-nval*-int64

session: {
  event: {
    val: 111
  }
  event: {
    val: 121
    val: 122
  }
  nval: 111
  nval: 121
  nval: 122
}

session: {
  event: {
    val: 10
    val: 7
  }
  event: {
    val: 1
  }
  nval: 10
  nval: 7
  nval: 1
}

Classes

class PromoteChildExpression: The root of the promoted sub tree.

class PromoteExpression: A promoted leaf.

Functions

promote(...): Promote a path to be a child of its grandparent, and give it a name.

promote_anonymous(...): Promote a path to be a new anonymous child of its grandparent.