Skip to content

Commit

Permalink
Final changes to procedure signature and structure
Browse files Browse the repository at this point in the history
  • Loading branch information
SaschaPeukert committed Oct 15, 2018
1 parent 79fc72b commit d01636f
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 93 deletions.

Large diffs are not rendered by default.

Expand Up @@ -149,11 +149,12 @@ public void listProcedures() throws Throwable
"Show the schema of the data.", "READ" ),
proc( "db.schema.visualization","() :: (nodes :: LIST? OF NODE?, relationships :: LIST? OF RELATIONSHIP?)",
"Visualize the schema of the data. Replaces db.schema.", "READ" ),
proc( "db.schema.nodeProperties", "() :: (nodeType :: STRING?, propertyName :: STRING?, " +
"propertyTypes :: LIST? OF STRING?, mandatory :: BOOLEAN?)", "Show the derived property schema of the nodes in tabular form.",
"READ" ),
proc( "db.schema.edgeProperties", "() :: (relationshipType :: STRING?, propertyName :: STRING?, " +
proc( "db.schema.nodeTypeProperties",
"() :: (nodeType :: STRING?, nodeLabels :: LIST? OF STRING?, propertyName :: STRING?, " +
"propertyTypes :: LIST? OF STRING?, mandatory :: BOOLEAN?)",
"Show the derived property schema of the nodes in tabular form.", "READ" ),
proc( "db.schema.relTypeProperties", "() :: (relType :: STRING?, " +
"propertyName :: STRING?, propertyTypes :: LIST? OF STRING?, mandatory :: BOOLEAN?)",
"Show the derived property schema of the relationships in tabular form.", "READ" ),
proc( "db.relationshipTypes", "() :: (relationshipType :: " + "STRING?)",
"List all relationship types in the database.", "READ" ),
Expand Down
Expand Up @@ -215,14 +215,14 @@ public void resampleOutdatedIndexes()
}
}

@Procedure( name = "db.schema.nodeProperties", mode = Mode.READ )
@Procedure( name = "db.schema.nodeTypeProperties", mode = Mode.READ )
@Description( "Show the derived property schema of the nodes in tabular form." )
public Stream<NodePropertySchemaInfoResult> nodePropertySchema()
{
return new SchemaCalculator( tx ).calculateTabularResultStreamForNodes();
}

