Permalink
Browse files

Merge branch 'temp' of github.com:ayende/ravendb

  • Loading branch information...
2 parents 72b0bcf + dc3d041 commit b7fb987c1a7f3ead91ead9e3642c8272f4035656 @ayende ayende committed Dec 8, 2011
@@ -48,10 +48,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Raven.Bundles.MoreLikeThis"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Raven.Client.MoreLikeThis", "Raven.Client.MoreLikeThis\Raven.Client.MoreLikeThis.csproj", "{039CB1C3-C4F3-4D87-A2C0-7531E386E6A3}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RavensNest.OAuth", "..\..\RavensNest\RavensNest.OAuth\RavensNest.OAuth.csproj", "{CA139FC8-4671-4817-8C25-43F5F0C8DCD7}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApplication1", "..\..\temp\ConsoleApplication1\ConsoleApplication1.csproj", "{D2390328-CC2C-4DE2-A554-D032B1F3BB4E}"
-EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -292,26 +288,6 @@ Global
{039CB1C3-C4F3-4D87-A2C0-7531E386E6A3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{039CB1C3-C4F3-4D87-A2C0-7531E386E6A3}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{039CB1C3-C4F3-4D87-A2C0-7531E386E6A3}.Release|x86.ActiveCfg = Release|Any CPU
- {CA139FC8-4671-4817-8C25-43F5F0C8DCD7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {CA139FC8-4671-4817-8C25-43F5F0C8DCD7}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {CA139FC8-4671-4817-8C25-43F5F0C8DCD7}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
- {CA139FC8-4671-4817-8C25-43F5F0C8DCD7}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
- {CA139FC8-4671-4817-8C25-43F5F0C8DCD7}.Debug|x86.ActiveCfg = Debug|Any CPU
- {CA139FC8-4671-4817-8C25-43F5F0C8DCD7}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {CA139FC8-4671-4817-8C25-43F5F0C8DCD7}.Release|Any CPU.Build.0 = Release|Any CPU
- {CA139FC8-4671-4817-8C25-43F5F0C8DCD7}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
- {CA139FC8-4671-4817-8C25-43F5F0C8DCD7}.Release|Mixed Platforms.Build.0 = Release|Any CPU
- {CA139FC8-4671-4817-8C25-43F5F0C8DCD7}.Release|x86.ActiveCfg = Release|Any CPU
- {D2390328-CC2C-4DE2-A554-D032B1F3BB4E}.Debug|Any CPU.ActiveCfg = Debug|x86
- {D2390328-CC2C-4DE2-A554-D032B1F3BB4E}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
- {D2390328-CC2C-4DE2-A554-D032B1F3BB4E}.Debug|Mixed Platforms.Build.0 = Debug|x86
- {D2390328-CC2C-4DE2-A554-D032B1F3BB4E}.Debug|x86.ActiveCfg = Debug|x86
- {D2390328-CC2C-4DE2-A554-D032B1F3BB4E}.Debug|x86.Build.0 = Debug|x86
- {D2390328-CC2C-4DE2-A554-D032B1F3BB4E}.Release|Any CPU.ActiveCfg = Release|x86
- {D2390328-CC2C-4DE2-A554-D032B1F3BB4E}.Release|Mixed Platforms.ActiveCfg = Release|x86
- {D2390328-CC2C-4DE2-A554-D032B1F3BB4E}.Release|Mixed Platforms.Build.0 = Release|x86
- {D2390328-CC2C-4DE2-A554-D032B1F3BB4E}.Release|x86.ActiveCfg = Release|x86
- {D2390328-CC2C-4DE2-A554-D032B1F3BB4E}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -624,10 +624,11 @@ private bool ShouldIncludeInResults(IndexQueryResult indexQueryResult)
private void RecordResultsAlreadySeenForDistinctQuery(IndexSearcher indexSearcher, TopDocs search, int start, int pageSize)
{
var min = Math.Min(start, search.TotalHits);
+
// we are paging, we need to check that we don't have duplicates in the previous page
// see here for details: http://groups.google.com/group/ravendb/browse_frm/thread/d71c44aa9e2a7c6e
- if(fieldsToFetch.IsProjection == false && start - pageSize >= 0 && start < search.TotalHits)
+ if (parent.IsMapReduce == false && fieldsToFetch.IsProjection == false && start - pageSize >= 0 && start < search.TotalHits)
{
for (int i = start - pageSize; i < min; i++)
{
@@ -49,7 +49,7 @@ protected override void ExecuteIndexingWorkOnMultipleThreads(IEnumerable<IndexTo
ExecuteIndexingInternal(indexesToWorkOn, documents => Parallel.ForEach(indexesToWorkOn, new ParallelOptions
{
MaxDegreeOfParallelism = context.Configuration.MaxNumberOfParallelIndexTasks,
- TaskScheduler = scheduler
+ TaskScheduler = scheduler,
}, indexToWorkOn => transactionalStorage.Batch(actions => IndexDocuments(actions, indexToWorkOn.IndexName, documents))));
}
@@ -231,132 +231,135 @@ public static string GetString(byte[] downloadData)
public static void ImportData(string instanceUrl, string file)
{
- var sw = Stopwatch.StartNew();
-
using (FileStream fileStream = File.OpenRead(file))
{
- // Try to read the stream compressed, otherwise continue uncompressed.
- JsonTextReader jsonReader;
-
- try
- {
- StreamReader streamReader = new StreamReader(new GZipStream(fileStream, CompressionMode.Decompress));
-
- jsonReader = new JsonTextReader(streamReader);
+ ImportData(fileStream, instanceUrl);
+ }
+ }
- if (jsonReader.Read() == false)
- return;
- }
- catch (InvalidDataException)
- {
- fileStream.Seek(0, SeekOrigin.Begin);
+ public static void ImportData(Stream stream, string instanceUrl)
+ {
+ var sw = Stopwatch.StartNew();
+ // Try to read the stream compressed, otherwise continue uncompressed.
+ JsonTextReader jsonReader;
+ try
+ {
+ var streamReader = new StreamReader(new GZipStream(stream, CompressionMode.Decompress));
- StreamReader streamReader = new StreamReader(fileStream);
+ jsonReader = new JsonTextReader(streamReader);
- jsonReader = new JsonTextReader(streamReader);
+ if (jsonReader.Read() == false)
+ return;
+ }
+ catch (InvalidDataException)
+ {
+ stream.Seek(0, SeekOrigin.Begin);
- if (jsonReader.Read() == false)
- return;
- }
+ StreamReader streamReader = new StreamReader(stream);
- if (jsonReader.TokenType != JsonToken.StartObject)
- throw new InvalidDataException("StartObject was expected");
+ jsonReader = new JsonTextReader(streamReader);
- // should read indexes now
if (jsonReader.Read() == false)
return;
- if (jsonReader.TokenType != JsonToken.PropertyName)
- throw new InvalidDataException("PropertyName was expected");
- if (Equals("Indexes", jsonReader.Value) == false)
- throw new InvalidDataException("Indexes property was expected");
- if (jsonReader.Read() == false)
- return;
- if (jsonReader.TokenType != JsonToken.StartArray)
- throw new InvalidDataException("StartArray was expected");
- using (var webClient = new WebClient())
+ }
+
+ if (jsonReader.TokenType != JsonToken.StartObject)
+ throw new InvalidDataException("StartObject was expected");
+
+ // should read indexes now
+ if (jsonReader.Read() == false)
+ return;
+ if (jsonReader.TokenType != JsonToken.PropertyName)
+ throw new InvalidDataException("PropertyName was expected");
+ if (Equals("Indexes", jsonReader.Value) == false)
+ throw new InvalidDataException("Indexes property was expected");
+ if (jsonReader.Read() == false)
+ return;
+ if (jsonReader.TokenType != JsonToken.StartArray)
+ throw new InvalidDataException("StartArray was expected");
+ using (var webClient = new WebClient())
+ {
+ webClient.UseDefaultCredentials = true;
+ webClient.Headers.Add("Content-Type", "application/json; charset=utf-8");
+ webClient.Credentials = CredentialCache.DefaultNetworkCredentials;
+ while (jsonReader.Read() && jsonReader.TokenType != JsonToken.EndArray)
{
- webClient.UseDefaultCredentials = true;
- webClient.Headers.Add("Content-Type", "application/json; charset=utf-8");
- webClient.Credentials = CredentialCache.DefaultNetworkCredentials;
- while (jsonReader.Read() && jsonReader.TokenType != JsonToken.EndArray)
+ var index = RavenJToken.ReadFrom(jsonReader);
+ var indexName = index.Value<string>("name");
+ if (indexName.StartsWith("Raven/") || indexName.StartsWith("Temp/"))
+ continue;
+ using (var streamWriter = new StreamWriter(webClient.OpenWrite(instanceUrl + "indexes/" + indexName, "PUT")))
+ using (var jsonTextWriter = new JsonTextWriter(streamWriter))
{
- var index = RavenJToken.ReadFrom(jsonReader);
- var indexName = index.Value<string>("name");
- if (indexName.StartsWith("Raven/") || indexName.StartsWith("Temp/"))
- continue;
- using (var streamWriter = new StreamWriter(webClient.OpenWrite(instanceUrl + "indexes/" + indexName, "PUT")))
- using (var jsonTextWriter = new JsonTextWriter(streamWriter))
- {
- index.Value<RavenJObject>("definition").WriteTo(jsonTextWriter);
- jsonTextWriter.Flush();
- streamWriter.Flush();
- }
+ index.Value<RavenJObject>("definition").WriteTo(jsonTextWriter);
+ jsonTextWriter.Flush();
+ streamWriter.Flush();
}
}
- // should read documents now
- if (jsonReader.Read() == false)
- return;
- if (jsonReader.TokenType != JsonToken.PropertyName)
- throw new InvalidDataException("PropertyName was expected");
- if (Equals("Docs", jsonReader.Value) == false)
- throw new InvalidDataException("Docs property was expected");
- if (jsonReader.Read() == false)
- return;
- if (jsonReader.TokenType != JsonToken.StartArray)
- throw new InvalidDataException("StartArray was expected");
- var batch = new List<RavenJObject>();
- int totalCount = 0;
- while (jsonReader.Read() && jsonReader.TokenType != JsonToken.EndArray)
+ }
+ // should read documents now
+ if (jsonReader.Read() == false)
+ return;
+ if (jsonReader.TokenType != JsonToken.PropertyName)
+ throw new InvalidDataException("PropertyName was expected");
+ if (Equals("Docs", jsonReader.Value) == false)
+ throw new InvalidDataException("Docs property was expected");
+ if (jsonReader.Read() == false)
+ return;
+ if (jsonReader.TokenType != JsonToken.StartArray)
+ throw new InvalidDataException("StartArray was expected");
+ var batch = new List<RavenJObject>();
+ int totalCount = 0;
+ while (jsonReader.Read() && jsonReader.TokenType != JsonToken.EndArray)
+ {
+ totalCount += 1;
+ var document = RavenJToken.ReadFrom(jsonReader);
+ batch.Add((RavenJObject)document);
+ if (batch.Count >= 128)
+ FlushBatch(instanceUrl, batch);
+ }
+ FlushBatch(instanceUrl, batch);
+
+ var attachmentCount = 0;
+ if (jsonReader.Read() == false || jsonReader.TokenType == JsonToken.EndObject)
+ return;
+ if (jsonReader.TokenType != JsonToken.PropertyName)
+ throw new InvalidDataException("PropertyName was expected");
+ if (Equals("Attachments", jsonReader.Value) == false)
+ throw new InvalidDataException("Attachment property was expected");
+ if (jsonReader.Read() == false)
+ return;
+ if (jsonReader.TokenType != JsonToken.StartArray)
+ throw new InvalidDataException("StartArray was expected");
+ while (jsonReader.Read() && jsonReader.TokenType != JsonToken.EndArray)
+ {
+ using (var client = new WebClient())
{
- totalCount += 1;
- var document = RavenJToken.ReadFrom(jsonReader);
- batch.Add((RavenJObject)document);
- if (batch.Count >= 128)
- FlushBatch(instanceUrl, batch);
- }
- FlushBatch(instanceUrl, batch);
+ attachmentCount += 1;
+ var item = RavenJToken.ReadFrom(jsonReader);
- var attachmentCount = 0;
- if (jsonReader.Read() == false || jsonReader.TokenType == JsonToken.EndObject)
- return;
- if (jsonReader.TokenType != JsonToken.PropertyName)
- throw new InvalidDataException("PropertyName was expected");
- if (Equals("Attachments", jsonReader.Value) == false)
- throw new InvalidDataException("Attachment property was expected");
- if (jsonReader.Read() == false)
- return;
- if (jsonReader.TokenType != JsonToken.StartArray)
- throw new InvalidDataException("StartArray was expected");
- while (jsonReader.Read() && jsonReader.TokenType != JsonToken.EndArray)
- {
- using (var client = new WebClient())
+ var attachmentExportInfo =
+ new JsonSerializer
+ {
+ Converters = {new TrivialJsonToJsonJsonConverter()}
+ }.Deserialize<AttachmentExportInfo>(new RavenJTokenReader(item));
+ Console.WriteLine("Importing attachment {0}", attachmentExportInfo.Key);
+ if (attachmentExportInfo.Metadata != null)
{
- attachmentCount += 1;
- var item = RavenJToken.ReadFrom(jsonReader);
-
- var attachmentExportInfo =
- new JsonSerializer
- {
- Converters = {new TrivialJsonToJsonJsonConverter()}
- }.Deserialize<AttachmentExportInfo>(new RavenJTokenReader(item));
- Console.WriteLine("Importing attachment {0}", attachmentExportInfo.Key);
- if (attachmentExportInfo.Metadata != null)
+ foreach (var header in attachmentExportInfo.Metadata)
{
- foreach (var header in attachmentExportInfo.Metadata)
- {
- client.Headers.Add(header.Key, StripQuotesIfNeeded(header.Value));
- }
+ client.Headers.Add(header.Key, StripQuotesIfNeeded(header.Value));
}
+ }
- using (var writer = client.OpenWrite(instanceUrl + "static/" + attachmentExportInfo.Key, "PUT"))
- {
- writer.Write(attachmentExportInfo.Data, 0, attachmentExportInfo.Data.Length);
- writer.Flush();
- }
+ using (var writer = client.OpenWrite(instanceUrl + "static/" + attachmentExportInfo.Key, "PUT"))
+ {
+ writer.Write(attachmentExportInfo.Data, 0, attachmentExportInfo.Data.Length);
+ writer.Flush();
}
}
- Console.WriteLine("Imported {0:#,#} documents and {1:#,#} attachments in {2:#,#} ms", totalCount, attachmentCount, sw.ElapsedMilliseconds);
}
+ Console.WriteLine("Imported {0:#,#} documents and {1:#,#} attachments in {2:#,#} ms", totalCount, attachmentCount, sw.ElapsedMilliseconds);
}
public class TrivialJsonToJsonJsonConverter : JsonConverter
@@ -599,7 +599,6 @@
<Resource Include="Assets\Images\ChangeView.png" />
<Content Include="Impl\PopupPlacement\Credit.txt" />
<Content Include="Impl\RelativeBinding\Credits.txt" />
- <Content Include="todo.txt" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Raven.Client.Silverlight\Raven.Client.Silverlight.csproj">
View
@@ -1,28 +0,0 @@
-Things to do here:
-
-* Make this pretty! Based on the new RavenDB.Net website design
-* Documents lists
-** Double click on the documents should open the edit
-
-
-* Allow editting of documents
-** allow delete
-** allow refresh
-** allow prettify
-** watch for changes
-
-* Allow editing of indexes
-** Set map(s)
-** Set reduce
-** Set transform results
-** Set fields properties
-
-* Allow querying
-
-* Administration
-** Backup
-** Import
-** Export
-
-
-* Collections
Oops, something went wrong.

0 comments on commit b7fb987

Please sign in to comment.