Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why isn't my TakeLimit honored by TableQuery?

I'd like to fetch top n rows from my Azure Table with a simple TableQuery. But with the code below, all rows are fetched regardless of my limit with the Take.

What am I doing wrong?

int entryLimit = 5;

var table = GetFromHelperFunc();

TableQuery<MyEntity> query = new TableQuery<MyEntity>()
    .Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "MyPK"))
    .Take(entryLimit);

List<FeedEntry> entryList = new List<FeedEntry>();
TableQuerySegment<FeedEntry> currentSegment = null;

while (currentSegment == null || currentSegment.ContinuationToken != null)
{
    currentSegment = table.ExecuteQuerySegmented(query, this.EntryResolver, currentSegment != null ? currentSegment.ContinuationToken : null);
    entryList.AddRange(currentSegment.Results);
}


Trace.WriteLine(entryList.Count) // <-- Why does this exceed my limit?
like image 251
Jonas Stensved Avatar asked Nov 19 '12 11:11

Jonas Stensved


People also ask

Is Azure table storage deprecated?

Azure table storage is being deprecated in favor of Azure Cosmos DB. Azure Cosmos DB offers many advantages over Azure table storage, such as: -Azure Cosmos DB is scalable.

What is Tablequery?

A make table query retrieves data from one or more tables, and then loads the result set into a new table. That new table can reside in the database that you have open, or you can create it in another database. Typically, you create make table queries when you need to copy or archive data.


1 Answers

AFAIK Storage Client Library 2.0 had a bug in Take implementation. It was fixed in ver 2.0.4.
Read last comments at http://blogs.msdn.com/b/windowsazurestorage/archive/2012/11/06/windows-azure-storage-client-library-2-0-tables-deep-dive.aspx

[EDIT] Original MSDN post no longer available. Still present on WebArchive: http://web.archive.org/web/20200722170914/https://docs.microsoft.com/en-us/archive/blogs/windowsazurestorage/windows-azure-storage-client-library-2-0-tables-deep-dive

like image 111
Fabrizio Accatino Avatar answered Sep 22 '22 12:09

Fabrizio Accatino