Custom comparator with LimitFilter

When I use a custom comparator with a LimitFilter, the results within the limit are returned first and then the comparator is applied, instead of applying the comparator on the complete result set, and then limit them. Is there a way to achieve the scenario I am expecting?
Thank is advance

I am also on coherence version 3.5.2
1. custom-pof-config.xml:
<?xml version="1.0"?>
<!DOCTYPE pof-config SYSTEM "pof-config.dtd">
<pof-config>
     <user-type-list>
          <include>coherence-pof-config.xml</include>
          <user-type>
               <type-id>2001</type-id>
               <class-name>com.biperf.cache.example.CacheItem</class-name>
          </user-type>
          <user-type>
               <type-id>2002</type-id>
               <class-name>com.biperf.cache.example.CacheSubItem1</class-name>
          </user-type>
          <user-type>
               <type-id>2003</type-id>
               <class-name>com.biperf.cache.example.CacheSubItem2</class-name>
          </user-type>
          <user-type>
               <type-id>2004</type-id>
               <class-name>com.biperf.cache.example.CustomFilter1</class-name>
          </user-type>
          <user-type>
               <type-id>2005</type-id>
               <class-name>com.biperf.cache.example.CustomComparator1</class-name>
          </user-type>
          <user-type>
               <type-id>2006</type-id>
               <class-name>com.biperf.cache.example.CustomProcessor1</class-name>
          </user-type>
     </user-type-list>
     <allow-interfaces>true</allow-interfaces>
     <allow-subclasses>true</allow-subclasses>
</pof-config>2. Domain objects:
public class CacheItem extends AbstractEvolvable implements EvolvablePortableObject, java.io.Serializable, com.tangosol.io.pof.PortableObject
  private static final int VERSION = 1;
  private static final long serialVersionUID = -1L;
  private long cacheItemId;
  private Set<CacheSubItem1> item1 = new HashSet<CacheSubItem1>();
  private Set<String> item2 = new HashSet<String>();
  private Set<Long> item3 = new HashSet<Long>();
  public long getCacheItemId()
    return cacheItemId;
  public void setCacheItemId( long cacheItemId )
    this.cacheItemId = cacheItemId;
  public Set<CacheSubItem1> getItem1()
    return item1;
  public void setItem1( Set<CacheSubItem1> item1 )
    this.item1 = item1;
  public Set<String> getItem2()
    return item2;
  public void setItem2( Set<String> item2 )
    this.item2 = item2;
  public Set<Long> getItem3()
    return item3;
  public void setItem3( Set<Long> item3 )
    this.item3 = item3;
  @SuppressWarnings( "unchecked" )
  @Override
  public void readExternal( PofReader reader ) throws IOException
    cacheItemId = reader.readLong( 0 );
    item1 = (Set<CacheSubItem1>)reader.readCollection( 1, item1 );
    item2 = (Set<String>)reader.readCollection( 2, item2 );
    item3 = (Set<Long>)reader.readCollection( 3, item3 );
  @Override
  public void writeExternal( PofWriter writer ) throws IOException
    writer.writeLong( 0, cacheItemId );
    writer.writeCollection( 1, item1 );
    writer.writeCollection( 2, item2 );
    writer.writeCollection( 3, item3 );
  @Override
  public int getImplVersion()
    return VERSION ;
public class CacheSubItem1 extends AbstractEvolvable implements EvolvablePortableObject, java.io.Serializable, com.tangosol.io.pof.PortableObject
  private static final int VERSION = 1;
  private static final long serialVersionUID = -1L;
  private Map<Integer, CacheSubItem2> item1 = new HashMap<Integer, CacheSubItem2>();
  public Map<Integer, CacheSubItem2> getItem1()
    return item1;
  public void setItem1( Map<Integer, CacheSubItem2> item1 )
    this.item1 = item1;
  @SuppressWarnings( "unchecked" )
  @Override
  public void readExternal( PofReader reader ) throws IOException
    item1 = (Map<Integer, CacheSubItem2>)reader.readMap( 0, item1 );
  @Override
  public void writeExternal( PofWriter writer ) throws IOException
    writer.writeMap( 0, item1 );
  @Override
  public int getImplVersion()
    return VERSION ;
public class CacheSubItem2 extends AbstractEvolvable implements EvolvablePortableObject, java.io.Serializable, com.tangosol.io.pof.PortableObject
  private static final int VERSION = 1;
  private static final long serialVersionUID = -1L;
  private int value;
  private boolean flag;
  public int getValue()
    return value;
  public void setValue( int value )
    this.value = value;
  public boolean isFlag()
    return flag;
  public void setFlag( boolean flag )
    this.flag = flag;
  @Override
  public void readExternal( PofReader reader ) throws IOException
    value = reader.readInt( 0 );
    flag = reader.readBoolean( 1 );
  @Override
  public void writeExternal( PofWriter writer ) throws IOException
    writer.writeInt( 0, value );
    writer.writeBoolean( 1, flag );
  @Override
  public int getImplVersion()
    return VERSION ;
public class CustomComparator1 implements java.io.Serializable, Comparator<CacheItem>, com.tangosol.io.pof.PortableObject
  private static final long serialVersionUID = -1L;
  private int sortOrder = 1 ;
  private Integer key ;
  public CustomComparator1(){}
  public CustomComparator1( Integer key )
    this.key = key ;
  @Override
  public int compare( CacheItem item1, CacheItem item2 )
    return sortOrder * ( getValue( item1 ).compareTo( getValue( item2 ) )  ) ;
  private Integer getValue( CacheItem item )
    int value = item.getItem1().iterator().next().getItem1().get( key ).getValue() ;
    return new Integer( value ) ;
  @Override
  public void readExternal( PofReader reader ) throws IOException
    sortOrder = reader.readInt( 0 ) ;
    key = reader.readInt( 1 ) ;
  @Override
  public void writeExternal( PofWriter writer ) throws IOException
    writer.writeInt( 0, sortOrder ) ;
    writer.writeInt( 1, key ) ;
  public void setAscendingOrder()
    sortOrder = 1 ;
  public void setDescendingOrder()
    sortOrder = -1 ;
public class CustomFilter1 implements Filter, java.io.Serializable, com.tangosol.io.pof.PortableObject
  private static final long serialVersionUID = -1L;
  private Integer key = null ;
  public CustomFilter1(){}
  public CustomFilter1( Integer key )
    super() ;
    this.key = key ;
  @Override
  public boolean evaluate( Object item )
    for( CacheSubItem1 subItem1: ((CacheItem)item).getItem1() )
      CacheSubItem2 subItem2 = subItem1.getItem1().get( key );
      if(null!=subItem2){
        return true ;
    return false ;
  @Override
  public void readExternal( PofReader reader ) throws IOException
    key = reader.readInt( 0 ) ;
  @Override
  public void writeExternal( PofWriter writer ) throws IOException
    writer.writeInt( 0, key ) ;
public class CustomProcessor1 extends AbstractProcessor implements PortableObject
  private static final long serialVersionUID = -1L;
  private Integer key ;
  private Set<String> item2s = new HashSet<String>();
  public CustomProcessor1(){}
  public CustomProcessor1( Integer key, Set<String> item2s )
    this.key = key ;
    this.item2s = item2s ;
  @Override
  public Object process( com.tangosol.util.InvocableMap.Entry entry )
    if ( !entry.isPresent() )
      return null ;
    CacheItem item = (CacheItem)entry.getValue() ;
    return extract( item ) ;
  public CacheItem extract( CacheItem item )
    CacheItem extract = new CacheItem() ;
    extract.setCacheItemId( item.getCacheItemId() );
    Set<CacheSubItem1> item1s = item.getItem1() ;
    for( CacheSubItem1 item1: item1s )
      extract.getItem1().add( getExtractedItem1( item1 ) ) ;
    for( String item2: item2s )
      if( item.getItem2().contains( item2 ) )
        extract.getItem2().add( item2 );
    return extract ;
  private CacheSubItem1 getExtractedItem1( CacheSubItem1 hydrated )
    CacheSubItem1 extracted = new CacheSubItem1() ;
    extracted.getItem1().put( key, hydrated.getItem1().get( key ) ) ;
    return extracted ;
  public Integer getKey()
    return key;
  public void setKey( Integer key )
    this.key = key;
  public Set< String > getItem2s()
    return item2s;
  public void setItem2s( Set< String > item2s )
    this.item2s = item2s;
  @SuppressWarnings( "unchecked" )
  @Override
  public void readExternal( PofReader reader ) throws IOException
    key = reader.readInt( 0 ) ;
    item2s = (Set<String>)reader.readCollection( 1, item2s );
  @Override
  public void writeExternal( PofWriter writer ) throws IOException
    writer.writeInt( 0, key ) ;
    writer.writeCollection( 1, item2s );
}3. Cache data loader:
public class CacheDataLoader
  public static final String BASE_ITEM2_KEY = "12345678901234567890";
  public static final char[] VALID_CHARS =
  {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J',
  'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'T', 'U',
  'V', 'W', 'X', 'Y', 'Z', '1', '2', '3', '4',
  '5', '6', '7', '8', '9', '0'} ;
  public static final int NUMBER_OF_ITEM2 = 1000 ;
  public static final int NUMBER_OF_ITEM3 = 1000 ;
  public static final int NUMBER_OF_ITEM = 20000;
  public static final int BATCH_LOAD_SIZE = 10000 ;
  public static final int NUMBER_OF_KEYS_PER_SUBITEM1 = 50;
  public static final int MULITPLE_ITEM1_FREQUENCY = 1000 ;
  public static final int NUMBER_OF_MULTIPLE_ITEM1 = 1;
  public static final int MULITPLE_ITEM2_FREQUENCY = 2;
  public static final int NUMBER_OF_MULTIPLE_ITEM2 = 3;
  public static final int MULITPLE_ITEM3_FREQUENCY = 2;
  public static final int NUMBER_OF_MULTIPLE_ITEM3 = 5;
  public static final long BASE_CACHE_ITEM_KEY = 10000000 ;
  public static final long BASE_ITEM3_KEY = 10000000;
  private long item3Count = 0;
  private long item2Count = 0;
  private long cacheItemCount = 0;
  private NamedCache cache = CacheFactory.getCache( "cache-data" ) ;
  public static void main( String[] args )
    CacheDataLoader loader = new CacheDataLoader() ;
    loader.load() ;
    loader.createIndices() ;
  private void createIndices()
    cache.addIndex( new KeyExtractor( IdentityExtractor.INSTANCE ), false, null );
    cache.addIndex( new ReflectionExtractor( "getItem2" ), false, null );
    cache.addIndex( new ReflectionExtractor( "getItem3" ), false, null );
  private void load()
    long start = System.currentTimeMillis();
    cache.clear();
    int iterations = NUMBER_OF_ITEM/BATCH_LOAD_SIZE ;
    for ( int i=0;i<iterations; i++ )
      cache.putAll( getCacheItems( BATCH_LOAD_SIZE ) );
    System.out.println( "CACHE LOAD: Instances: " + cache.size() + " keysize: " + NUMBER_OF_KEYS_PER_SUBITEM1 + " Time: " + ( System.currentTimeMillis() - start ) );
  private Map<Long, CacheItem> getCacheItems( int loadSize )
    Map<Long, CacheItem> cacheItems = new HashMap<Long, CacheItem>() ;
    for( int i=0; i<loadSize; i++)
      CacheItem cacheItem = getCacheItem();
      cacheItems.put( cacheItem.getCacheItemId(), cacheItem ) ;
    return cacheItems ;
  private CacheItem getCacheItem()
    CacheItem cacheItem = new CacheItem();
    cacheItem.setCacheItemId( getNextCacheItemId() );
    cacheItem.setItem1( getItem1() ) ;
    cacheItem.setItem2( getItem2() );
    cacheItem.setItem3( getItem3() );
    return cacheItem;
  private Set<Long> getItem3()
    Set<Long> item3s = new HashSet<Long>() ;
    //First item3
    item3s.add( getNextItem3Id() ) ;
    //Additional item3s
    if( isAdditionalItem3Required() )
      for(int i=0; i<NUMBER_OF_MULTIPLE_ITEM3; ++i){
        item3s.add( getNextItem3Id() ) ;
    return item3s;
  private Set<String> getItem2()
    Set<String> item2s = new HashSet<String>() ;
    //First item2
    item2s.add( getNextItem2Id() ) ;
    //Additional item2s
    if( isAdditionalItem2Required() )
      for(int i=0; i<NUMBER_OF_MULTIPLE_ITEM2; ++i){
        item2s.add( getNextItem2Id() ) ;
    return item2s;
  private Set<CacheSubItem1> getItem1()
    Set<CacheSubItem1> item1s = new HashSet<CacheSubItem1>() ;
    //First item1
    item1s.add( getSubItem1() ) ;
    //Additional item1s
    if( isAdditionalItem1Required() )
      for(int i=0; i<NUMBER_OF_MULTIPLE_ITEM1; ++i){
        item1s.add( getSubItem1() ) ;
    return item1s;
  private CacheSubItem1 getSubItem1()
    CacheSubItem1 item = new CacheSubItem1() ;
    item.setItem1( getSubItemMap( NUMBER_OF_KEYS_PER_SUBITEM1 ) ) ;
    return item;
  private Map<Integer, CacheSubItem2> getSubItemMap( int numberPriceKeys )
    Map<Integer, CacheSubItem2> items = new HashMap<Integer, CacheSubItem2>();
    for ( int x = 0; x < numberPriceKeys; x++ )
      Integer key = x;
      items.put( key, getSubItem2() );
    return items;
  private CacheSubItem2 getSubItem2()
    CacheSubItem2 item = new CacheSubItem2() ;
    item.setFlag( RandomUtils.nextBoolean() ) ;
    item.setValue( getRandomValue() ) ;
    return item;
  private boolean isAdditionalItem1Required()
    return cacheItemCount%MULITPLE_ITEM1_FREQUENCY == 0;
  private boolean isAdditionalItem2Required()
    return cacheItemCount%MULITPLE_ITEM2_FREQUENCY == 0;
  private boolean isAdditionalItem3Required()
    return cacheItemCount%MULITPLE_ITEM3_FREQUENCY == 0;
  private long getNextCacheItemId()
    return BASE_CACHE_ITEM_KEY + (++cacheItemCount);
  private long getNextItem3Id()
    return BASE_ITEM3_KEY + (++item3Count%NUMBER_OF_ITEM3);
  private String getNextItem2Id()
    return BASE_ITEM2_KEY + (++item2Count%NUMBER_OF_ITEM2);
  private int getRandomValue()
    return RandomUtils.nextInt( 10000 ) ;
}4. Test Case:
public class TestExampleCache extends TestCase
  public void testLimitFilter1()
    final Integer key = getKey();
    Set<String> item2 = getItem2();
    Set<Long> item3 = getItem3();
    CustomComparator1 comparator = new CustomComparator1(key);
    comparator.setAscendingOrder();
    Filter[] filterArray = { new ContainsAnyFilter( "getItem2", item2 ),
                             new ContainsAnyFilter( "getItem3", item3 ),
                             new CustomFilter1( key ) };
    Filter allFilter = new AllFilter( filterArray ) ;
    CustomProcessor1 processor = new CustomProcessor1(key,item2);
    Set<Map.Entry<Long, CacheItem>> result1 = CacheFactory.getCache( "cache-data" ).entrySet( allFilter,comparator );
    for(Map.Entry<Long, CacheItem> entry : result1 ){
      CacheItem item = processor.extract( entry.getValue() );
      System.out.println(item.getCacheItemId()+"-"+item.getItem1().iterator().next().getItem1().values().iterator().next().getValue());
    System.out.println();
  public void testLimitFilter2()
    final Integer key = getKey();
    final int numberOfProducts = 10;
    Set<String> item2 = getItem2();
    Set<Long> item3 = getItem3();
    CustomComparator1 comparator = new CustomComparator1(key);
    comparator.setAscendingOrder();
    Filter[] filterArray = { new ContainsAnyFilter( "getItem2", item2 ),
                             new ContainsAnyFilter( "getItem3", item3 ),
                             new CustomFilter1( key ) };
    Filter allFilter = new AllFilter( filterArray ) ;
    LimitFilter limitFilter = new LimitFilter(allFilter, numberOfProducts);
    CustomProcessor1 processor = new CustomProcessor1(key,item2);
    Set<Map.Entry<Long, CacheItem>> result1 = CacheFactory.getCache( "cache-data" ).entrySet( limitFilter,comparator );
    for(Map.Entry<Long, CacheItem> entry : result1 ){
      CacheItem item = processor.extract( entry.getValue() );
      System.out.println(item.getCacheItemId()+"-"+item.getItem1().iterator().next().getItem1().values().iterator().next().getValue());
    System.out.println();
    limitFilter.nextPage();
    Set<Map.Entry<Long, CacheItem>> result2 = CacheFactory.getCache( "cache-data" ).entrySet( limitFilter,comparator );
    for(Map.Entry<Long, CacheItem> entry : result2 ){
      CacheItem item = processor.extract( entry.getValue() );
      System.out.println(item.getCacheItemId()+"-"+item.getItem1().iterator().next().getItem1().values().iterator().next().getValue());
  private Integer getKey()
    return new Integer(10);
  private Set<String> getItem2()
    Set<String> items = new HashSet<String>();
    items.add( "12345678901234567890" + 1 );
    items.add( "12345678901234567890" + 2 );
    items.add( "12345678901234567890" + 3 );
    items.add( "12345678901234567890" + 4 );
    items.add( "12345678901234567890" + 5 );
    items.add( "12345678901234567890" + 6 );
    items.add( "12345678901234567890" + 7 );
    items.add( "12345678901234567890" + 8 );
    items.add( "12345678901234567890" + 9 );
    items.add( "12345678901234567890" + 10 );
    items.add( "12345678901234567890" + 11 );
    items.add( "12345678901234567890" + 12 );
    return items;
  private Set<Long> getItem3()
    Set<Long> items = new HashSet<Long>();
    items.add( new Long(10000001) );
    items.add( new Long(10000002) );
    items.add( new Long(10000003) );
    items.add( new Long(10000004) );
    items.add( new Long(10000005) );
    items.add( new Long(10000006) );
    items.add( new Long(10000007) );
    items.add( new Long(10000008) );
    items.add( new Long(10000009) );
    items.add( new Long(10000010) );
    return items;
}5. Results:
a. testLimitFilter1()
10010001-109
10002002-121
10002004-487
10006003-726
10008004-762
10000004-845
10010003-922
10014003-1157
10012002-1426
10008002-1585
10002003-1709
10004004-2004
10004001-2179
10018002-2452
10016004-3073
10012004-3145
10008001-3249
10018001-3270
10008003-3319
10016002-3778
10012001-4256
10012003-4391
10002001-4921
10006002-5072
10000002-5162
10016003-5777
10014004-6068
10000001-6260
10000003-6373
10004002-6615
10014001-7679
10006001-7729
10006004-7794
10010002-8188
10010004-8215
10018004-8258
10016001-8383
10018003-8760
10004003-9652
10014002-9876
b. testLimitFilter2()
Page-1
10002004-487
10000004-845
10012002-1426
10008002-1585
10004004-2004
10018001-3270
10016003-5777
10006004-7794
10016001-8383
10018003-8760
Page-2
10018002-2452
10008001-3249
10008003-3319
10016002-3778
10012001-4256
10012003-4391
10014004-6068
10000003-6373
10010002-8188
10010004-8215
c. Expected results:
Page-1
10010001-109
10002002-121
10002004-487
10006003-726
10008004-762
10000004-845
10010003-922
10014003-1157
10012002-1426
10008002-1585
Page-2
10002003-1709
10004004-2004
10004001-2179
10018002-2452
10016004-3073
10012004-3145
10008001-3249
10018001-3270
10008003-3319
10016002-3778
Edited by: user8065775 on Oct 21, 2009 3:02 PM
PS : Looks like the following thread addresses the problem that I have mentioned, which has links to download the source code but they do not work. Is there a way that I can access the java source pointed to in the post pointed to by the following link?
Re: The question about the locking of the cache
SortByMethodNameAggregator.java
SortByMethodNameCaller.java
Can you please email me the code to [email protected]

Similar Messages

  • How to use comparator with LimitFilter in C#

    How to use a comparator with a LimitFilter, to achieve the sort of results ?
    My problem with this as [ http://forums.oracle.com/forums/thread.jspa?threadID=972856&start=0&tstart=240|http://forums.oracle.com/forums/thread.jspa?threadID=972856&start=0&tstart=240 ] , but I use coherence in C#, must use remote cache scheme.
    You have any good suggestions ?
    Thank is advance
    Edited by: user13034952 on Jun 11, 2010 6:18 PM

    Hi,
    We are still working on the bug.
    I talked to the engineer working on the problem and he suggested this workaround:
    As a workaround for this issue, I would suggest executing the query on the proxy itself using the Invocation service. The query would be executed in an Invocable (easiest way is to extend AbstractInvocable) and the Invocable would be launched from the .NET side.
    For more information on Invocation Service, please take a look at this link:
    http://download.oracle.com/docs/cd/E14447_01/coh.330/cohnet33/remoteinvocservice.htm

  • LINQ grouping with custom comparer

    I'm trying to implement a linq grouping with a custom comparer. I have a datatable, I fill it with data, then I add the datarows to a
    List(Of DataRow), then I select all the rows to a IEnumerable(Of Object()). After that, I would like to group the result with a custom comprarer.
    This is the code:
    Dim result As IEnumerable(Of Object())
    Dim dt As New DataTable
    Dim indexes As New List(Of Integer)
    Dim groupedindexes As New List(Of Integer)
    Dim datarows As New List(Of DataRow)
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    dt.Columns.Add("f1", Type.GetType("System.Char"))
    dt.Columns.Add("f2", Type.GetType("System.Char"))
    dt.Columns.Add("f3", Type.GetType("System.Char"))
    For i = 0 To 100
    dt.Rows.Add("a", "b", "c")
    Next
    indexes.Add(0)
    indexes.Add(1)
    indexes.Add(2)
    groupedindexes.Add(0)
    groupedindexes.Add(1)
    groupedindexes.Add(2)
    For i = 0 To dt.Rows.Count - 1
    datarows.Add(dt.Rows(i))
    Next
    result = datarows.Select(Function(row) indexes.Select(Function(index) row(index)).ToArray)
    Dim test = result.GroupBy(Function(row) groupedindexes.Select(Function(grpindex) row(grpindex)).ToArray, New compare)
    End Sub
    And this is the compare class:
    Partial Class compare
    Implements System.Collections.Generic.IEqualityComparer(Of Object())
    Public Function Equals1(ByVal x() As Object, ByVal y() As Object) As Boolean Implements System.Collections.Generic.IEqualityComparer(Of Object()).Equals
    Dim equal As Boolean = True
    For i = 0 To x.Count - 1
    If x(i) IsNot y(i) Then
    equal = False
    Exit For
    End If
    Next
    Return equal
    End Function
    Public Function GetHashCode1(ByVal obj() As Object) As Integer Implements System.Collections.Generic.IEqualityComparer(Of Object()).GetHashCode
    Dim hashcode As Integer
    For i = 0 To obj.Count - 1
    hashcode = hashcode + obj(i).GetHashCode
    Next
    Return hashcode
    End Function
    End Class
    With the above code, I get all the 101 rows, but I would like to get only one row (a, b, c), since all the rows are the same. Therefore I wrote the custom comparer class. I'm new to this and I'm not sure, that I use it correct.
    Can you advise me, how should I modify the code to get only one row?
    Thanks.

    Try code below.  I use a dictionary to group rows and then filter results to get unique rows.
    Module Module1
    Sub Main()
    Dim dt As New DataTable
    Dim dict As Dictionary(Of Integer, List(Of DataRow)) = dt.AsEnumerable() _
    .GroupBy(Function(x) x.Field(Of Integer)("Col A"), Function(y) y) _
    .ToDictionary(Function(x) x.Key, Function(y) compare(y.ToList()))
    End Sub
    Function compare(rows As List(Of DataRow)) As List(Of DataRow)
    Dim results As New List(Of DataRow)
    results.Add(rows.FirstOrDefault)
    If (rows.Count > 1) Then
    For i = 1 To (rows.Count - 1)
    Dim unique As Boolean = True
    Dim rowArray() As Object = rows(i).ItemArray
    For j = 0 To (results.Count - 1)
    Dim oldArray() As Object = results(j).ItemArray
    For cols = 0 To (rowArray.Length - 1)
    If rowArray(i) <> oldArray(j) Then
    unique = False
    Exit For
    End If
    Next cols
    If unique = False Then
    Exit For
    End If
    Next j
    If unique = True Then
    results.Add(rows(i))
    End If
    Next i
    End If
    Return results
    End Function
    End Module
    jdweng

  • Slow performance with custom comparator (AdvancedDataGrid sorting)

    I'm using Flex 3.4.
    I have an advancedDataGrid. Have 2 columns with numbers as data.
    For one column, I do not set any custom comparator function.
    For the other column, I set a custom comparator function which is exactly the same as the default one used by Flex. (The private function SortField.numericCompare).
    For both columns, I set the same data - 3000 Rows with values either 0 or 1.
    When i sort on column1 (the one with custom comparator), the sorting is much slower than on column2 (default Flex comparator).
    I went through the AdvancedDataGrid/SortField source codes but could not see why this could be happening as the comparator functions are the same in both cases.
    Also, I checked out this bug -
    http://bugs.adobe.com/jira/browse/SDK-13118
    But shouldn't this be applicable to both custom and default sorting?
    Can anyone help me out?

    This is the function that i have : (same as the SortField numericCompare function which is the default function which is used if no customCompare is specified.)
            public function numCompare(a:Object, b:Object):int {
                var fa:Number;
                try {
                    fa = _name == null ? Number(a) : Number(a[_name]);
                } catch (error:Error) {
                var fb:Number;
                try {
                    fb = _name == null ? Number(b) : Number(b[_name]);
                } catch (error:Error) {
                return ObjectUtil.numericCompare(fa, fb);
    As per bug, the performance should be slow for lots of items that have same value. But, it should be the same for both the custom compare and the default compare as the custom compare function I'm using is the same as what is used for Flex.

  • Sorting a Set with a custom Comparator

    Hi,
    I wondered how to sort a Set with a custom Comparator. I know how to do this with a List: Collections.sort(list,new CustomComparator()).
    But how can I do this with a Set?
    Thanks
    Jonny

    If you want to just sort the Set on demand, you'd have to dump its contents into a List, sort the List, then dump its contents back into a LinkedHashSet.
    If you want the set to always be in sorted order, use a SortedSet, such as TreeSet.

  • Use a single variable value to compare with 2 characteristics

    Hi guys
        I need some advice on how to use a single variable value to compare with 2 characteristics in a Infocube.
    eg : I hv 2 characteristics in Infocube
           Launch date  &  Closing Date
       Now I want to display report where the variable date (inputted by user) is equal to Launch Date and Closing Date.
        with regards

    Bobby,
    if I right understood your situation, you have an input variable ZINPUT (related to a date 'A') and 2 others dates (yours Launch and Closing dates, 'B' and 'C').
    You want to display only the rows where A(user input)=B=C.
    Now you have to create 2 new variables (called ZB and ZC, related to B and C dates) NOT marked as 'ready for input' and set to 'mandatory variable entry'.
    Call Transaction CMOD for the definition of the customer exit (if not already existing!).
    Create a new project, maintain the short text, and assign a development class.
    Goto Enhancements Assignments and assign RSR00001. Press the button components to continue.
    Double-click on EXIT_SAPLRRS0_001. For documentation place the cursor on RSR00001 and use the menu Goto -> Display documentation. 
    Then double-click on ZXRSRU01. If the include doesn’t exist you have to create it; assign a development class and a transport request.
    Enter the coding:
    DATA: L_S_RANGE TYPE RSR_S_RANGESID.
    DATA: LOC_VAR_RANGE LIKE RRRANGEEXIT.
    CASE I_VNAM.
    WHEN 'ZB'.
    (and you have to repeate the same code also for the variable 'ZC' !)
    IF I_STEP = 2.
    READ TABLE I_T_VAR_RANGE INTO LOC_VAR_RANGE
    WITH KEY vnam = 'ZINPUT'.
    if sy-subrc = 0.
    L_S_RANGE-LOW  = LOC_VAR_RANGE-LOW.
    endif.
    L_S_RANGE-sign = 'I'.
    L_S_RANGE-opt = 'EQ'.
    append L_S_RANGE to e_t_range.
    ENDIF.
    ENDCASE.
    Save and activate the coding and the project.
    Now go to your query and use these two new variables to restrict B and C....et voilà !!!
    Let me know if you need more help (and please assign points !!! be generous !!!)
    Bye,
    Roberto

  • Compare with my cost of goods sold account to my sales revenue account

    Hi,
    i want to compare with my cost of goods sold account to my sales revenue account.
    After PGI my COGS a/c will be debited INVENTORY a/c will be credited so after sales my SALES a/c credit & customer a/c debit . I want to see what is the difference value of COGS a/c with respective billing Sales A/C
    No doudt we can see in Profit of margin in billing doc. It is quite impossible to see all document in respective wise. Please give a solution for which i can know what is profit of margin with comparing values in both of Account.
    Thank's
    Abhay

    Hi,
    This is possible through CO-PA report. You can get the result per sales order.
    Also the same can be achieved in FI as follows:
    Outbound delivery document thr" VL01N is captured in "Reference field" of FI doc (BKPF-XBLNR) generated through delivery.
    If the settings are done by SD person to capture the outbound delivery no. in "Reference field" of FI doc generated through Billing document (VF01), then there will be a common field to compare the documents in both accounts.
    In transaction FAGLL03, select the account COGS & Sales revenue account. Once the report displays, sort or take sub total on this common field "Reference".
    This will give you difference between COGS & Sales revenue per document.
    Hope this resolves your query.
    Regards,
    Ashutosh

  • Sort order by custom comparable logic

    Hi All,
    Is it possible to sort the records from NamedCache.entrySet() by implementing Comparable<T> in my pojo?
    Thanks,

    user1096084 wrote:
    Thanks for your quick response.
    My requirement is to fetch objects without filter but with custom sort order and
    I couldn't find any method in QueryMap for this purpose.
    What will be result if implement Comparable interface in object?Hi,
    1. You can always use AlwaysFilter.INSTANCE for filtering.
    2. You can use a parallel aggregator to parallelly presort objects and also limit the number of objects you fetch.
    Implementing Comparable with the objects allows you to call entrySet(Filter, Comparator) with null for comparator. The method entrySet() without parameters or the entrySet(Filter) do not sort regardless of whether your objects implement comparable or not.
    Best regards,
    Robert

  • How to use a custom comparator in a TableSorter?

    Hi,
    I want to use a custom comparator for sorting a table by a specific column.
    As you possibly know, the constructor for the TableSorter class looks like this:
    TableSorter(IWDTable table, IWDAction sortAction, Map comparators);
    As Map is an Interface I chose Hashmap as comparator container. So, I use the put(Key, Value) method to insert my own comparator into the Hashmap in order to deliver this Object to the TableSorter constructor.
    But there is an essential problem:
    I assume, that the column which is to be associated with my comparator is determined by the key of the Map object from the TableSorter constructor.
    Presuming this, <u>what should the map key be/look like?</u>
    An Integer counted from the columns? The column header as String? Whatever? Or am I on the wrong way?
    PS:
    Hours of search did not lead me to some kind of documentation or javadoc of the TableSorter class! This can't be, does someone have a link please?
    Thanks a lot for any help.

    (sorry Mrutyun, this did not help.)
    Ok, I solved it; let me share it with you:
    public class ExampleView
            public static void wdDoModifyView(IPrivateExampleView wdThis, IPrivateExampleView.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)
                     * A custom Comparator class is used for sorting by Severity.
                     * An Object of it is delivered to an object of a Map class to be delivered to the TableSorter constructor.
                     * The Map class consists of key-value pairs, and the TableSorter must accept the Key of it
                     * because he uses it to assign the mapped Comparator to the column of the table to be sorted!
                     * And this is done with the ID of the Element, which shall be sorted with the Comparator, used as Map Key.
                     * All other columns of the assigned tables will be sorted by default Comparators.
                    IWDTable table = (IWDTable) view.getElement("[TableName]");
                    HashMap tableComps = new HashMap();
                    tableComps.put(view.getElement("[ColumnName]").getId(), new MyComp(wdContext.currentExampleElement())); //The map key value I looked for is the ID of the Element of the Column!
                    wdContext.current/*yourContextNode*/Element().setTableSort(
                            new TableSorter(table, wdThis.wdGetSortTableRowAction(),
                                    tableComps)); //Insert HashMap with the new Comparator
            public void onActionSortTableRow(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
            //@@begin onActionSortTableRow(ServerEvent)
                            wdContext.currentConfigurationElement().getTableSort().sort(wdEvent, wdContext.nodeOpenIncident());
            //@@end
    As you see, the Column which is to be sorted by the custom Comparator "MyComp", is clearly assigned to it. Thus, is will only be used when sorting by this column is done.
    The "inActionSort" method is as usual.
    My Comparator sorts a column which contains variables of a "SimpleType" with an enumeration. (If you need help with this, feel free to write me.) To achieve this, the Comparator needs to know what this SimpleType consists of. That's why I deliver this Element per Constructor to it.
    public class MyComp implements Comparator
         MappedNodeElement element;
         public SeverityComp(I/*one*/Element element)
              this.element = element;
         public SeverityComp(I/*another*/Element element)
              this.element = element;
         public int compare(Object severity1, Object severity2)
    Because MappedNodeElement is such abstract, it can be used by several different Tables, provided they use the same SimpleType.
    Concerning my quest for this resolution, I hope this is helpful.
    null

  • What is the use of jsp when compare with Struts

    what is the use of jsp when compare with Struts

    JSP Tag Libraries are great for reusable content formatting and ligic.
    For example, let's say you have this Shopping site. Each item you sell is stored in a database, and you get them out depending on Catagories, creating a List of ItemBeans. You allways want to display the items with a catagory header, then a <table> with the item number, the description and the price.
    Instead of creating a bunch of logic in the JSP that does this, you can pass it on to a Tag that might look like this in your JSP:
    <shopping:itemTable catagory="${selectedCatagory}" items="${itemsForCatagory}" />
    This would make the JSP easier to read and work with.
    The actual uses are incredible. Have you used the <jsp:useBean ...> tag? That is an example of a use of the Custom Tag Libraries.
    Furthermore, look into JSTL (JSP Standard Tag Libraries). They are a collection of tags (API by Sun, coding by Apache) used to do many of the standard actions you might want/need to do in JSPs, like a conditional tag (c:if only do something if the test is true), multiple-conditional tags (c:choos c:when c:otherwise) like an if [else if] else construct. Looping through an array or Collection (c:forEach), storeing values in scopes (c:set) formating numbers and dates (the fmt library), xml transformations (xml library), and lots of other things that you could replace scriptlet code with.

  • SAP XI comparative with Cordys & TIBCO

    Hi gurus,
    Can anybody help me to find how SAP XI is better than Cordys or TIBCO .i.e. comparision between (SAP PI,Cordys,TIBCO)
    regards,

    HI
    Sap XI:
           XI is well suited for connecting SAP systems with each other and with non-SAP. SAP XI provides an integrated workflow engine that allows defining adapters to non-XML protocols and mappings to convert data content from source to target format.
    XI comes handy particularly incase of SAP - Non SAP interfaces where you can import standard integration content. Also XI has got sophisticated open standard adapter framework which is very easy to implement and custom logic can be implemented using Adapter module programming.
    Advantages
    u2022Monitoring is better than any other middleware product. It offers exhaustive monitoring features like message, performance, component monitoring etc, all of which can be used to track and rectify the errors. It follows a hub and spoke model.
    u2022When you need to integrate with an SAP system XI has an advantage in supporting various SAP components and so on.
    u2022Process functionalities inside XI to modify content in the communication channel on own defined rules for business purposes.
    u2022Mappings and adapters are good as comparable with any other middleware product.
    u2022Synchronous & Asynchronous communication is possible.
      Dis-Advantages
    u2022Web methods are particularly good if u have B2B kind of communication with their Trading Partners product.
    u2022XI is lacking full-fledged Message Queue compared to other established Middleware products.
    u2022It lacks in ability to process huge messages but SAP is working on that.
    u2022It does not have a messaging layer exposed by APIs like IBM MQ-Series.
    u2022It is not comparable to Tibco in terms of speed.
    u2022SAP relies on other vendors except for a few adapters.
    TIBCO:     
           TIBCO is described as having the most advanced BPM features overall, spanning both integration-centric and human-centric features due to the company's aggressive strategy to sustain competitive advantage by adding leading-edge features, whether via internal development or strategic acquisition.
    For the integration of custom applications into the e-business infrastructure, TIBCO makes available a comprehensive Software Development Kit that enables enterprises to build their own adapters.
    Advantages
    u2022Tibco has many adapters that are built by their own.
    u2022Tibco simple and productive User Interface is much more matured than XI.
    u2022Tibco does publish/subscribe very well. Available messaging types include request/reply, publish/subscribe and publish/reply interactions.
    u2022Improves overall system performance by eliminating repetitive batch requests to packaged application systems.
    u2022Lowers cost-of-ownership through general n-way rather than point-to-point integration.
    u2022Simplifies administration with data transparency provided by subject-based naming.
    u2022Enhances networked applications based on component or object development models.
    u2022Choice of message delivery service levels for optimal resource utilization.
    Dis-Advantages
    u2022Tibco does not have asynchronous SOAP/HTTP.
    u2022Concept of integration in terms of semantics and steps is a little more complex.
    u2022When compared in terms of monitoring, message level trace, message resubmission, pipelining, components monitoring Tibco is far behind to XI.
    cheers

  • EAP-TLS match on custom EKU with ACS 5.5

    Hi,
    is there any possibility to match on a custom EKU with ACS 5.5?
    I have to create a solution to limit access to a specific WLAN SSID. Only certificates containing a specific, self-created EKU should have access to this SSID. Other certificates from the same CA should be denied.
    I know that it's possible with Microsoft NPS but I would prefer a solution with ACS. But in ACS the ceritifcate dictionary contains only a few attributes i.e. common name, issuer, subject, but not the Enhanced Key Usage  (EKU).
    Any suggestions?
    Thanks,
    Werner

    Object Identifier Check for EAP-TLS Authentication
    ACS can compare the OID against the Enhanced Key Usage (EKU) field in the user's certificate. ACS denies access if the OID and EKU do not match. For more information about options, see Authentication for profile_name Page, page 14-46.
    When OID comparison is enabled and a valid OID string is entered, all the certificates that the users present for EAP-TLS authentication are checked against the OIDs entered. Authentication will be successful only if the OIDs match. If OID comparison is enabled but the user certificate presented does not contain any OID in the EKU field, authentication will fail.
    To enable OID comparison you must:
    •Enable EAP-TLS from the NAP page.
    •Enter only contain numbers, dots, commas and spaces in the OID strings, for example: 1.3.6.1.5.5.7.3.2 is a valid OID string.
    •Enter multiple OIDs as comma-separated values. For example: 1.3.6.1.5.5.7.3.1, 1.3.6.1.5.5.7.3.2 is a valid string.

  • Cost of ints compared with doubles

    This question isn't strictly specific to Java, but I was just wondering if there were any rough figures, or an order of magnitude as to how much more expensive float or double calculations are when compared with int calculations for operations such as addition, multiplication etc.
    I've read that some people try to avoid floating point calculations wherever possible and would like to know if it is still worth the effort, with processing power at the levels it is now.

    These sort of performance metrics are usually best avoided. Use whichever arithemetic is best for the job at hand. In 3 months the slow processor will be replaced (I think there's something called Moore's Law about this)
    It is quite possible that the floating point processor is 10 times as slow as the fixed point arithmetic, but you will waste more than 10 times the instructions by reimplementing COBOL's fixed point decimal data type in Java. You could also break that precious pipeline with an unfortunate branch down in the machine code.
    These kind of measures also vary significantly from one machine to another, often within the same family. If this level of performance is a serious issue, you are best off programming the critical portion of your code in Assembly language and customizing it for each supported processor, you could even have a C version for the other processors. That's what the real-world games programmers often do.

  • Jdev  Java Editor: API for 'compare with' option

    Hi,
    For a plug-in that I am working on, I would want to display the diff between two specified files. This is an existing feature in Jdev (10.1.3.3.0.3). Here is the navigation path for the existing feature.
    a. Open an java source
    b. Right click -> Compare with -> Other file
    c. After choosing the file to compare with, the diff is shown in a different editor
    Can you point api(if exists) to the diff editor to which I can specify the two files to compare in some sort of custom plugin.
    Thanks in much anticipation.
    With regards,
    Veerendra S.

    Awaiting inputs. Thanks in anticipation.
    With regards,
    Veerendra S.

  • Customer Statement with opening and closing balances

    Dear Forum,
    The users want to generate the Customer Statement with opening and closing balances like the traditional one. The statement now generated gives the list of all open items as on date, but the users want the statement with opening balances as on the date of the begining of the range specified and the closing balance at the end of the period for which the statement is generated. Is there a way to generate the same from the system.
    Thanks for the help.
    Regards,

    Hi,
    SPRO> Financial Accounting (New) > Accounts Receivable and Accounts Payable > Customer Accounts > Line Items > Correspondence > Make and Check Settings for Correspondence
    You can use the program RFKORD10 with correspondance type SAP06 for your company code
    This program prints account statements and open items lists for customers and vendors in letter form. For account statements, all postings between two key dates, as well as the opening and closing balance, are listed.
    Regards,
    Gaurav

Maybe you are looking for

  • Downloaded Global Address List does not download all fields

    I have my Global Address List from the Exchange Server linked into an Access 2003 database. (Will not link to Access 2007, 2010 format).  There is one field (TITLE) that appears in the structure of the linked table but the data for that field is not

  • Java limitations in sap

    Dear sir, I am java developer i would like to know what is the limitation of using java in SAP customization can we use Java in customizing core SAP R3 or that should be done only in ABAP like customizing the putaway strategy in warehouse management

  • Can a battery be changed in a ipod 30gb  ?

    can a battery be changed in a ipod classic 30gb  ? mine only last 3hrs max...

  • Dataguard Setup

    Hi Guys, I am trying to setup an physical standby across 2 locations in different cities. used RMAN duplicate command to setup an standby database on DR location. Now once RMAN completed, we executed alter database recover managed standby database us

  • Dossier TEMP et Adobe Master Collection et Windows 7(64)

    Bonjour et merci d'avance pour votre précieuse aide. J'ai fait l'acquisition de la Master Collection d'Adobe, mais impossible de la faire fonctionner correctement. A savoir que certains logiciels Photoshop, Indesign, Bridge exige d'être démarré en ta