private unsafe void FillCountOfResultsAndIndexEtag(QueryResultServerSide resultToFill, string collection) { var buffer = stackalloc long[3]; if (collection == Constants.Documents.Collections.AllDocumentsCollection) { var numberOfDocuments = _documents.GetNumberOfDocuments(_context); buffer[0] = DocumentsStorage.ReadLastDocumentEtag(_context.Transaction.InnerTransaction); buffer[1] = DocumentsStorage.ReadLastTombstoneEtag(_context.Transaction.InnerTransaction); buffer[2] = numberOfDocuments; resultToFill.TotalResults = (int)numberOfDocuments; } else { var collectionStats = _documents.GetCollection(collection, _context); buffer[0] = _documents.GetLastDocumentEtag(_context, collection); buffer[1] = _documents.GetLastTombstoneEtag(_context, collection); buffer[2] = collectionStats.Count; } resultToFill.ResultEtag = (long)Hashing.XXHash64.Calculate((byte *)buffer, sizeof(long) * 3); }