Example #1
0
        internal virtual bool HasRelevantProperty(CURSOR cursor, EntityUpdates.Builder updates)
        {
            if (!cursor.hasProperties())
            {
                return(false);
            }
            bool hasRelevantProperty = false;

            _propertyCursor.init(cursor.propertiesReference());
            while (_propertyCursor.next())
            {
                int propertyKeyId = _propertyCursor.propertyKey();
                if (_propertyKeyIdFilter.test(propertyKeyId))
                {
                    // This relationship has a property of interest to us
                    Value value = _propertyCursor.propertyValue();
                    // No need to validate values before passing them to the updater since the index implementation
                    // is allowed to fail in which ever way it wants to. The result of failure will be the same as
                    // a failed validation, i.e. population FAILED.
                    updates.Added(propertyKeyId, value);
                    hasRelevantProperty = true;
                }
            }
            return(hasRelevantProperty);
        }
        public override EntityUpdates NodeAsUpdates(long nodeId)
        {
            NodeRecord node = NodeStore.getRecord(nodeId, NodeStore.newRecord(), FORCE);

            if (!node.InUse())
            {
                return(null);
            }
            long firstPropertyId = node.NextProp;

            if (firstPropertyId == Record.NO_NEXT_PROPERTY.intValue())
            {
                return(null);                        // no properties => no updates (it's not going to be in any index)
            }
            long[] labels = parseLabelsField(node).get(NodeStore);
            if (labels.Length == 0)
            {
                return(null);                        // no labels => no updates (it's not going to be in any index)
            }
            EntityUpdates.Builder update = EntityUpdates.forEntity(nodeId, true).withTokens(labels);
            foreach (PropertyRecord propertyRecord in PropertyStore.getPropertyRecordChain(firstPropertyId))
            {
                foreach (PropertyBlock property in propertyRecord)
                {
                    Value value = property.Type.value(property, PropertyStore);
                    update.Added(property.KeyIndexId, value);
                }
            }
            return(update.Build());
        }