Skip to content

Commit

Permalink
Cleanup based on comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ragadeeshu committed Jun 15, 2018
1 parent 7cc8eec commit 1055659
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 36 deletions.
Expand Up @@ -410,44 +410,29 @@ public String toString()
}

@Override
public int hashCode()
public boolean equals( Object o )
{
final int prime = 31;
int result = 1;
result = prime * result + Arrays.hashCode( entityTokensBefore );
result = prime * result + Arrays.hashCode( entityTokensAfter );
result = prime * result + (int) (entityId ^ (entityId >>> 32));

final IntIterator propertyKeyIds = knownProperties.keySet().intIterator();
while ( propertyKeyIds.hasNext() )
{
int propertyKeyId = propertyKeyIds.next();
result = result * 31 + propertyKeyId;
result = result * 31 + knownProperties.get( propertyKeyId ).hashCode();
}
return result;
}

@Override
public boolean equals( Object obj )
{
if ( this == obj )
if ( this == o )
{
return true;
}
if ( obj == null )
{
return false;
}
if ( getClass() != obj.getClass() )
if ( o == null || getClass() != o.getClass() )
{
return false;
}
EntityUpdates other = (EntityUpdates) obj;
return Arrays.equals( entityTokensBefore, other.entityTokensBefore ) &&
Arrays.equals( entityTokensAfter, other.entityTokensAfter ) &&
entityId == other.entityId &&
Objects.equals( knownProperties, other.knownProperties );
EntityUpdates that = (EntityUpdates) o;
return entityId == that.entityId && Arrays.equals( entityTokensBefore, that.entityTokensBefore ) &&
Arrays.equals( entityTokensAfter, that.entityTokensAfter );
}

@Override
public int hashCode()
{

int result = Objects.hash( entityId );
result = 31 * result + Arrays.hashCode( entityTokensBefore );
result = 31 * result + Arrays.hashCode( entityTokensAfter );
return result;
}

enum PropertyValueType
Expand Down
Expand Up @@ -22,6 +22,7 @@
import org.eclipse.collections.api.set.primitive.IntSet;

import java.util.Set;
import java.util.function.Function;

import org.neo4j.function.ThrowingFunction;
import org.neo4j.internal.kernel.api.schema.SchemaDescriptor;
Expand Down Expand Up @@ -50,7 +51,7 @@ public IndexMap indexMapSnapshot()
* @param modifier the function modifying the snapshot.
* @throws E exception thrown by the function.
*/
public synchronized <E extends Exception> void modify( ThrowingFunction<IndexMap,IndexMap,E> modifier ) throws E
public synchronized <E extends Exception> void modify( Function<IndexMap,IndexMap> modifier ) throws E
{
IndexMap snapshot = indexMapSnapshot();
indexMap = modifier.apply( snapshot );
Expand Down
Expand Up @@ -37,9 +37,9 @@
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ExecutionException;
import java.util.function.Function;

import org.neo4j.function.ThrowingConsumer;
import org.neo4j.function.ThrowingFunction;
import org.neo4j.graphdb.ResourceIterator;
import org.neo4j.helpers.collection.Iterators;
import org.neo4j.internal.kernel.api.InternalIndexState;
Expand Down Expand Up @@ -747,7 +747,7 @@ private void logIndexStateSummary( String method, Map<InternalIndexState,List<In
log.info( format( "IndexingService.%s: indexes not specifically mentioned above are %s", method, mostPopularState ) );
}

private final class IndexPopulationStarter implements ThrowingFunction<IndexMap,IndexMap,IOException>
private final class IndexPopulationStarter implements Function<IndexMap,IndexMap>
{
private final StoreIndexDescriptor[] descriptors;
private IndexPopulationJob nodePopulationJob;
Expand Down
Expand Up @@ -1063,16 +1063,16 @@ public void flushAllIndexesWhileSomeOfThemDropped() throws IOException
public void failForceAllWhenOneOfTheIndexesFailToForce() throws IOException
{
IndexMapReference indexMapReference = new IndexMapReference();
IndexProxy strangeIndexProxy = createIndexProxyMock( 1 );
doThrow( new UncheckedIOException( new IOException( "Can't force" ) ) ).when( strangeIndexProxy ).force( any( IOLimiter.class ) );
indexMapReference.modify( indexMap ->
{
IndexProxy validIndex = createIndexProxyMock( 0 );
indexMap.putIndexProxy( validIndex );
indexMap.putIndexProxy( validIndex );
IndexProxy strangeIndexProxy = createIndexProxyMock( 1 );
indexMap.putIndexProxy( strangeIndexProxy );
indexMap.putIndexProxy( validIndex );
indexMap.putIndexProxy( validIndex );
doThrow( new UncheckedIOException( new IOException( "Can't force" ) ) ).when( strangeIndexProxy ).force( any( IOLimiter.class ) );
return indexMap;
} );

Expand Down

0 comments on commit 1055659

Please sign in to comment.