You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@clerezza.apache.org by "Rupert Westenthaler (Created) (JIRA)" <ji...@apache.org> on 2012/02/08 08:15:00 UTC

[jira] [Created] (CLEREZZA-686) LockableMGraphWrapper does not implement hashCode, equals and toString

LockableMGraphWrapper does not implement hashCode, equals and toString
----------------------------------------------------------------------

                 Key: CLEREZZA-686
                 URL: https://issues.apache.org/jira/browse/CLEREZZA-686
             Project: Clerezza
          Issue Type: Improvement
          Components: rdf.core
            Reporter: Rupert Westenthaler
            Priority: Trivial


LockableMGraphWrapper does not implement hashCode, equals and toString. This is not a big issue, because MGraphs are rarely used with sets or maps, but it is at least inconvenient for logging and debugging.


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (CLEREZZA-686) LockableMGraphWrapper does not implement hashCode, equals and toString

Posted by "Daniel Spicar (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CLEREZZA-686?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13203513#comment-13203513 ] 

Daniel Spicar commented on CLEREZZA-686:
----------------------------------------

About locking:

I'm just thinking in terms of interface contract here. Current MGraphs do not need locks (and I can't think of any currently that would need it ever) but I don't know the future. There is nothing that disallows an Mgraph to read (or even write, even though that sound silly) in the toString/hashCode/ewuals methods. The options I see:

- Ignore the problem, it might never occur
- Document it as an interface contract somewhere - where? With the current type system it may be necessary in the MGraph interface because we just wrap generic MGraphs with LockableMGraphWrapper in TcProviderMultiplexer.
- Restrict what can be wrapped by LockableMGraphWrapper by introducing some other type requirements.

Just looking for some consensus on this issue.


                
> LockableMGraphWrapper does not implement hashCode, equals and toString
> ----------------------------------------------------------------------
>
>                 Key: CLEREZZA-686
>                 URL: https://issues.apache.org/jira/browse/CLEREZZA-686
>             Project: Clerezza
>          Issue Type: Improvement
>          Components: rdf.core
>            Reporter: Rupert Westenthaler
>            Assignee: Daniel Spicar
>            Priority: Trivial
>         Attachments: CLEREZZA-686_rdf.core-LockableMGraphWrapper-hasCode-equals-toString.patch
>
>
> LockableMGraphWrapper does not implement hashCode, equals and toString. This is not a big issue, because MGraphs are rarely used with sets or maps, but it is at least inconvenient for logging and debugging.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Resolved] (CLEREZZA-686) LockableMGraphWrapper does not implement hashCode, equals and toString

Posted by "Daniel Spicar (Resolved) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CLEREZZA-686?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Daniel Spicar resolved CLEREZZA-686.
------------------------------------

    Resolution: Fixed

Changed equals to adhere to equals specification.
                
> LockableMGraphWrapper does not implement hashCode, equals and toString
> ----------------------------------------------------------------------
>
>                 Key: CLEREZZA-686
>                 URL: https://issues.apache.org/jira/browse/CLEREZZA-686
>             Project: Clerezza
>          Issue Type: Improvement
>          Components: rdf.core
>            Reporter: Rupert Westenthaler
>            Assignee: Daniel Spicar
>            Priority: Trivial
>         Attachments: CLEREZZA-686_rdf.core-LockableMGraphWrapper-hasCode-equals-toString.patch
>
>
> LockableMGraphWrapper does not implement hashCode, equals and toString. This is not a big issue, because MGraphs are rarely used with sets or maps, but it is at least inconvenient for logging and debugging.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Resolved] (CLEREZZA-686) LockableMGraphWrapper does not implement hashCode, equals and toString

Posted by "Daniel Spicar (Resolved) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CLEREZZA-686?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Daniel Spicar resolved CLEREZZA-686.
------------------------------------

    Resolution: Fixed

I committed an implementation that simply delegates all the calls to the wrapped instance without locking.
                
