@@ -4,6 +4,13 @@ ALTER SESSION SET CURRENT_SCHEMA = lab_user;
44DECLARE
55 -- All item declarations must precede subprogram bodies (PLS-00103 otherwise).
66 seed NUMBER := 42 ;
7+ -- Ticket volume. 10,000 tickets is deliberately past the point where the
8+ -- cost-based optimizer chooses the IVF vector index over exact full-scan
9+ -- distance for module 03's filtered FETCH APPROX query (the crossover
10+ -- arrives by roughly 3,000 rows on the Free container with fresh stats) —
11+ -- so the captured plan shows the index + in-plan predicate evaluation, not
12+ -- a toy-size full scan.
13+ c_tickets CONSTANT PLS_INTEGER := 10000 ;
714 v_vec VARCHAR2 (400 );
815 v_norm NUMBER ;
916 TYPE t_f IS TABLE OF NUMBER INDEX BY PLS_INTEGER;
@@ -18,13 +25,71 @@ DECLARE
1825 v_prod PLS_INTEGER;
1926 v_qty PLS_INTEGER;
2027 v_ts TIMESTAMP ;
28+ v_cat PLS_INTEGER;
29+ v_body VARCHAR2 (2000 );
30+ -- Enriched ticket-body corpus for tickets 301..c_tickets: 6 intros x 8 issue
31+ -- categories x 4 details x 50 products x 5 closers ~= 48k distinct bodies, so
32+ -- the 384-dim embeddings form real semantic clusters instead of 4 duplicated
33+ -- points (matters for a meaningful IVF index and hybrid-search demo).
34+ TYPE t_v IS TABLE OF VARCHAR2 (400 );
35+ intro t_v := t_v(' Customer reports an issue with their recent experience.' ,
36+ ' Contacting support after several attempts to resolve this alone.' ,
37+ ' Opening a ticket on behalf of the account holder.' ,
38+ ' Follow-up on an earlier conversation with the support team.' ,
39+ ' New request submitted through the help center.' ,
40+ ' Escalated from chat: the problem is still not resolved.' );
41+ refund t_v := t_v(' The package arrived damaged and a refund is requested.' ,
42+ ' The box was crushed in transit and the item inside is damaged beyond use.' ,
43+ ' Item arrived with a cracked casing; customer asks for their money back.' ,
44+ ' Shipment was left in the rain and the contents are damaged and unusable.' );
45+ login t_v := t_v(' Login fails with an authentication error after reset.' ,
46+ ' Password reset completed but sign-in still rejects the new credentials.' ,
47+ ' Two-factor prompt never arrives and access to the account is blocked.' ,
48+ ' Account is locked out after the security update and recovery does not work.' );
49+ shipdl t_v := t_v(' The order has not arrived within the promised window.' ,
50+ ' Tracking has shown no movement for a week and the delivery date passed.' ,
51+ ' Carrier marked the parcel delivered but nothing has arrived.' ,
52+ ' Estimated delivery keeps slipping and no update has been provided.' );
53+ warr t_v := t_v(' Customer asks whether the warranty covers accidental damage.' ,
54+ ' Requesting warranty service for a unit that stopped powering on.' ,
55+ ' Screen developed dead pixels within the coverage period.' ,
56+ ' Asking how to start a warranty claim for a failed component.' );
57+ billing t_v := t_v(' The statement shows a duplicate charge for a single order.' ,
58+ ' A promotional discount was not applied at checkout.' ,
59+ ' The invoice total does not match the order confirmation email.' ,
60+ ' Customer was billed after cancelling the subscription.' );
61+ exch t_v := t_v(' Requesting an exchange for a different size of the same product.' ,
62+ ' The wrong color variant was delivered and a swap is requested.' ,
63+ ' Received a different model than the one ordered.' ,
64+ ' Asking to exchange a gift for store credit instead.' );
65+ install t_v := t_v(' The setup guide does not match the ports on the device.' ,
66+ ' Firmware update fails at forty percent every attempt.' ,
67+ ' The companion app cannot discover the device during pairing.' ,
68+ ' Installation completes but the device reboots continuously.' );
69+ perf t_v := t_v(' The device becomes very slow after a few hours of use.' ,
70+ ' Battery drains overnight even when the unit is idle.' ,
71+ ' Audio cuts out intermittently during playback.' ,
72+ ' The connection drops whenever a second device joins.' );
73+ closing t_v := t_v(' Customer asks for a response today.' ,
74+ ' This is the second time the issue has been reported.' ,
75+ ' The customer mentions they are a long-time subscriber.' ,
76+ ' A callback number has been left on the account.' ,
77+ ' No workaround has been found so far.' );
2178 FUNCTION nxt RETURN NUMBER IS -- LCG: deterministic across runs
2279 BEGIN
2380 seed := MOD(seed * 1103515245 + 12345 , 2147483648 );
2481 RETURN seed / 2147483648 ;
2582 END;
2683 FUNCTION pick(n IN PLS_INTEGER) RETURN PLS_INTEGER IS
2784 BEGIN RETURN TRUNC(nxt * n) + 1 ; END;
85+ FUNCTION cat_detail(p_cat PLS_INTEGER) RETURN VARCHAR2 IS
86+ BEGIN
87+ RETURN CASE p_cat
88+ WHEN 1 THEN refund (pick(4 )) WHEN 2 THEN login(pick(4 ))
89+ WHEN 3 THEN shipdl (pick(4 )) WHEN 4 THEN warr (pick(4 ))
90+ WHEN 5 THEN billing(pick(4 )) WHEN 6 THEN exch (pick(4 ))
91+ WHEN 7 THEN install(pick(4 )) ELSE perf(pick(4 )) END;
92+ END;
2893BEGIN
2994 FOR i IN 1 ..200 LOOP
3095 INSERT INTO customers (email, full_name, segment)
95160 UPDATE orders SET total_amount = ROUND(v_total,2 ) WHERE order_id = i;
96161 END LOOP;
97162
163+ -- Tickets 1..300: the ORIGINAL 4-template corpus, byte-for-byte (module 01's
164+ -- ticket #1 proofs and module 03's read-after-write probe depend on ticket #1
165+ -- keeping its "Login fails with an authentication error after reset." body).
98166 FOR i IN 1 ..300 LOOP
99167 v_norm := 0 ;
100168 FOR d IN 1 ..8 LOOP f(d) := nxt* 2 - 1 ; v_norm := v_norm + f(d)* f(d); END LOOP;
@@ -119,6 +187,38 @@ BEGIN
119187 CASE WHEN MOD(i,3 )= 0 THEN ' closed' WHEN MOD(i,7 )= 0 THEN ' pending' ELSE ' open' END,
120188 TO_VECTOR(v_vec, 8 , FLOAT32));
121189 END LOOP;
190+
191+ -- Tickets 301..c_tickets: the enriched scaled corpus. The LCG is re-seeded to
192+ -- a fixed value here so this block is deterministic regardless of how the
193+ -- upstream seeding evolves — same bodies on every fresh build.
194+ seed := 342 ;
195+ FOR i IN 301 ..c_tickets LOOP
196+ v_cat := pick(8 );
197+ v_cust := pick(200 );
198+ v_body := intro(pick(6 ))|| ' ' || cat_detail(v_cat)||
199+ ' Relates to Product ' || pick(50 )|| ' . ' || closing(pick(5 ));
200+ v_norm := 0 ;
201+ FOR d IN 1 ..8 LOOP f(d) := nxt* 2 - 1 ; v_norm := v_norm + f(d)* f(d); END LOOP;
202+ v_norm := SQRT(v_norm);
203+ v_vec := ' [' ;
204+ FOR d IN 1 ..8 LOOP
205+ v_vec := v_vec || TO_CHAR(ROUND(f(d)/ v_norm, 6 ),' FM990.999999' ) || CASE WHEN d< 8 THEN ' ,' END;
206+ END LOOP;
207+ v_vec := v_vec || ' ]' ;
208+ INSERT INTO support_tickets (customer_id, subject, body, status, embedding)
209+ VALUES (v_cust,
210+ CASE v_cat WHEN 1 THEN ' Refund request for damaged item'
211+ WHEN 2 THEN ' Cannot sign in after password reset'
212+ WHEN 3 THEN ' Shipping delay on recent order'
213+ WHEN 4 THEN ' Warranty question for product'
214+ WHEN 5 THEN ' Billing discrepancy on statement'
215+ WHEN 6 THEN ' Exchange request for recent order'
216+ WHEN 7 THEN ' Device setup and installation issue'
217+ ELSE ' Performance problem with product' END || ' #' || i,
218+ v_body,
219+ CASE WHEN MOD(i,3 )= 0 THEN ' closed' WHEN MOD(i,7 )= 0 THEN ' pending' ELSE ' open' END,
220+ TO_VECTOR(v_vec, 8 , FLOAT32));
221+ END LOOP;
122222 COMMIT ;
123223END;
124224/
0 commit comments