コード例 #1
0
        private void ClearAndRebuildCache()
        {
            columnPropertyCache.Clear();
            tableReferenceCache.Clear();
            relationshipReferenceCache.Clear();
            componentPropertyColumnCache.Clear();

            foreach (var mapping in ReferenceMappings.Where(r => r.FromTable != null && r.ToReference != null))
            {
                tableReferenceCache.AddMapping(mapping.FromTable, mapping.ToReference);
            }

            foreach (var mapping in RelationshipMappings.Where(r => r.FromRelationship != null && r.ToReference != null))
            {
                relationshipReferenceCache.AddMapping(mapping.FromRelationship, mapping.ToReference);
            }

            foreach (var mapping in Mappings)
            {
                foreach (var columnPropMapping in mapping.Mappings.Where(m => m.Column != null && m.Property != null))
                {
                    columnPropertyCache.AddMapping(columnPropMapping.Column, columnPropMapping.Property);
                }
            }

            foreach (var mapping in componentMappings)
            {
                foreach (var columnPropMapping in mapping.Mappings.Where(m => m.Column != null && m.Property != null))
                {
                    componentPropertyColumnCache.AddMapping(columnPropMapping.Column, columnPropMapping.Property);
                }
            }

            CacheInvalid = false;
        }
コード例 #2
0
ファイル: SchemaCalculator.cs プロジェクト: Neo4Net/Neo4Net
        private void ScanEverythingBelongingToRelationships(RelationshipMappings relMappings)
        {
            using (RelationshipScanCursor relationshipScanCursor = _cursors.allocateRelationshipScanCursor(), PropertyCursor propertyCursor = _cursors.allocatePropertyCursor())
            {
                _dataRead.allRelationshipsScan(relationshipScanCursor);
                while (relationshipScanCursor.Next())
                {
                    int typeId = relationshipScanCursor.Type();
                    relationshipScanCursor.Properties(propertyCursor);
                    MutableIntSet propertyIds = IntSets.mutable.empty();

                    while (propertyCursor.Next())
                    {
                        int propertyKey = propertyCursor.PropertyKey();

                        Value           currentValue = propertyCursor.PropertyValue();
                        Pair <int, int> key          = Pair.of(typeId, propertyKey);
                        UpdateValueTypeInMapping(currentValue, key, relMappings.RelationshipTypeIdANDPropertyTypeIdToValueType);

                        propertyIds.add(propertyKey);
                    }
                    propertyCursor.Close();

                    MutableIntSet oldPropertyKeySet = relMappings.RelationshipTypeIdToPropertyKeys.getOrDefault(typeId, _emptyPropertyIdSet);

                    // find out which old properties we did not visited and mark them as nullable
                    if (oldPropertyKeySet == _emptyPropertyIdSet)
                    {
                        if (propertyIds.size() == 0)
                        {
                            // Even if we find property key on other rels with this type, set all of them nullable
                            relMappings.NullableRelationshipTypes.Add(typeId);
                        }

                        propertyIds.addAll(oldPropertyKeySet);
                    }
                    else
                    {
                        MutableIntSet currentPropertyIdsHelperSet = new IntHashSet(propertyIds.size());
                        currentPropertyIdsHelperSet.addAll(propertyIds);
                        propertyIds.removeAll(oldPropertyKeySet);                                     // only the brand new ones in propIds now
                        oldPropertyKeySet.removeAll(currentPropertyIdsHelperSet);                     // only the old ones that are not on the new rel

                        propertyIds.addAll(oldPropertyKeySet);
                        propertyIds.forEach(id =>
                        {
                            Pair <int, int> key = Pair.of(typeId, id);
                            relMappings.RelationshipTypeIdANDPropertyTypeIdToValueType[key].setNullable();
                        });

                        propertyIds.addAll(currentPropertyIdsHelperSet);
                    }

                    relMappings.RelationshipTypeIdToPropertyKeys[typeId] = propertyIds;
                }
                relationshipScanCursor.Close();
            }
        }
コード例 #3
0
ファイル: SchemaCalculator.cs プロジェクト: Neo4Net/Neo4Net
        public virtual Stream <RelationshipPropertySchemaInfoResult> CalculateTabularResultStreamForRels()
        {
            RelationshipMappings relMappings = InitializeMappingsForRels();

            ScanEverythingBelongingToRelationships(relMappings);

            // go through all relationshipTypes to get actual names
            AddNamesToCollection(_tokenRead.relationshipTypesGetAllTokens(), relMappings.RelationshipTypIdToRelationshipName);

            return(ProduceResultsForRelationships(relMappings).stream());
        }
コード例 #4
0
ファイル: SchemaCalculator.cs プロジェクト: Neo4Net/Neo4Net
        private IList <RelationshipPropertySchemaInfoResult> ProduceResultsForRelationships(RelationshipMappings relMappings)
        {
            IList <RelationshipPropertySchemaInfoResult> results = new List <RelationshipPropertySchemaInfoResult>();

            foreach (int?typeId in relMappings.RelationshipTypeIdToPropertyKeys.Keys)
            {
                // lookup typ name
                string name = relMappings.RelationshipTypIdToRelationshipName[typeId];
                name = ":`" + name + "`";                         // escaping

                // lookup property value types
                MutableIntSet propertyIds = relMappings.RelationshipTypeIdToPropertyKeys[typeId];
                if (propertyIds.size() == 0)
                {
                    results.Add(new RelationshipPropertySchemaInfoResult(name, null, null, false));
                }
                else
                {
                    string finalName = name;
                    propertyIds.forEach(propId =>
                    {
                        string propName = _propertyIdToPropertyNameMapping[propId];
                        ValueTypeListHelper valueTypeListHelper = relMappings.RelationshipTypeIdANDPropertyTypeIdToValueType[Pair.of(typeId, propId)];
                        if (relMappings.NullableRelationshipTypes.Contains(typeId))
                        {
                            results.Add(new RelationshipPropertySchemaInfoResult(finalName, propName, valueTypeListHelper.CypherTypesList, false));
                        }
                        else
                        {
                            results.Add(new RelationshipPropertySchemaInfoResult(finalName, propName, valueTypeListHelper.CypherTypesList, valueTypeListHelper.Mandatory));
                        }
                    });
                }
            }
            return(results);
        }