Skip to content

Commit

Permalink
Add placeholder funtion for codegen transformations
Browse files Browse the repository at this point in the history
Summary:
We will want to transform 2 things:
- The entire fact retrieved from the codebase.
- The prefix pattern to search in the codebase.

This diff adds these transformations to `PredicateTransformation`

Reviewed By: pepeiborra

Differential Revision: D39692883

fbshipit-source-id: bc5528e6d6c53d0edc9ffb74f2d4a1ab4d5c90c8
  • Loading branch information
Marcelo Lazaroni authored and facebook-github-bot committed Sep 23, 2022
1 parent 0799e07 commit 718ab66
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
4 changes: 4 additions & 0 deletions glean/db/Glean/Database/Schema/Transform.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ mkPredicateTransformation detailsFor fromPid toPid
, tAvailable = pidRef to
, tTransformFactBack = fromMaybe id $
mkFactTransformation to from

, transformPrefix = Nothing
, transformKey = Nothing
, transformValue = Nothing
}
where
to = detailsFor toPid
Expand Down
28 changes: 28 additions & 0 deletions glean/db/Glean/Database/Schema/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module Glean.Database.Schema.Types
, PredicateDetails(..)
, predicateRef
, PredicateTransformation(..)
, Bytes(..)
, SchemaSelector(..)
, schemaNameEnv
, addTmpPredicate
Expand Down Expand Up @@ -40,10 +41,14 @@ import Data.Text.Prettyprint.Doc hiding ((<>))

import Glean.Angle.Types as Schema hiding (Type, FieldDef)
import qualified Glean.Angle.Types as Schema
import Glean.Bytecode.Types
import Glean.Query.Codegen.Types (Match, Var)
import Glean.Database.Schema.ComputeIds
import Glean.Query.Typecheck.Types
import Glean.RTS.Foreign.Bytecode (Subroutine)
import Glean.RTS.Foreign.Inventory (Inventory)
import Glean.RTS.Bytecode.Code
import Glean.RTS.Term (Term)
import Glean.RTS.Typecheck
import Glean.RTS.Traverse
import Glean.RTS.Types (Pid(..), Type, PidRef(..), FieldDef, ExpandedType(..))
Expand Down Expand Up @@ -86,6 +91,29 @@ data PredicateTransformation = PredicateTransformation
-- ^ available -> requested
-- ^ transform a fact of the available predicate into a fact
-- of the requested predicate.

, transformPrefix
:: forall a
. Maybe ( Term (Match () Var)
-> (IsPointQuery -> Bytes -> Code a)
-> Code a)
-- ^ requested -> available
-- ^ Build a prefix for the available predicate based on a matching
-- term for the requested predicate

, transformKey :: forall a. Maybe (Bytes -> (Bytes -> Code a) -> Code a)
, transformValue :: forall a. Maybe (Bytes -> (Bytes -> Code a) -> Code a)
-- ^ available -> requested
}

-- | Whether a prefix will match a fact from beginning to end and therefore can
-- only have a single result.
type IsPointQuery = Bool

-- | bytes in a binary output
data Bytes = Bytes
{ b_start :: Register 'DataPtr
, b_end :: Register 'DataPtr
}

data TypeDetails = TypeDetails
Expand Down

0 comments on commit 718ab66

Please sign in to comment.