3 Replies Latest reply: Jan 16, 2013 10:09 AM by Harvey Raja-Oracle RSS

    how to specify index for cache in coherence-cache-config.xml

    984647
      Hi All,
      We want to apply indexing on cache data.
      Suppose i have a EMPLOYEE object in coherence cache.
      and i want to use employeeID for indexing purpose.

      Can anybody help me to achieve this at Congregational level i.e. using xml file (coherence-cache-config.xml) .

      Edited by: 981644 on Jan 16, 2013 1:51 AM
        • 1. Re: how to specify index for cache in coherence-cache-config.xml
          Harvey Raja-Oracle
          Hi,

          This is not possible out-of-the-box however can be achieved a number of ways. I wrote an example sometime ago leveraging the work Brian has done in the incubator wrt namespaces to allow indexes to be specified in the cache configuration. I'll try to dig it out shortly.

          Thanks,
          Harvey
          • 2. Re: how to specify index for cache in coherence-cache-config.xml
            984647
            hi Harvey,
            Thanx for your reply.
            i ll wait for your response/
            • 3. Re: how to specify index for cache in coherence-cache-config.xml
              Harvey Raja-Oracle
              Hi,

              I've posted some [url http://coherence.oracle.com/download/attachments/14647422/add-index-namespace.jar]code and the [url http://coherence.oracle.com/download/attachments/14647422/add-index-namespace-src.jar]source. It depends on coherence common version 2.3.0.39174 however I believe it will work with 2.0.0.23649 also. Coherence common library can be downloaded from [url http://coherence.oracle.com/display/INC10/coherence-common]here

              Note: This is purely an example on how to achieve index creation via a cache configuration file and is not a part of the product thus is not covered by product support.

              Here is an example cache configuration that uses the namespace:
              <cache-config xmlns:service="class://com.oracle.coherence.environment.extensible.ServiceOperations">
                  <caching-scheme-mapping>
                      <service:index-add cache-name="dist-indexes">
                          <extractor>
                              <class-name>ReflectionExtractor</class-name>
                              <init-params>
                                  <init-param>
                                      <param-type>string</param-type>
                                      <param-value>getName</param-value>
                                  </init-param>
                              </init-params>
                          </extractor>
                      </service:index-add>
              
                      <!-- Simplified POF Config -->
                      <service:index-add cache-name="dist-indexes" pof-enabled="true">
                          <pof-index>8,16,32</pof-index>
                      </service:index-add>
                      
                      <!-- This should not be counted based on system-property override -->
                      <service:index-add cache-name="dist-indexes" pof-enabled="true" enabled="{tangosol.index.add}">
                          <pof-index>8,16,31</pof-index>
                      </service:index-add>
                      
                      <!-- Explicit POF Config -->
                      <service:index-add cache-name="dist-indexes">
                          <extractor>
                              <class-name>PofExtractor</class-name>
                              <init-params>
                                  <init-param>
                                      <param-type>{class}</param-type>
                                      <param-value>null</param-value>
                                  </init-param>
                                  <init-param>
                                      <param-type>{object}</param-type>
                                      <param-value>
                                          <class-name>com.tangosol.io.pof.reflect.SimplePofPath</class-name>
                                          <init-params>
                                              <init-param>
                                                  <param-type>{int[]}</param-type>
                                                  <param-value>1,2,4</param-value>
                                              </init-param>
                                          </init-params>                      
                                      </param-value>
                                  </init-param>
                              </init-params>
                          </extractor>
                      </service:index-add>
                  </caching-scheme-mapping>
              </cache-config>
              Thanks,
              Harvey