ReferenceValue

ReferenceValue

Generates values for referencing field by following the reference and randomly (following the specified distribution) picking a row from the value set (rows) of the referenced table and recalculating its value. Default timeIDOffset = 0

Attributes
Name Description Required Min Max Allowed Values
timeIDOffset Content type: Integer
Offset for the timeID this generator is going to use (e.g., if fixed time frame mode is used: refTimeID = offset + gc.timeID).
Default: 0
no 0 1
name (Class)Name of this element. Used to identify plugin Class. Full name is required. Example: com.en.myPluginPackage.myPuginClass no 0 1
choose supported modes: [randomShuffle, random, permutationRandom, relativeRowMapping, relativeUnique_withoutDeletedInNextUpdate, directRowMapping, sameChoiceAs, globalUnique, intraTupel, idFromSubGenerator, relativeUnique] yes 1 1
  • randomShuffle
  • random
  • permutationRandom
  • relativeRowMapping
  • relativeUnique_withoutDeletedInNextUpdate
  • directRowMapping
  • sameChoiceAs
  • globalUnique
  • intraTupel
  • idFromSubGenerator
  • relativeUnique
from supported modes: [fixedTimeFrame, atInsert, historical, sameTimeFrame, relativeTimeFrame] yes 1 1
  • fixedTimeFrame
  • atInsert
  • historical
  • sameTimeFrame
  • relativeTimeFrame
id Identification String of this element. May be used to uniquely identify a field within the children of an Element. no 0 1
includeDeletedIDs Content type: Boolean
When generating references to an update table, also include already deleted IDs.
Default: false
no 0 1
  • true
  • false
  • 0
  • 1
timeIDMAX Content type: Integer
Maximal chosen timeID this generator is going to use relatively to the current timeID in GenerationContext.getTimeID().
Default : last timeID in table).
no 0 1
Nodes
Name Description Required Min Max Allowed Values
reference reference yes 1 1
sameChoiceAs Content type: Empty
Requires a <field> and a <generatorByID> attribute (in same table) to pick the row number from. If specified this ReferenceValue does not choose a random row, but it uses the same row as the referenced generator.
Default: <not set>
no 0 1
distribution Distribution to be used by a generator when calculating a value no 0 1
  • bankmark.pdgf.distribution.Logarithmic
  • bankmark.pdgf.distribution.Beta
  • bankmark.pdgf.distribution.Normal
  • bankmark.pdgf.distribution.Exponential
  • bankmark.pdgf.distribution.Zeta
  • bankmark.pdgf.distribution.Binomial
gen Value Generator for this field no 0 1

