Skip to content

Commit

Permalink
TxState: new methods to return DiffSets with PropertyValues
Browse files Browse the repository at this point in the history
When we retrieve the actual property values from an index during
an index query, we need to also get the actual property values
from the TX state instead of just the IDs of added nodes.

This adds new methods for 5 index operations to get DiffSets including
the property values.
  • Loading branch information
sherfert committed Aug 14, 2018
1 parent ed11f7a commit cb2edb9
Show file tree
Hide file tree
Showing 10 changed files with 1,084 additions and 225 deletions.
Expand Up @@ -47,6 +47,7 @@ trait NodeIndexSeeker {


// index seek // index seek


// TODO make case class of (NodeValue, Seq[Value]) and use Array instead of Seq
protected def indexSeek(state: QueryState, protected def indexSeek(state: QueryState,
indexReference: IndexReference, indexReference: IndexReference,
propertyIndicesWithValues: Seq[Int], propertyIndicesWithValues: Seq[Int],
Expand Down
@@ -0,0 +1,83 @@
/*
* Copyright (c) 2002-2018 "Neo4j,"
* Neo4j Sweden AB [http://neo4j.com]
*
* This file is part of Neo4j.
*
* Neo4j is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.storageengine.api.txstate;

import java.util.Arrays;
import java.util.Objects;

import org.neo4j.values.storable.Value;

/**
* A node together with properties. This class is needed to present changes in the transaction state to index operations
* that require knowing the affected property values as well.
*
* TODO create interface and impl
*/
public class NodeWithPropertyValues
{

private final long nodeId;
private final Value[] values;

public NodeWithPropertyValues( long nodeId, Value[] values )
{
this.nodeId = nodeId;
this.values = values;
}

public long getNodeId()
{
return nodeId;
}

public Value[] getValues()
{
return values;
}

@Override
public String toString()
{
return "NodeWithPropertyValues{" + "nodeId=" + nodeId + ", values=" + Arrays.toString( values ) + '}';
}

@Override
public boolean equals( Object o )
{
if ( this == o )
{
return true;
}
if ( o == null || getClass() != o.getClass() )
{
return false;
}
NodeWithPropertyValues that = (NodeWithPropertyValues) o;
return nodeId == that.nodeId && Arrays.equals( values, that.values );
}

@Override
public int hashCode()
{
int result = Objects.hash( nodeId );
result = 31 * result + Arrays.hashCode( values );
return result;
}
}
Expand Up @@ -109,16 +109,49 @@ public interface ReadableTransactionState


LongDiffSets indexUpdatesForScan( IndexDescriptor index ); LongDiffSets indexUpdatesForScan( IndexDescriptor index );


/**
* Returns the updates for a particular index as a DiffSets of both Node values and propertyValues.
*
* If property values are not needed, {@link ReadableTransactionState#indexUpdatesForScan(IndexDescriptor)} )}
* should be used instead.
*/
ReadableDiffSets<NodeWithPropertyValues> indexUpdatesWithValuesForScan( IndexDescriptor descriptor );

LongDiffSets indexUpdatesForSuffixOrContains( IndexDescriptor index, IndexQuery query ); LongDiffSets indexUpdatesForSuffixOrContains( IndexDescriptor index, IndexQuery query );


/**
* Returns the updates for a particular range as a DiffSets of both Node values and propertyValues.
*
* If property values are not needed, {@link ReadableTransactionState#indexUpdatesForSuffixOrContains(IndexDescriptor, IndexQuery)} )}
* should be used instead.
*/
ReadableDiffSets<NodeWithPropertyValues> indexUpdatesWithValuesForSuffixOrContains( IndexDescriptor descriptor, IndexQuery query );

LongDiffSets indexUpdatesForSeek( IndexDescriptor index, ValueTuple values ); LongDiffSets indexUpdatesForSeek( IndexDescriptor index, ValueTuple values );


LongDiffSets indexUpdatesForRangeSeek( IndexDescriptor index, ValueGroup valueGroup, LongDiffSets indexUpdatesForRangeSeek( IndexDescriptor index, ValueGroup valueGroup,
Value lower, boolean includeLower, Value lower, boolean includeLower,
Value upper, boolean includeUpper ); Value upper, boolean includeUpper );


/**
* Returns the updates for a particular range as a DiffSets of both Node values and propertyValues.
*
* If property values are not needed, {@link ReadableTransactionState#indexUpdatesForRangeSeek(IndexDescriptor, ValueGroup, Value, boolean, Value, boolean)}
* should be used instead.
*/
ReadableDiffSets<NodeWithPropertyValues> indexUpdatesWithValuesForRangeSeek( IndexDescriptor descriptor, ValueGroup valueGroup, Value lower,
boolean includeLower, Value upper, boolean includeUpper );

LongDiffSets indexUpdatesForRangeSeekByPrefix( IndexDescriptor index, String prefix ); LongDiffSets indexUpdatesForRangeSeekByPrefix( IndexDescriptor index, String prefix );


/**
* Returns the updates for a particular range as a DiffSets of both Node values and propertyValues.
*
* If property values are not needed, {@link ReadableTransactionState#indexUpdatesForRangeSeekByPrefix(IndexDescriptor, String)} )}
* should be used instead.
*/
ReadableDiffSets<NodeWithPropertyValues> indexUpdatesWithValuesForRangeSeekByPrefix( IndexDescriptor descriptor, String prefix );

NodeState getNodeState( long id ); NodeState getNodeState( long id );


RelationshipState getRelationshipState( long id ); RelationshipState getRelationshipState( long id );
Expand Down

0 comments on commit cb2edb9

Please sign in to comment.