> LockableMGraphWrapper does not implement hashCode, equals and toString
> ----------------------------------------------------------------------
>
>                 Key: CLEREZZA-686
>                 URL: https://issues.apache.org/jira/browse/CLEREZZA-686
>             Project: Clerezza
>          Issue Type: Improvement
>          Components: rdf.core
>            Reporter: Rupert Westenthaler
>            Assignee: Daniel Spicar
>            Priority: Trivial
>         Attachments: CLEREZZA-686_rdf.core-LockableMGraphWrapper-hasCode-equals-toString.patch
>
>
> LockableMGraphWrapper does not implement hashCode, equals and toString. This is not a big issue, because MGraphs are rarely used with sets or maps, but it is at least inconvenient for logging and debugging.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (CLEREZZA-686) LockableMGraphWrapper does not implement hashCode, equals and toString

Posted by "Daniel Spicar (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CLEREZZA-686?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13207603#comment-13207603 ] 

Daniel Spicar commented on CLEREZZA-686:
----------------------------------------

Hmm that is true. But it means that that g and w are different graphs because:
- g does not equals w 
and 
- w does not equal g

An implementation according to this would be:

	public boolean equals(Object obj) {
		if(obj == null) {
			return false;
		}
		if(obj == this) {
			return true;
		}
		if(obj.getClass() != getClass()) {
			return false;
		}
		
		LockableMGraphWrapper other = (LockableMGraphWrapper) obj;
		return wrapped.equals(other.wrapped);
	}

Now how would we test two graphs for graph equality (such that g and w are the same graph) while maintaining symmetry? If we had something like a graph ID in protected scope we could do that by persistently comparing the IDs in all equal implementations in all Graphs.

What do you think? Is it even necessary?
                
> LockableMGraphWrapper does not implement hashCode, equals and toString
> ----------------------------------------------------------------------
>
>                 Key: CLEREZZA-686
>                 URL: https://issues.apache.org/jira/browse/CLEREZZA-686
>             Project: Clerezza
>          Issue Type: Improvement
>          Components: rdf.core
>            Reporter: Rupert Westenthaler
>            Assignee: Daniel Spicar
>            Priority: Trivial
>         Attachments: CLEREZZA-686_rdf.core-LockableMGraphWrapper-hasCode-equals-toString.patch
>
>
> LockableMGraphWrapper does not implement hashCode, equals and toString. This is not a big issue, because MGraphs are rarely used with sets or maps, but it is at least inconvenient for logging and debugging.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (CLEREZZA-686) LockableMGraphWrapper does not implement hashCode, equals and toString

Posted by "Rupert Westenthaler (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CLEREZZA-686?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13203445#comment-13203445 ] 

Rupert Westenthaler commented on CLEREZZA-686:
----------------------------------------------

+1 for delegating to the wrapped MGraph instead of calling super. This was in fact my intension ... but I must have overlooked that the eclipse code completion had already inserted super.{method}. ... sorry for that.

                
> LockableMGraphWrapper does not implement hashCode, equals and toString
> ----------------------------------------------------------------------
>
>                 Key: CLEREZZA-686
>                 URL: https://issues.apache.org/jira/browse/CLEREZZA-686
>             Project: Clerezza
>          Issue Type: Improvement
>          Components: rdf.core
>            Reporter: Rupert Westenthaler
>            Assignee: Daniel Spicar
>            Priority: Trivial
>         Attachments: CLEREZZA-686_rdf.core-LockableMGraphWrapper-hasCode-equals-toString.patch
>
>
> LockableMGraphWrapper does not implement hashCode, equals and toString. This is not a big issue, because MGraphs are rarely used with sets or maps, but it is at least inconvenient for logging and debugging.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Assigned] (CLEREZZA-686) LockableMGraphWrapper does not implement hashCode, equals and toString

Posted by "Daniel Spicar (Assigned) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CLEREZZA-686?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Daniel Spicar reassigned CLEREZZA-686:
--------------------------------------

    Assignee: Daniel Spicar
    