Examples

  1. Simple Key/Foreign Key

    Generates customers with foreign keys to the NATION table. Hence for every nation id in the CUSTOMER table, there exists a corresponding primary key in the NATION table.

    Schema config for Simple Key/Foreign Key
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <!--
    /*******************************************************************************
    * Copyright (c) 2013, bankmark and/or its affiliates. All rights reserved.
    * bankmark UG PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
    ******************************************************************************/
    --><schema xmlns:doc="http://bankmark.de/pdgf/doc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="demo" xsi:noNamespaceSchemaLocation="structure/pdgfSchema.xsd">
      <!-- All data is derived from this starting seed.
           If this seed is the same, the generated data will the same on each
           computer/node/platform.
           Change this seed to generate a different data set.-->
      <seed>1234567890L</seed>
    
      <rng name="PdgfDefaultRandom"/>
    
      <!--Default Scale factor for all tables -->
      <property name="SF" type="double">1</property>
    
      <!--Simple Key/Foreign Key-->
        <!--
          Generates customers with foreign keys to the NATION table. Hence for every nation id in the CUSTOMER table,
          there exists a corresponding primary key in the NATION table.
        -->
        <!--n_nid (integer, asc.) | n_name (varchar) -->
        <!--base table used for reference -->
        <table name="NATION">
          <size>4</size>
          <field name="n_nid" type="NUMERIC">
            <gen_Id id="n_nid_gen">
              <min>1</min>
            </gen_Id>
          </field>
          <field name="n_name" type="VARCHAR">
            <gen_DictList>
              <file>dicts/country.dict</file>
              <disableRng/>
              <unique/>
            </gen_DictList>
          </field>
        </table>
    
        <table name="CUSTOMER">
          <!-- if tables should scale with -SF command line argument.
               Specify your scaling formula here: -->
          <size>10 * ${SF}</size>
    
          <field name="c_cid" type="NUMERIC">
            <gen_Id>
              <min>1</min>
            </gen_Id>
          </field>
    
          <field name="c_nid" size="" type="NUMERIC">
            <gen_ReferenceValue choose="random" from="historical">
              <reference field="n_nid" table="NATION"/>
            </gen_ReferenceValue>
          </field>
        </table>
        </schema>
    
    Output for Simple Key/Foreign Key
    # NATION
    1|Kyrgyzstan
    2|El Salvador
    3|Lesotho
    4|Bulgaria
    
    # CUSTOMER
    1|2
    2|4
    3|1
    4|3
    5|1
    6|2
    7|4
    8|3
    9|4
    10|2
  2. Sample Values from Reference Table

    Generates customers with a field for country of origin using the NATION table. Hence for every origin field in the CUSTOMER table, there exists a corresponding entry in the NATION table. See also OtherFieldValue generator for the same kind of behaviour within a table.

    Schema config for Sample Values from Reference Table
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <!--
    /*******************************************************************************
    * Copyright (c) 2013, bankmark and/or its affiliates. All rights reserved.
    * bankmark UG PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
    ******************************************************************************/
    --><schema xmlns:doc="http://bankmark.de/pdgf/doc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="demo" xsi:noNamespaceSchemaLocation="structure/pdgfSchema.xsd">
      <!-- All data is derived from this starting seed.
           If this seed is the same, the generated data will the same on each
           computer/node/platform.
           Change this seed to generate a different data set.-->
      <seed>1234567890L</seed>
    
      <rng name="PdgfDefaultRandom"/>
    
      <!--Default Scale factor for all tables -->
      <property name="SF" type="double">1</property>
    
      <!--Sample Values from Reference Table-->
        <!--
          Generates customers with a field for country of origin using the NATION table. Hence for every origin field in
          the CUSTOMER table, there exists a corresponding entry in the NATION table. See also OtherFieldValue generator
          for the same kind of behaviour within a table.
        -->
        <!--n_nid (integer, asc.) | n_name (varchar) -->
        <!--base table used for reference -->
        <table name="NATION">
          <size>4</size>
          <field name="n_nid" type="NUMERIC">
            <gen_Id id="n_nid_gen">
              <min>1</min>
            </gen_Id>
          </field>
          <field name="n_name" type="VARCHAR">
            <gen_DictList>
              <file>dicts/country.dict</file>
              <disableRng/>
              <unique/>
            </gen_DictList>
          </field>
        </table>
    
        <table name="CUSTOMER">
          <!-- if tables should scale with -SF command line argument.
               Specify your scaling formula here: -->
          <size>10 * ${SF}</size>
    
          <field name="c_cid" type="NUMERIC">
            <gen_Id>
              <min>1</min>
            </gen_Id>
          </field>
    
          <field name="c_nid_1" size="" type="NUMERIC">
            <gen_ReferenceValue choose="random" from="historical" id="c_nid_gen">
              <reference field="n_nid" table="NATION"/>
            </gen_ReferenceValue>
          </field>
          <field name="c_origin" size="" type="VARCHAR">
            <!--sample from the NATION table using n_nid -->
            <gen_ReferenceValue choose="sameChoiceAs" from="">
              <sameChoiceAs field="c_nid_1" generatorByID="c_nid_gen"/>
              <reference field="n_name" table="NATION"/>
            </gen_ReferenceValue>
          </field>
        </table>
        </schema>
    
    Output for Sample Values from Reference Table
    # NATION
    1|The Bahamas
    2|Benin
    3|Mali
    4|Botswana
    
    # CUSTOMER
    1|3|Mali
    2|2|Benin
    3|4|Botswana
    4|3|Mali
    5|4|Botswana
    6|3|Mali
    7|1|The Bahamas
    8|2|Benin
    9|3|Mali
    10|3|Mali
2.7-83fb0 | 2020-04-22