@Procedure( name = "db.schema.edgeProperties", mode = Mode.READ )
@Procedure( name = "db.schema.relTypeProperties", mode = Mode.READ )
@Description( "Show the derived property schema of the relationships in tabular form." )
public Stream<RelationshipPropertySchemaInfoResult> relationshipPropertySchema()
{
Expand Down
Expand Up @@ -24,10 +24,14 @@
public class NodePropertySchemaInfoResult
{
/**
* A combination of labels interleaved by ":"
* A combination of escaped label names interleaved by ":"
*/
public final String nodeType;

/**
* A list of label names
*/
public final List<String> nodeLabels;
/**
* A property name that occurs on the given label combination or null
*/
Expand All @@ -43,9 +47,10 @@ public class NodePropertySchemaInfoResult
*/
public final boolean mandatory;

public NodePropertySchemaInfoResult( String nodeLabels, String propertyName, List<String> cypherTypes, boolean mandatory )
public NodePropertySchemaInfoResult( String nodeType, List<String> nodeLabelsList, String propertyName, List<String> cypherTypes, boolean mandatory )
{
this.nodeType = nodeLabels;
this.nodeType = nodeType;
this.nodeLabels = nodeLabelsList;
this.propertyName = propertyName;
this.propertyTypes = cypherTypes;
this.mandatory = mandatory;
Expand Down
Expand Up @@ -26,7 +26,7 @@ public class RelationshipPropertySchemaInfoResult
/**
* A relationship type
*/
public final String relationshipType;
public final String relType;

/**
* A property name that occurs on the given relationship type or null
Expand All @@ -45,7 +45,7 @@ public class RelationshipPropertySchemaInfoResult

public RelationshipPropertySchemaInfoResult( String relType, String propertyName, List<String> cypherTypes, boolean mandatory )
{
this.relationshipType = relType;
this.relType = relType;
this.propertyName = propertyName;
this.propertyTypes = cypherTypes;
this.mandatory = mandatory;
Expand Down
Expand Up @@ -86,7 +86,7 @@ public Stream<NodePropertySchemaInfoResult> calculateTabularResultStreamForNodes
// go through all labels to get actual names
addNamesToCollection( tokenRead.labelsGetAllTokens(), nodeMappings.labelIdToLabelName );

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

public Stream<RelationshipPropertySchemaInfoResult> calculateTabularResultStreamForRels()
Expand All @@ -107,6 +107,7 @@ private List<RelationshipPropertySchemaInfoResult> produceResultsForRelationship
{
// lookup typ name
String name = relMappings.relationshipTypIdToRelationshipName.get( typeId );
name = ":`" + name + "`"; // escaping

// lookup property value types
MutableIntSet propertyIds = relMappings.relationshipTypeIdToPropertyKeys.get( typeId );
Expand All @@ -116,18 +117,19 @@ private List<RelationshipPropertySchemaInfoResult> produceResultsForRelationship
}
else
{
String finalName = name;
propertyIds.forEach( propId -> {
// lookup propId name and valueGroup
String propName = propertyIdToPropertyNameMapping.get( propId );
ValueTypeListHelper valueTypeListHelper = relMappings.relationshipTypeIdANDPropertyTypeIdToValueType.get( Pair.of( typeId, propId ) );
if ( relMappings.nullableRelationshipTypes.contains( typeId ) )
{
results.add( new RelationshipPropertySchemaInfoResult( name, propName, valueTypeListHelper.getCypherTypesList(),
results.add( new RelationshipPropertySchemaInfoResult( finalName, propName, valueTypeListHelper.getCypherTypesList(),
false ) );
}
else
{
results.add( new RelationshipPropertySchemaInfoResult( name, propName, valueTypeListHelper.getCypherTypesList(),
results.add( new RelationshipPropertySchemaInfoResult( finalName, propName, valueTypeListHelper.getCypherTypesList(),
valueTypeListHelper.isMandatory() ) );
}
} );
Expand All @@ -152,22 +154,15 @@ private List<NodePropertySchemaInfoResult> produceResultsForNodes( NodeMappings
StringBuilder labelsConcatenator = new StringBuilder();
for ( String item : labelNames )
{
if ( labelsConcatenator.toString().equals( "" ) )
{
labelsConcatenator.append( item );
}
else
{
labelsConcatenator.append( ":" ).append( item );
}
labelsConcatenator.append( ":`" ).append( item ).append( "`" );
}
String labels = labelsConcatenator.toString();

// lookup property value types
MutableIntSet propertyIds = nodeMappings.labelSetToPropertyKeys.get( labelSet );
if ( propertyIds.size() == 0 )
{
results.add( new NodePropertySchemaInfoResult( labels, null, null, false ) );
results.add( new NodePropertySchemaInfoResult( labels, labelNames, null, null, false ) );
}
else
{
Expand All @@ -177,11 +172,11 @@ private List<NodePropertySchemaInfoResult> produceResultsForNodes( NodeMappings
ValueTypeListHelper valueTypeListHelper = nodeMappings.labelSetANDNodePropertyKeyIdToValueType.get( Pair.of( labelSet, propId ) );
if ( nodeMappings.nullableLabelSets.contains( labelSet ) )
{
results.add( new NodePropertySchemaInfoResult( labels, propName, valueTypeListHelper.getCypherTypesList(), false ) );
results.add( new NodePropertySchemaInfoResult( labels, labelNames, propName, valueTypeListHelper.getCypherTypesList(), false ) );
}
else
{
results.add( new NodePropertySchemaInfoResult( labels, propName, valueTypeListHelper.getCypherTypesList(),
results.add( new NodePropertySchemaInfoResult( labels, labelNames, propName, valueTypeListHelper.getCypherTypesList(),
valueTypeListHelper.isMandatory() ) );
}
} );
Expand Down
Expand Up @@ -289,13 +289,13 @@ public void shouldListCorrectBuiltinProcedures() throws Throwable
record( "db.schema.visualization",
"db.schema.visualization() :: (nodes :: LIST? OF NODE?, relationships :: LIST? OF RELATIONSHIP?)",
"Visualize the schema of the data. Replaces db.schema.", "READ" ),
record( "db.schema.nodeProperties",
"db.schema.nodeProperties() :: (nodeType :: STRING?, propertyName :: STRING?," +
" propertyTypes :: LIST? OF STRING?, mandatory :: BOOLEAN?)",
"Show the derived property schema of the nodes in tabular form.", "READ" ),
record( "db.schema.edgeProperties",
"db.schema.edgeProperties() :: (relationshipType :: STRING?, propertyName :: STRING?, " +
record( "db.schema.nodeTypeProperties",
"db.schema.nodeTypeProperties() :: (nodeType :: STRING?, nodeLabels :: LIST? OF STRING?, propertyName :: STRING?, " +
"propertyTypes :: LIST? OF STRING?, mandatory :: BOOLEAN?)",
"Show the derived property schema of the nodes in tabular form.", "READ" ),
record( "db.schema.relTypeProperties",
"db.schema.relTypeProperties() :: (relType :: STRING?, propertyName :: STRING?, propertyTypes :: LIST? OF STRING?," +
" mandatory :: BOOLEAN?)",
"Show the derived property schema of the relationships in tabular form.", "READ" ),
record( "db.index.explicit.searchNodes",
"db.index.explicit.searchNodes(indexName :: STRING?, query :: ANY?) :: (node :: NODE?, weight :: FLOAT?)",
Expand Down

0 comments on commit d01636f

Please sign in to comment.