> LockableMGraphWrapper does not implement hashCode, equals and toString
> ----------------------------------------------------------------------
>
>                 Key: CLEREZZA-686
>                 URL: https://issues.apache.org/jira/browse/CLEREZZA-686
>             Project: Clerezza
>          Issue Type: Improvement
>          Components: rdf.core
>            Reporter: Rupert Westenthaler
>            Assignee: Daniel Spicar
>            Priority: Trivial
>         Attachments: CLEREZZA-686_rdf.core-LockableMGraphWrapper-hasCode-equals-toString.patch
>
>
> LockableMGraphWrapper does not implement hashCode, equals and toString. This is not a big issue, because MGraphs are rarely used with sets or maps, but it is at least inconvenient for logging and debugging.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Reopened] (CLEREZZA-686) LockableMGraphWrapper does not implement hashCode, equals and toString

Posted by "Reto Bachmann-Gmür (Reopened JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CLEREZZA-686?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Reto Bachmann-Gmür reopened CLEREZZA-686:
-----------------------------------------


I realize the patch implements my suggestion, but it just occurs to me that it breaks the spec for equals as it is no longer symmetric.

e.g:

val g = new SomeMGraph()
val w = new LockableMGraphWrapper(g);


q.equals(w) != w.equals(g)

So I think the correct implementation would be to call wrapped.equals(other.wrapped) iff other is a LockableMGraphWrapper and return false otherwise.

                
> LockableMGraphWrapper does not implement hashCode, equals and toString
> ----------------------------------------------------------------------
>
>                 Key: CLEREZZA-686
>                 URL: https://issues.apache.org/jira/browse/CLEREZZA-686
>             Project: Clerezza
>          Issue Type: Improvement
>          Components: rdf.core
>            Reporter: Rupert Westenthaler
>            Assignee: Daniel Spicar
>            Priority: Trivial
>         Attachments: CLEREZZA-686_rdf.core-LockableMGraphWrapper-hasCode-equals-toString.patch
>
>
> LockableMGraphWrapper does not implement hashCode, equals and toString. This is not a big issue, because MGraphs are rarely used with sets or maps, but it is at least inconvenient for logging and debugging.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Updated] (CLEREZZA-686) LockableMGraphWrapper does not implement hashCode, equals and toString

Posted by "Rupert Westenthaler (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CLEREZZA-686?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rupert Westenthaler updated CLEREZZA-686:
-----------------------------------------

    Attachment: CLEREZZA-686_rdf.core-LockableMGraphWrapper-hasCode-equals-toString.patch

This patch uses read locks for all three methods. I have no idea if this is really required for all thee methods.
                
> LockableMGraphWrapper does not implement hashCode, equals and toString
> ----------------------------------------------------------------------
>
>                 Key: CLEREZZA-686
>                 URL: https://issues.apache.org/jira/browse/CLEREZZA-686
>             Project: Clerezza
>          Issue Type: Improvement
>          Components: rdf.core
>            Reporter: Rupert Westenthaler
>            Priority: Trivial
>         Attachments: CLEREZZA-686_rdf.core-LockableMGraphWrapper-hasCode-equals-toString.patch
>
>
> LockableMGraphWrapper does not implement hashCode, equals and toString. This is not a big issue, because MGraphs are rarely used with sets or maps, but it is at least inconvenient for logging and debugging.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (CLEREZZA-686) LockableMGraphWrapper does not implement hashCode, equals and toString

Posted by "Reto Bachmann-Gmür (Commented JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CLEREZZA-686?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13203440#comment-13203440 ] 

Reto Bachmann-Gmür commented on CLEREZZA-686:
---------------------------------------------

Just delegating to the inherited hashCode and equals from Object satisfies the contract and poses no synchronization issues. Delegating to the wrapped MGraph would be better, a locking isn't needed in this case either as an MGraph doesn't change its identity by triples being added or removed.
                
