Skip to content

Instantly share code, notes, and snippets.

@phinett
phinett / ReportQueryMultipleValues.cs
Created April 28, 2014 11:40
Failing unit test for reporting query returning multiple values on same aggregate
public class ReportQueryMultipleValues : ReplicationBase
{
public class Sale
{
public string Id { get; set; }
public double Nett { get; set; }
public bool IsCancelled { get; set; }
}
{
LastDocEtag: "01000000-0000-0627-0000-000000003BC7",
LastAttachmentEtag: "00000000-0000-0000-0000-000000000000",
CountOfIndexes: 22,
InMemoryIndexingQueueSize: 2,
ApproximateTaskCount: 0,
CountOfDocuments: 8494288,
StaleIndexes: [
"AudioStatsCounterIndex/ByAccount",
"FollowersIndex",
{
LastDocEtag: "01000000-0000-0627-0000-000000003B97",
LastAttachmentEtag: "00000000-0000-0000-0000-000000000000",
CountOfIndexes: 22,
InMemoryIndexingQueueSize: 12,
ApproximateTaskCount: 0,
CountOfDocuments: 8494287,
StaleIndexes: [
"AudioStatsCounterIndex/ByAccount",
"FollowersIndex",
2013-10-11 13:57:05.9263,Raven.Storage.Esent.StorageActions.DocumentStorageActions,Debug,housemixes,Document with key 'audios-304570' was found,
2013-10-11 13:57:07.0183,Raven.Database.Server.HttpServer,Warn,,Error on request,"System.MissingMethodException: Method not found: '!!0 Raven.Json.Linq.Extensions.Value(Raven.Json.Linq.RavenJToken)'.
at MyRavenReplicationBundle.LastInWinsReplicationConflictResolver.GetLastModified(RavenJObject metadata)
at MyRavenReplicationBundle.LastInWinsReplicationConflictResolver.ExistingDocIsOlder(RavenJObject newMetadata, JsonDocument existingDoc)
at MyRavenReplicationBundle.LastInWinsReplicationConflictResolver.ExistingDocShouldWin(RavenJObject newMetadata, JsonDocument existingDoc)
at MyRavenReplicationBundle.LastInWinsReplicationConflictResolver.TryResolve(String id, RavenJObject metadata, RavenJObject document, JsonDocument existingDoc, Func`2 getDocument)
at Raven.Bundles.Replication.Responders.DocumentReplicationBehavior.<>c__DisplayClassb.<TryResolveConfl
public class LastInWinsReplicationConflictResolver : AbstractDocumentReplicationConflictResolver
{
private readonly Logger _log = LogManager.GetCurrentClassLogger();
public override bool TryResolve(string id, RavenJObject metadata, RavenJObject document, JsonDocument existingDoc, Func<string, JsonDocument> getDocument)
{
if (this.ExistingDocShouldWin(metadata, existingDoc))
{
this.ReplaceValues(metadata, existingDoc.Metadata);
this.ReplaceValues(document, existingDoc.DataAsJson);
@phinett
phinett / audios-1
Created September 20, 2013 12:19
Conflict Documents
{
"NhibernateAudioId": 0,
"AccountId": "accounts-414783",
"AudioType": "Mix",
"Identifier": "03032103-voc",
"Name": "The Strange Cargo Radio Show TALK FREEl Version 03.03.2013",
"Description": "<div><font face=\"Arial, Verdana\" size=\"2\">Not your Normal London Disco; www.disco-lab.co.uk - From Weddings to Corporate parties, Hospitality and musical branding - Bespoke party design and Audio Architecture Services Like no other T | 0208 419 8103 E | info@disco-lab.co.uk</font></div><div style=\"font-family: Arial, Verdana; font-size: 10pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;\"><br/></div><font face=\"Arial, Verdana\" size=\"2\">To quote one of today's 1st time listeners&nbsp;\"This show is like whiskey on yer cornflakes of a Sunday, flame on!\"</font><br/><font face=\"Arial, Verdana\" size=\"2\">Come check out today's proceedings at the Home of Real Good, Feel Good Music and 2 hours of blissed out beats &amp; pieces &amp; yet more audio gymnastics for&
{"LastDocEtag":"01000000-0000-0207-0000-0000000004D7","LastAttachmentEtag":"00000000-0000-0000-0000-000000000000","CountOfIndexes":29,"InMemoryIndexingQueueSize":0,"ApproximateTaskCount":0,"CountOfDocuments":3569,"StaleIndexes":[],"CurrentNumberOfItemsToIndexInSingleBatch":512,"CurrentNumberOfItemsToReduceInSingleBatch":256,"DatabaseTransactionVersionSizeInMB":0.06,"Indexes":[{"Name":"Activity/Index","IndexingAttempts":5569,"IndexingSuccesses":5569,"IndexingErrors":0,"LastIndexedEtag":"01000000-0000-0207-0000-0000000004D7","LastIndexedTimestamp":"2013-09-17T19:45:57.7400447Z","LastQueryTimestamp":"2013-09-17T18:18:42.3871456Z","TouchCount":0,"Priority":"Normal","ReduceIndexingAttempts":null,"ReduceIndexingSuccesses":null,"ReduceIndexingErrors":null,"LastReducedEtag":null,"LastReducedTimestamp":null,"CreatedTimestamp":"2013-05-02T13:24:21.1603805Z","LastIndexingTime":"2013-09-17T18:05:30.5672363Z","IsOnRam":"false","LockMode":"Unlock","ForEntityName":["Activties"],"Performance":[],"DocsCount":957},{"Name":"Ap
Copying c:\RavenDb\Server\Database\Databases\housemixes\IndexDefinitions\Account%2fIndex.index
Copying c:\RavenDb\Server\Database\Databases\housemixes\IndexDefinitions\Account%2fIndex.index
Copying c:\RavenDb\Server\Database\Databases\housemixes\IndexDefinitions\AccountProfileComment%2fIndex.index
Copying c:\RavenDb\Server\Database\Databases\housemixes\IndexDefinitions\AccountProfileComment%2fIndex.index
Copying c:\RavenDb\Server\Database\Databases\housemixes\IndexDefinitions\AccountSearch%2fIndex.index
Copying c:\RavenDb\Server\Database\Databases\housemixes\IndexDefinitions\AccountSearch%2fIndex.index
Copying c:\RavenDb\Server\Database\Databases\housemixes\IndexDefinitions\ActivityIndex.index
Copying c:\RavenDb\Server\Database\Databases\housemixes\IndexDefinitions\ActivityIndex.index
Copying c:\RavenDb\Server\Database\Databases\housemixes\IndexDefinitions\AudioCounterIndex.index
Copying c:\RavenDb\Server\Database\Databases\housemixes\IndexDefinitions\AudioCounterIndex.index
@phinett
phinett / ListExtensions.cs
Created March 13, 2013 02:52
Modification to delete records from SQL server using a DELETE WHERE IN (...) statement instead of individual deletes.
using System;
using System.Collections.Generic;
using System.Linq;
namespace Raven.Abstractions.Extensions
{
public static class ListExtensions
{
public static void ForEach<T>(this IEnumerable<T> source, Action<T> action)
{
@phinett
phinett / LoadAllStartingWithShouldNotLoadDeletedDocs.cs
Last active December 12, 2015 06:09
RavenDb test - 1) Create document, 2) Call LoadStartingWith to get results 3) Delete the document 4) Call LoadStartingWith - This is returning the deleted documents because the query is returning from the cache with a 304 response.
public class LoadAllStartingWith : RavenTestBase
{
public class TestClass
{
public string Id { get; set; }
}
[Fact]
public void LoadAllStartingWithShouldNotLoadDeletedDocs()