Configuration for the Table.Scan operation
示例#1
1
        /// <summary>
        /// Initiates a Search object to Scan a DynamoDB table, with the
        /// specified config.
        /// 
        /// No calls are made until the Search object is used.
        /// </summary>
        /// <param name="config">Configuration to use.</param>
        /// <returns>Resultant Search container.</returns>
        public Search Scan(ScanOperationConfig config)
        {
            var currentConfig = config ?? new ScanOperationConfig();

            Search ret = new Search(SearchType.Scan)
            {
                SourceTable = this,
                TableName = TableName,
                Limit = currentConfig.Limit,
                Filter = currentConfig.Filter,
                FilterExpression = currentConfig.FilterExpression,
                ConditionalOperator = currentConfig.ConditionalOperator,
                AttributesToGet = currentConfig.AttributesToGet,
                Select = currentConfig.Select,
                CollectResults = currentConfig.CollectResults,
                IndexName = currentConfig.IndexName
            };

            if (currentConfig.TotalSegments != 0)
            {
                ret.TotalSegments = currentConfig.TotalSegments;
                ret.Segment = currentConfig.Segment;
            }

            return ret;
        }
示例#2
0
        /// <summary>
        /// Initiates a Search object to Scan a DynamoDB table, with the
        /// specified config.
        ///
        /// No calls are made until the Search object is used.
        /// </summary>
        /// <param name="config">Configuration to use.</param>
        /// <returns>Resultant Search container.</returns>
        public Search Scan(ScanOperationConfig config)
        {
            var currentConfig = config ?? new ScanOperationConfig();

            Search ret = new Search(SearchType.Scan)
            {
                SourceTable         = this,
                TableName           = TableName,
                Limit               = currentConfig.Limit,
                Filter              = currentConfig.Filter,
                FilterExpression    = currentConfig.FilterExpression,
                ConditionalOperator = currentConfig.ConditionalOperator,
                AttributesToGet     = currentConfig.AttributesToGet,
                Select              = currentConfig.Select,
                CollectResults      = currentConfig.CollectResults,
                IndexName           = currentConfig.IndexName,
                IsConsistentRead    = currentConfig.ConsistentRead,
                PaginationToken     = currentConfig.PaginationToken
            };

            if (currentConfig.TotalSegments != 0)
            {
                ret.TotalSegments = currentConfig.TotalSegments;
                ret.Segment       = currentConfig.Segment;
            }

            return(ret);
        }
示例#3
0
        /// <summary>
        /// Initiates a Search object to Scan a DynamoDB table, with the
        /// specified expression.
        ///
        /// No calls are made until the Search object is used.
        /// </summary>
        /// <param name="filterExpression">Expression to apply to the scan.</param>
        /// <returns>Resultant Search container.</returns>
        public Search Scan(Expression filterExpression)
        {
            ScanOperationConfig config = new ScanOperationConfig
            {
                FilterExpression = filterExpression
            };

            return(Scan(config));
        }
示例#4
0
        /// <summary>
        /// Initiates a Search object to Scan a DynamoDB table, with the
        /// specified config.
        ///
        /// No calls are made until the Search object is used.
        /// </summary>
        /// <param name="config">Configuration to use.</param>
        /// <returns>Resultant Search container.</returns>
        public Search Scan(ScanOperationConfig config)
        {
            var currentConfig = config ?? new ScanOperationConfig();

            Search ret = new Search(SearchType.Scan)
            {
                SourceTable     = this,
                TableName       = TableName,
                Limit           = currentConfig.Limit,
                Filter          = currentConfig.Filter,
                AttributesToGet = currentConfig.AttributesToGet,
                Select          = currentConfig.Select,
                CollectResults  = currentConfig.CollectResults
            };

            if (currentConfig.TotalSegments != 0)
            {
                ret.TotalSegments = currentConfig.TotalSegments;
                ret.Segment       = currentConfig.Segment;
            }

            return(ret);
        }
        private object ExecuteScan(TranslationResult translationResult, Type entityType)
        {
            var scanConfig = new ScanOperationConfig
            {
                Filter = translationResult.GetScanFilterForTable(this.TableDefinition),
                CollectResults = false
            };

            if (translationResult.AttributesToGet != null)
            {
                scanConfig.Select = SelectValues.SpecificAttributes;
                scanConfig.AttributesToGet = translationResult.AttributesToGet;
            }

            var searchResult = this.TableDefinition.Scan(scanConfig);

            this.Log("DynamoDb scan: " + translationResult);

            return this.CreateReader(searchResult, entityType, translationResult.ProjectionFunc);
        }
示例#6
0
        /// <summary>
        /// Initiates a Search object to Scan a DynamoDB table, with the
        /// specified expression.
        /// 
        /// No calls are made until the Search object is used.
        /// </summary>
        /// <param name="filterExpression">Expression to apply to the scan.</param>
        /// <returns>Resultant Search container.</returns>
        public Search Scan(Expression filterExpression)
        {
            ScanOperationConfig config = new ScanOperationConfig
            {
                FilterExpression = filterExpression
            };

            return Scan(config);
        }
示例#7
0
        /// <summary>
        /// Initiates a Search object to Scan a DynamoDB table, with the
        /// specified config.
        /// 
        /// No calls are made until the Search object is used.
        /// </summary>
        /// <param name="config">Configuration to use.</param>
        /// <returns>Resultant Search container.</returns>
        public Search Scan(ScanOperationConfig config)
        {
            var currentConfig = config ?? new ScanOperationConfig();

            Search ret = new Search(SearchType.Scan)
            {
                SourceTable = this,
                TableName = TableName,
                Limit = currentConfig.Limit,
                Filter = currentConfig.Filter,
                AttributesToGet = currentConfig.AttributesToGet,
                Select = currentConfig.Select
            };

            return ret;
        }
        /// <summary>
        /// A utility method for cleaning up expired sessions that IIS failed to delete. The method performs a scan on the table
        /// with a condition that the expiration date is in the past and calls delete on all the keys returned. Scans can be costly on performance
        /// so use this method sparingly like a nightly or weekly clean job.
        /// </summary>
        /// <param name="dbClient">The AmazonDynamoDB client used to find a delete expired sessions.</param>
        /// <param name="tableName">The table to search.</param>
        public static void DeleteExpiredSessions(IAmazonDynamoDB dbClient, string tableName)
        {
            LogInfo("DeleteExpiredSessions");
            Table table = Table.LoadTable(dbClient, tableName, DynamoDBEntryConversion.V1);

            ScanFilter filter = new ScanFilter();
            filter.AddCondition(ATTRIBUTE_EXPIRES, ScanOperator.LessThan, DateTime.Now);

            ScanOperationConfig config = new ScanOperationConfig();
            config.AttributesToGet = new List<string> { ATTRIBUTE_SESSION_ID };
            config.Select = SelectValues.SpecificAttributes;
            config.Filter = filter;

            DocumentBatchWrite batchWrite = table.CreateBatchWrite();
            Search search = table.Scan(config);

            do
            {
                List<Document> page = search.GetNextSet();
                foreach (var document in page)
                {
                    batchWrite.AddItemToDelete(document);
                }
            } while (!search.IsDone);

            batchWrite.Execute();
        }