> LockableMGraphWrapper does not implement hashCode, equals and toString
> ----------------------------------------------------------------------
>
>                 Key: CLEREZZA-686
>                 URL: https://issues.apache.org/jira/browse/CLEREZZA-686
>             Project: Clerezza
>          Issue Type: Improvement
>          Components: rdf.core
>            Reporter: Rupert Westenthaler
>            Assignee: Daniel Spicar
>            Priority: Trivial
>         Attachments: CLEREZZA-686_rdf.core-LockableMGraphWrapper-hasCode-equals-toString.patch
>
>
> LockableMGraphWrapper does not implement hashCode, equals and toString. This is not a big issue, because MGraphs are rarely used with sets or maps, but it is at least inconvenient for logging and debugging.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Commented] (CLEREZZA-686) LockableMGraphWrapper does not implement hashCode, equals and toString

Posted by "Daniel Spicar (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CLEREZZA-686?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13203429#comment-13203429 ] 

Daniel Spicar commented on CLEREZZA-686:
----------------------------------------

I am not sure what the intention of this patch is. As I see it you are wrapping calls to Object.hashCode/Object.equals/Object.toString into readLocks (i.e. you call super.hashcode). I assume what we really want, are delegation to wrapped.hashCode etc., i.e. the hashCode method by the wrapped graph. Going there I see the following issues:
- MGraph defines the interface for the equals method to be: "Returns true if other represents the same mutable graph as this instance, false otherwise. It returns true if this == other or if it s otherwise guaranteed that changes to one of the instances are immediately reflected in the other." Given this description I think the current equals implementation is wrong, we need to delegate the call to the wrapped Mgraph instance.
- From my understanding the read or write locks are only needed when reading from/writing to the wrapped MGraph. Since we ware not doing it currently, I don't think the locks are needed in this patch.
- However when we call the methods on the wrapped instance, then we may need them since we do not know how they are implemented there. But technically we don't even know whether the implementation there does write access to the graph (although I can't think of a reason why it would do that).

I think in general we want to delegate the calls to the wrapped MGraph instance. Intuitively I would put these calls in a readlock to be sure. Probably that will be fine. But from my knowledge the contract of these methods does not restrict the MGraph Implementation to read access only so theoretically there is a potential problem. But does it make sense to redefine the contract of the MGraph interface for hashCode, toString, and equals to be read access only? I'm not sure how this is handled elsewhere.
                
> LockableMGraphWrapper does not implement hashCode, equals and toString
> ----------------------------------------------------------------------
>
>                 Key: CLEREZZA-686
>                 URL: https://issues.apache.org/jira/browse/CLEREZZA-686
>             Project: Clerezza
>          Issue Type: Improvement
>          Components: rdf.core
>            Reporter: Rupert Westenthaler
>            Assignee: Daniel Spicar
>            Priority: Trivial
>         Attachments: CLEREZZA-686_rdf.core-LockableMGraphWrapper-hasCode-equals-toString.patch
>
>
> LockableMGraphWrapper does not implement hashCode, equals and toString. This is not a big issue, because MGraphs are rarely used with sets or maps, but it is at least inconvenient for logging and debugging.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (CLEREZZA-686) LockableMGraphWrapper does not implement hashCode, equals and toString

Posted by "Reto Bachmann-Gmür (Commented JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CLEREZZA-686?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13211729#comment-13211729 ] 

Reto Bachmann-Gmür commented on CLEREZZA-686:
---------------------------------------------

I don't think that there is any major disadvantage in g and w not being equals. There is an advantage in multiple lockableMGaph over the same MGraph as being equals, so I think the implemementation in your comment is just fine.
                
> LockableMGraphWrapper does not implement hashCode, equals and toString
> ----------------------------------------------------------------------
>
>                 Key: CLEREZZA-686
>                 URL: https://issues.apache.org/jira/browse/CLEREZZA-686
>             Project: Clerezza
>          Issue Type: Improvement
>          Components: rdf.core
>            Reporter: Rupert Westenthaler
>            Assignee: Daniel Spicar
>            Priority: Trivial
>         Attachments: CLEREZZA-686_rdf.core-LockableMGraphWrapper-hasCode-equals-toString.patch
>
>
> LockableMGraphWrapper does not implement hashCode, equals and toString. This is not a big issue, because MGraphs are rarely used with sets or maps, but it is at least inconvenient for logging and debugging.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira