void loadVertexIndices ( GraphTraversalSource traversalSource , Vertex schemaVertex ) { List < Path > indices = traversalSource . V ( schemaVertex ) . out ( SQLG_SCHEMA_SCHEMA_VERTEX_EDGE ) . as ( "vertex" ) . out ( SQLG_SCHEMA_VERTEX_INDEX_EDGE ) . as ( "index" ) . outE ( SQLG_SCHEMA_INDEX_PROPERTY_EDGE ) . order ( ) . by ( SQLG_SCHEMA_INDEX_PROPERTY_EDGE_SEQUENCE ) . inV ( ) . as ( "property" ) . path ( ) . toList ( ) ; for ( Path vertexIndices : indices ) { Vertex vertexVertex = null ; Vertex vertexIndex = null ; Vertex propertyIndex = null ; List < Set < String > > labelsList = vertexIndices . labels ( ) ; for ( Set < String > labels : labelsList ) { for ( String label : labels ) { switch ( label ) { case "vertex" : vertexVertex = vertexIndices . get ( "vertex" ) ; break ; case "index" : vertexIndex = vertexIndices . get ( "index" ) ; break ; case "property" : propertyIndex = vertexIndices . get ( "property" ) ; break ; case BaseStrategy . SQLG_PATH_FAKE_LABEL : case BaseStrategy . SQLG_PATH_ORDER_RANGE_LABEL : case Schema . MARKER : break ; default : throw new IllegalStateException ( String . format ( "BUG: Only \"vertex\",\"index\" and \"property\" is expected as a label. Found %s" , label ) ) ; } } } Preconditions . checkState ( vertexVertex != null , "BUG: Topology vertex not found." ) ; String schemaName = schemaVertex . value ( SQLG_SCHEMA_SCHEMA_NAME ) ; String tableName = vertexVertex . value ( SQLG_SCHEMA_VERTEX_LABEL_NAME ) ; VertexLabel vertexLabel = this . vertexLabels . get ( schemaName + "." + VERTEX_PREFIX + tableName ) ; if ( vertexLabel == null ) { vertexLabel = new VertexLabel ( this , tableName ) ; this . vertexLabels . put ( schemaName + "." + VERTEX_PREFIX + tableName , vertexLabel ) ; } if ( vertexIndex != null ) { String indexName = vertexIndex . value ( SQLG_SCHEMA_INDEX_NAME ) ; Optional < Index > oidx = vertexLabel . getIndex ( indexName ) ; Index idx ; if ( oidx . isPresent ( ) ) { idx = oidx . get ( ) ; } else { idx = new Index ( indexName , IndexType . fromString ( vertexIndex . value ( SQLG_SCHEMA_INDEX_INDEX_TYPE ) ) , vertexLabel ) ; vertexLabel . addIndex ( idx ) ; } if ( propertyIndex != null ) { String propertyName = propertyIndex . value ( SQLG_SCHEMA_PROPERTY_NAME ) ; vertexLabel . getProperty ( propertyName ) . ifPresent ( ( PropertyColumn pc ) -> idx . addProperty ( pc ) ) ; } } } }
load indices for all vertices in schema