1
+ /*
2
+ * Copyright (c) 2025, Oracle and/or its affiliates.
3
+ *
4
+ * Licensed under the Universal Permissive License v 1.0 as shown at
5
+ * https://oss.oracle.com/licenses/upl.
6
+ */
7
+ using System ;
8
+ using System . Collections ;
9
+ using NUnit . Framework ;
10
+ using Tangosol . Net ;
11
+ using Tangosol . Run . Xml ;
12
+ using Tangosol . Util . Aggregator ;
13
+ using Tangosol . Util . Extractor ;
14
+ using Tangosol . Util . Filter ;
15
+
16
+ namespace Tangosol . Util ;
17
+
18
+ [ TestFixture ]
19
+ public class SimpleQueryRecordTests
20
+ {
21
+ private INamedCache GetCache ( String cacheName )
22
+ {
23
+ IConfigurableCacheFactory ccf = CacheFactory . ConfigurableCacheFactory ;
24
+
25
+ IXmlDocument config = XmlHelper . LoadXml ( "assembly://Coherence.Tests/Tangosol.Resources/s4hc-cache-config.xml" ) ;
26
+ ccf . Config = config ;
27
+
28
+ return CacheFactory . GetCache ( cacheName ) ;
29
+ }
30
+
31
+ [ SetUp ]
32
+ public void SetUp ( )
33
+ {
34
+ TestContext . Error . WriteLine ( $ "[START] { DateTime . Now : yyyy-MM-dd HH:mm:ss.fff} : { TestContext . CurrentContext . Test . FullName } ") ;
35
+ }
36
+
37
+ [ TearDown ]
38
+ public void TearDown ( )
39
+ {
40
+ TestContext . Error . WriteLine ( $ "[END] { DateTime . Now : yyyy-MM-dd HH:mm:ss.fff} : { TestContext . CurrentContext . Test . FullName } ") ;
41
+ }
42
+
43
+ [ Test ]
44
+ public void TestQueryRecorder ( )
45
+ {
46
+ INamedCache cache = GetCache ( "dist-query-recorder" ) ;
47
+ cache . Clear ( ) ;
48
+
49
+ var valueExtractor = new UniversalExtractor ( "City" ) ;
50
+ try
51
+ {
52
+ Hashtable ht = new Hashtable ( ) ;
53
+ Address address1 = new Address ( "Street1" , "City1" , "State1" , "Zip1" ) ;
54
+ Address address2 = new Address ( "Street2" , "City2" , "State2" , "Zip2" ) ;
55
+ ht . Add ( "key1" , address1 ) ;
56
+ ht . Add ( "key2" , address2 ) ;
57
+ cache . InsertAll ( ht ) ;
58
+
59
+ cache . AddIndex ( valueExtractor , false , null ) ;
60
+
61
+ QueryRecorder queryRecorder = new QueryRecorder ( QueryRecorder . RecordType . Explain ) ;
62
+ IFilter yourFilter = new ContainsFilter ( new UniversalExtractor ( "City" ) , "City1" ) ;
63
+ Object resultsExplain = cache . Aggregate ( yourFilter , queryRecorder ) ;
64
+ Console . WriteLine ( resultsExplain ) ;
65
+ }
66
+ finally
67
+ {
68
+ cache . RemoveIndex ( valueExtractor ) ;
69
+ CacheFactory . Shutdown ( ) ;
70
+ }
71
+ }
72
+ }
0 commit comments