Skip to content

Commit

Permalink
Include feedback from review
Browse files Browse the repository at this point in the history
  • Loading branch information
SaschaPeukert committed Oct 15, 2018
1 parent 8f49bd9 commit 79fc72b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
Expand Up @@ -296,7 +296,7 @@ public void testRelsShouldNotDependOnOrderOfCreationWithOverlap2() throws Throwa
} }


@Test @Test
public void testWithNodes() throws Throwable public void testWithAllDifferentNodes() throws Throwable
{ {
// Given // Given


Expand Down Expand Up @@ -403,7 +403,7 @@ public void testWithSimilarNodesShouldNotDependOnOrderOfCreation() throws Throwa
} }


@Test @Test
public void testWithRelationships() throws Throwable public void testWithAllDifferentRelationships() throws Throwable
{ {
// Given // Given


Expand Down
Expand Up @@ -48,9 +48,6 @@ public class SchemaCalculator
{ {
private Map<Integer,String> propertyIdToPropertyNameMapping; private Map<Integer,String> propertyIdToPropertyNameMapping;


private NodeMappings nodeMappings;
private RelationshipMappings relMappings;

private final MutableIntSet emptyPropertyIdSet = IntSets.mutable.empty(); private final MutableIntSet emptyPropertyIdSet = IntSets.mutable.empty();


private final Read dataRead; private final Read dataRead;
Expand All @@ -68,42 +65,42 @@ public class SchemaCalculator
addNamesToCollection( tokenRead.propertyKeyGetAllTokens(), propertyIdToPropertyNameMapping ); addNamesToCollection( tokenRead.propertyKeyGetAllTokens(), propertyIdToPropertyNameMapping );
} }


private void initializeMappingsForNodes() private NodeMappings initializeMappingsForNodes()
{ {
int labelCount = tokenRead.labelCount(); int labelCount = tokenRead.labelCount();
nodeMappings = new NodeMappings( labelCount ); return new NodeMappings( labelCount );
} }


private void initializeMappingsForRels() private RelationshipMappings initializeMappingsForRels()
{ {
int relationshipTypeCount = tokenRead.relationshipTypeCount(); int relationshipTypeCount = tokenRead.relationshipTypeCount();
relMappings = new RelationshipMappings( relationshipTypeCount ); return new RelationshipMappings( relationshipTypeCount );
} }


// If we would have this schema information in the count store (or somewhere), this could be super fast // If we would have this schema information in the count store (or somewhere), this could be super fast
public Stream<NodePropertySchemaInfoResult> calculateTabularResultStreamForNodes() public Stream<NodePropertySchemaInfoResult> calculateTabularResultStreamForNodes()
{ {
initializeMappingsForNodes(); NodeMappings nodeMappings = initializeMappingsForNodes();
scanEverythingBelongingToNodes(); scanEverythingBelongingToNodes(nodeMappings);


// go through all labels to get actual names // go through all labels to get actual names
addNamesToCollection( tokenRead.labelsGetAllTokens(), nodeMappings.labelIdToLabelName ); addNamesToCollection( tokenRead.labelsGetAllTokens(), nodeMappings.labelIdToLabelName );


return produceResultsForNodes().stream(); return produceResultsForNodes(nodeMappings).stream();
} }


public Stream<RelationshipPropertySchemaInfoResult> calculateTabularResultStreamForRels() public Stream<RelationshipPropertySchemaInfoResult> calculateTabularResultStreamForRels()
{ {
initializeMappingsForRels(); RelationshipMappings relMappings = initializeMappingsForRels();
scanEverythingBelongingToRelationships( ); scanEverythingBelongingToRelationships( relMappings );


// go through all relationshipTypes to get actual names // go through all relationshipTypes to get actual names
addNamesToCollection( tokenRead.relationshipTypesGetAllTokens(), relMappings.relationshipTypIdToRelationshipName ); addNamesToCollection( tokenRead.relationshipTypesGetAllTokens(), relMappings.relationshipTypIdToRelationshipName );


return produceResultsForRelationships().stream(); return produceResultsForRelationships( relMappings ).stream();
} }


private List<RelationshipPropertySchemaInfoResult> produceResultsForRelationships() private List<RelationshipPropertySchemaInfoResult> produceResultsForRelationships( RelationshipMappings relMappings )
{ {
List<RelationshipPropertySchemaInfoResult> results = new ArrayList<>(); List<RelationshipPropertySchemaInfoResult> results = new ArrayList<>();
for ( Integer typeId : relMappings.relationshipTypeIdToPropertyKeys.keySet() ) for ( Integer typeId : relMappings.relationshipTypeIdToPropertyKeys.keySet() )
Expand Down Expand Up @@ -139,7 +136,7 @@ private List<RelationshipPropertySchemaInfoResult> produceResultsForRelationship
return results; return results;
} }


private List<NodePropertySchemaInfoResult> produceResultsForNodes() private List<NodePropertySchemaInfoResult> produceResultsForNodes( NodeMappings nodeMappings )
{ {
List<NodePropertySchemaInfoResult> results = new ArrayList<>(); List<NodePropertySchemaInfoResult> results = new ArrayList<>();
for ( SortedLabels labelSet : nodeMappings.labelSetToPropertyKeys.keySet() ) for ( SortedLabels labelSet : nodeMappings.labelSetToPropertyKeys.keySet() )
Expand Down Expand Up @@ -193,7 +190,7 @@ private List<NodePropertySchemaInfoResult> produceResultsForNodes()
return results; return results;
} }


private void scanEverythingBelongingToRelationships( ) private void scanEverythingBelongingToRelationships( RelationshipMappings relMappings )
{ {
try ( RelationshipScanCursor relationshipScanCursor = cursors.allocateRelationshipScanCursor(); try ( RelationshipScanCursor relationshipScanCursor = cursors.allocateRelationshipScanCursor();
PropertyCursor propertyCursor = cursors.allocatePropertyCursor() ) PropertyCursor propertyCursor = cursors.allocatePropertyCursor() )
Expand Down Expand Up @@ -252,7 +249,7 @@ private void scanEverythingBelongingToRelationships( )
} }
} }


private void scanEverythingBelongingToNodes( ) private void scanEverythingBelongingToNodes( NodeMappings nodeMappings )
{ {
try ( NodeCursor nodeCursor = cursors.allocateNodeCursor(); try ( NodeCursor nodeCursor = cursors.allocateNodeCursor();
PropertyCursor propertyCursor = cursors.allocatePropertyCursor() ) PropertyCursor propertyCursor = cursors.allocatePropertyCursor() )
Expand Down

0 comments on commit 79fc72b

Please sign in to comment.