Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed command aggregation for legacy indexes #6022

Merged
merged 1 commit into from
Dec 7, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,10 @@ private void addCommand( String indexName, IndexCommand command, boolean clearFi
}
else if ( command.getEntityType() == IndexEntityType.Relationship.id() )
{
commands = nodeCommands.get( indexName );
commands = relationshipCommands.get( indexName );
if ( commands == null )
{
nodeCommands.put( indexName, commands = new ArrayList<>() );
relationshipCommands.put( indexName, commands = new ArrayList<>() );
}
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import java.io.IOException;
import java.util.Map;
import java.util.Objects;

import org.neo4j.graphdb.index.Index;
import org.neo4j.kernel.impl.transaction.command.Command;
Expand Down Expand Up @@ -205,22 +206,28 @@ public byte endNodeNeedsLong()
}

@Override
public int hashCode()
public boolean equals( Object o )
{
int result = (int) (startNode ^ (startNode >>> 32));
result = 31 * result + (int) (endNode ^ (endNode >>> 32));
return result;
if ( this == o )
{
return true;
}
if ( o == null || getClass() != o.getClass() )
{
return false;
}
if ( !super.equals( o ) )
{
return false;
}
AddRelationshipCommand that = (AddRelationshipCommand) o;
return startNode == that.startNode && endNode == that.endNode;
}

@Override
public boolean equals( Object obj )
public int hashCode()
{
if ( !super.equals( obj ) )
{
return false;
}
AddRelationshipCommand other = (AddRelationshipCommand) obj;
return startNode == other.startNode && endNode == other.endNode;
return Objects.hash( super.hashCode(), startNode, endNode );
}

@Override
Expand Down Expand Up @@ -297,15 +304,28 @@ public Map<String, String> getConfig()
}

@Override
public int hashCode()
public boolean equals( Object o )
{
return config != null ? config.hashCode() : 0;
if ( this == o )
{
return true;
}
if ( o == null || getClass() != o.getClass() )
{
return false;
}
if ( !super.equals( o ) )
{
return false;
}
CreateCommand that = (CreateCommand) o;
return Objects.equals( config, that.config );
}

@Override
public boolean equals( Object obj )
public int hashCode()
{
return super.equals( obj ) && config.equals( ((CreateCommand)obj).config );
return Objects.hash( super.hashCode(), config );
}

@Override
Expand All @@ -323,20 +343,34 @@ public String toString()
}

@Override
public boolean equals( Object obj )
public boolean equals( Object o )
{
IndexCommand other = (IndexCommand) obj;
boolean equals = getCommandType() == other.getCommandType() &&
entityType == other.entityType &&
indexNameId == other.indexNameId &&
keyId == other.keyId &&
getValueType() == other.getValueType();
if ( !equals )
if ( this == o )
{
return true;
}
if ( o == null || getClass() != o.getClass() )
{
return false;
}
if ( !super.equals( o ) )
{
return false;
}
IndexCommand that = (IndexCommand) o;
return commandType == that.commandType &&
indexNameId == that.indexNameId &&
entityType == that.entityType &&
entityId == that.entityId &&
keyId == that.keyId &&
valueType == that.valueType &&
Objects.equals( value, that.value );
}

return value == null ? other.value == null : value.equals( other.value );
@Override
public int hashCode()
{
return Objects.hash( super.hashCode(), commandType, indexNameId, entityType, entityId, keyId, valueType, value );
}

public byte getCommandType()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;

import org.neo4j.collection.primitive.Primitive;
Expand All @@ -31,7 +32,6 @@
import org.neo4j.kernel.impl.transaction.command.NeoCommandHandler;

import static java.lang.String.format;

import static org.neo4j.collection.primitive.Primitive.intObjectMap;

/**
Expand Down Expand Up @@ -142,25 +142,35 @@ private int getOrAssignId( Map<String,Integer> stringToId, PrimitiveIntObjectMap
return id;
}


@Override
public int hashCode()
public boolean equals( Object o )
{
int result = nextIndexNameId != null ? nextIndexNameId.hashCode() : 0;
result = 31 * result + (nextKeyId != null ? nextKeyId.hashCode() : 0);
result = 31 * result + (getIndexNameIdRange() != null ? getIndexNameIdRange().hashCode() : 0);
result = 31 * result + (getKeyIdRange() != null ? getKeyIdRange().hashCode() : 0);
result = 31 * result + (idToIndexName != null ? idToIndexName.hashCode() : 0);
result = 31 * result + (idToKey != null ? idToKey.hashCode() : 0);
return result;
if ( this == o )
{
return true;
}
if ( o == null || getClass() != o.getClass() )
{
return false;
}
if ( !super.equals( o ) )
{
return false;
}
IndexDefineCommand that = (IndexDefineCommand) o;
return nextIndexNameId.get() == that.nextIndexNameId.get() &&
nextKeyId.get() == that.nextKeyId.get() &&
Objects.equals( indexNameIdRange, that.indexNameIdRange ) &&
Objects.equals( keyIdRange, that.keyIdRange ) &&
Objects.equals( idToIndexName, that.idToIndexName ) &&
Objects.equals( idToKey, that.idToKey );
}

@Override
public boolean equals( Object obj )
public int hashCode()
{
IndexDefineCommand other = (IndexDefineCommand) obj;
return getIndexNameIdRange().equals( other.getIndexNameIdRange() ) &&
getKeyIdRange().equals( other.getKeyIdRange() );
return Objects.hash( super.hashCode(), nextIndexNameId.get(), nextKeyId.get(), indexNameIdRange, keyIdRange,
idToIndexName, idToKey );
}

@Override
Expand Down