Andy,

You might consider caching the hash code once it is calculated.  I assume
you use this object in hash maps or hash sets where the hash code needs to
be retrieve many times - O(log(n)?  per operation.  In this case caching
may show a performance improvement.

Claude

On Mon, Nov 3, 2014 at 8:24 PM, <[email protected]> wrote:

> Repository: jena
> Updated Branches:
>   refs/heads/master 1f2642ad1 -> be8f0aea6
>
>
> hashCode and .equals (auto-generated)
>
> Project: http://git-wip-us.apache.org/repos/asf/jena/repo
> Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/be8f0aea
> Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/be8f0aea
> Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/be8f0aea
>
> Branch: refs/heads/master
> Commit: be8f0aea68df5caecc287ca612d7af00231d553f
> Parents: 1f2642a
> Author: Andy Seaborne <[email protected]>
> Authored: Mon Nov 3 20:24:30 2014 +0000
> Committer: Andy Seaborne <[email protected]>
> Committed: Mon Nov 3 20:24:30 2014 +0000
>
> ----------------------------------------------------------------------
>  .../com/hp/hpl/jena/tdb/setup/StoreParams.java  | 99 ++++++++++++++++++++
>  1 file changed, 99 insertions(+)
> ----------------------------------------------------------------------
>
>
>
> http://git-wip-us.apache.org/repos/asf/jena/blob/be8f0aea/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/StoreParams.java
> ----------------------------------------------------------------------
> diff --git
> a/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/StoreParams.java
> b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/StoreParams.java
> index 63fdef5..7c1829b 100644
> --- a/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/StoreParams.java
> +++ b/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/setup/StoreParams.java
> @@ -18,6 +18,8 @@
>
>  package com.hp.hpl.jena.tdb.setup;
>
> +import java.util.Arrays ;
> +
>  import org.apache.jena.atlas.lib.StrUtils ;
>
>  import com.hp.hpl.jena.tdb.base.block.FileMode ;
> @@ -207,5 +209,102 @@ public class StoreParams implements IndexParams
>          buff.append(String.format("%-20s   %s\n", name, value)) ;
>      }
>
> +    @Override
> +    public int hashCode() {
> +        final int prime = 31 ;
> +        int result = 1 ;
> +        result = prime * result + Node2NodeIdCacheSize ;
> +        result = prime * result + NodeId2NodeCacheSize ;
> +        result = prime * result + NodeMissCacheSize ;
> +        result = prime * result + blockReadCacheSize ;
> +        result = prime * result + blockSize ;
> +        result = prime * result + blockWriteCacheSize ;
> +        result = prime * result + ((fileMode == null) ? 0 :
> fileMode.hashCode()) ;
> +        result = prime * result + ((indexId2Node == null) ? 0 :
> indexId2Node.hashCode()) ;
> +        result = prime * result + ((indexNode2Id == null) ? 0 :
> indexNode2Id.hashCode()) ;
> +        result = prime * result + ((indexPrefix == null) ? 0 :
> indexPrefix.hashCode()) ;
> +        result = prime * result + ((prefixId2Node == null) ? 0 :
> prefixId2Node.hashCode()) ;
> +        result = prime * result + Arrays.hashCode(prefixIndexes) ;
> +        result = prime * result + ((prefixNode2Id == null) ? 0 :
> prefixNode2Id.hashCode()) ;
> +        result = prime * result + ((primaryIndexPrefix == null) ? 0 :
> primaryIndexPrefix.hashCode()) ;
> +        result = prime * result + ((primaryIndexQuads == null) ? 0 :
> primaryIndexQuads.hashCode()) ;
> +        result = prime * result + ((primaryIndexTriples == null) ? 0 :
> primaryIndexTriples.hashCode()) ;
> +        result = prime * result + Arrays.hashCode(quadIndexes) ;
> +        result = prime * result + Arrays.hashCode(tripleIndexes) ;
> +        return result ;
> +    }
> +
> +    @Override
> +    public boolean equals(Object obj) {
> +        if ( this == obj )
> +            return true ;
> +        if ( obj == null )
> +            return false ;
> +        if ( getClass() != obj.getClass() )
> +            return false ;
> +        StoreParams other = (StoreParams)obj ;
> +        if ( Node2NodeIdCacheSize != other.Node2NodeIdCacheSize )
> +            return false ;
> +        if ( NodeId2NodeCacheSize != other.NodeId2NodeCacheSize )
> +            return false ;
> +        if ( NodeMissCacheSize != other.NodeMissCacheSize )
> +            return false ;
> +        if ( blockReadCacheSize != other.blockReadCacheSize )
> +            return false ;
> +        if ( blockSize != other.blockSize )
> +            return false ;
> +        if ( blockWriteCacheSize != other.blockWriteCacheSize )
> +            return false ;
> +        if ( fileMode != other.fileMode )
> +            return false ;
> +        if ( indexId2Node == null ) {
> +            if ( other.indexId2Node != null )
> +                return false ;
> +        } else if ( !indexId2Node.equals(other.indexId2Node) )
> +            return false ;
> +        if ( indexNode2Id == null ) {
> +            if ( other.indexNode2Id != null )
> +                return false ;
> +        } else if ( !indexNode2Id.equals(other.indexNode2Id) )
> +            return false ;
> +        if ( indexPrefix == null ) {
> +            if ( other.indexPrefix != null )
> +                return false ;
> +        } else if ( !indexPrefix.equals(other.indexPrefix) )
> +            return false ;
> +        if ( prefixId2Node == null ) {
> +            if ( other.prefixId2Node != null )
> +                return false ;
> +        } else if ( !prefixId2Node.equals(other.prefixId2Node) )
> +            return false ;
> +        if ( !Arrays.equals(prefixIndexes, other.prefixIndexes) )
> +            return false ;
> +        if ( prefixNode2Id == null ) {
> +            if ( other.prefixNode2Id != null )
> +                return false ;
> +        } else if ( !prefixNode2Id.equals(other.prefixNode2Id) )
> +            return false ;
> +        if ( primaryIndexPrefix == null ) {
> +            if ( other.primaryIndexPrefix != null )
> +                return false ;
> +        } else if ( !primaryIndexPrefix.equals(other.primaryIndexPrefix) )
> +            return false ;
> +        if ( primaryIndexQuads == null ) {
> +            if ( other.primaryIndexQuads != null )
> +                return false ;
> +        } else if ( !primaryIndexQuads.equals(other.primaryIndexQuads) )
> +            return false ;
> +        if ( primaryIndexTriples == null ) {
> +            if ( other.primaryIndexTriples != null )
> +                return false ;
> +        } else if (
> !primaryIndexTriples.equals(other.primaryIndexTriples) )
> +            return false ;
> +        if ( !Arrays.equals(quadIndexes, other.quadIndexes) )
> +            return false ;
> +        if ( !Arrays.equals(tripleIndexes, other.tripleIndexes) )
> +            return false ;
> +        return true ;
> +    }
> +
>  }
>
>
>


-- 
I like: Like Like - The likeliest place on the web
<http://like-like.xenei.com>
LinkedIn: http://www.linkedin.com/in/claudewarren

Reply via email to