Skip to content

Commit

Permalink
Fixing build
Browse files Browse the repository at this point in the history
Todo: Remove extraneous dependencies from core/project.json once dapper point the correct versions
  • Loading branch information
sebastienros committed Apr 4, 2016
1 parent b3c83fd commit c146d96
Show file tree
Hide file tree
Showing 32 changed files with 519 additions and 391 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ artifacts
*.vsp
project.lock.json
*.mdb
.vs/
.build/
.vs/
.build/
.testPublish/
2 changes: 1 addition & 1 deletion samples/YesSql.Bench/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static void Main(string[] args)


session.Save(bill);

}

using (var session = _store.CreateSession())
Expand Down
24 changes: 18 additions & 6 deletions samples/YesSql.Bench/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,33 @@
"Microsoft.Data.Sqlite": "1.0.0-*",
"YesSql.Core": "2.0.0-*",
"YesSql.Storage.LightningDB": "1.0.0-*",
"xunit.assert": "2.1.0"
"xunit": "2.1.0"
},
"commands": {
"YesSql.Bench": "YesSql.Bench"
},
"frameworks": {
"net451": {
"frameworkAssemblies": {
"System.Runtime": {
"type": "build"
},
"System.Reflection": {
"type": "build"
},
"System.Threading.Tasks": {
"type": "build"
}
}
},
"netstandardapp1.5": {
"dependencies": {
"NETStandard.Library": "1.0.0-*",
"System.Data.SqlClient": "4.0.0-*"
},
"imports": [
"dnxcore50",
"portable-net451+win8"
]
],
"dependencies": {
"NETStandard.Library": "1.5.0-*"
}
}
}
}
18 changes: 9 additions & 9 deletions samples/YesSql.Samples.FullText/Indexes/ArticleByWord.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
//using YesSql.Core.Indexes;
using YesSql.Core.Indexes;

//namespace YesSql.Samples.FullText.Indexes
//{
// public class ArticleByWord : ReduceIndex
// {
// public string Word { get; set; }
// public int Count { get; set; }
// }
//}
namespace YesSql.Samples.FullText.Indexes
{
public class ArticleByWord : ReduceIndex
{
public string Word { get; set; }
public int Count { get; set; }
}
}
65 changes: 33 additions & 32 deletions samples/YesSql.Samples.FullText/Indexes/ArticleIndexProvider.cs
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
//using System.Linq;
//using YesSql.Core.Indexes;
//using YesSql.Samples.FullText.Models;
//using YesSql.Samples.FullText.Tokenizers;
using System.Linq;
using YesSql.Core.Indexes;
using YesSql.Samples.FullText.Models;
using YesSql.Samples.FullText.Tokenizers;

//namespace YesSql.Samples.FullText.Indexes
//{
// public class ArticleIndexProvider : IndexProvider<Article>
// {
// public override void Describe(DescribeContext<Article> context)
// {
// var tokenizer = new WhiteSpaceTokenizer();
// var filter = new StopWordFilter();
namespace YesSql.Samples.FullText.Indexes
{
public class ArticleIndexProvider : IndexProvider<Article>
{
public override void Describe(DescribeContext<Article> context)
{
var tokenizer = new WhiteSpaceTokenizer();
var filter = new StopWordFilter();

// // for each BlogPost, create a BlogPostByAuthor index
// context.For<ArticleByWord, string>()
// .Map(article => filter
// .Filter(tokenizer.Tokenize(article.Content))
// .Select(x => new ArticleByWord {Word = x, Count = 1})
// )
// .Group(article => article.Word)
// .Reduce(group => new ArticleByWord
// {
// Word = group.Key,
// Count = group.Sum(y => y.Count)
// })
// .Delete((index, map) => {
// index.Count -= map.Sum(x => x.Count);
// for each BlogPost, create a BlogPostByAuthor index
context.For<ArticleByWord, string>()
.Map(article => filter
.Filter(tokenizer.Tokenize(article.Content))
.Select(x => new ArticleByWord { Word = x, Count = 1 })
)
.Group(article => article.Word)
.Reduce(group => new ArticleByWord
{
Word = group.Key,
Count = group.Sum(y => y.Count)
})
.Delete((index, map) =>
{
index.Count -= map.Sum(x => x.Count);
// // if Count == 0 then delete the index
// return index.Count > 0 ? index : null;
// });
// }
// }
//}
// if Count == 0 then delete the index
return index.Count > 0 ? index : null;
});
}
}
}
14 changes: 7 additions & 7 deletions samples/YesSql.Samples.FullText/Models/Article.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//namespace YesSql.Samples.FullText.Models
//{
// public class Article
// {
// public string Content { get; set; }
// }
//}
namespace YesSql.Samples.FullText.Models
{
public class Article
{
public string Content { get; set; }
}
}
123 changes: 65 additions & 58 deletions samples/YesSql.Samples.FullText/Program.cs
Original file line number Diff line number Diff line change
@@ -1,58 +1,65 @@
//using System;
//using YesSql.Samples.FullText.Indexes;
//using YesSql.Samples.FullText.Models;
//using YesSql.Core.Services;
//using System.Data.SQLite;
//using YesSql.Core.Storage.InMemory;

//namespace YesSql.Samples.FullText
//{
// internal class Program
// {
// private static void Main(string[] args)
// {
// var store = new Store(cfg =>
// {
// cfg.ConnectionFactory = new DbConnectionFactory<SQLiteConnection>(@"Data Source=:memory:", true);
// cfg.DocumentStorageFactory = new InMemoryDocumentStorageFactory();

// cfg.Migrations.Add(builder => builder
// .CreateReduceIndexTable(nameof(ArticleByWord), table => table
// .Column<int>("Count")
// .Column<string>("Word")
// )
// );
// });

// // register available indexes
// store.RegisterIndexes<ArticleIndexProvider>();

// // creating articles
// using (var session = store.CreateSession())
// {
// session.Save(new Article {Content = "This is a white fox"});
// session.Save(new Article {Content = "This is a brown cat"});
// session.Save(new Article {Content = "This is a pink elephant"});
// session.Save(new Article {Content = "This is a white tiger"});
// }

// using (var session = store.CreateSession())
// {
// Console.WriteLine("Simple term: 'white'");
// var simple = session.QueryAsync<Article, ArticleByWord>().Where(a => a.Word == "white").List().Result;

// foreach (var article in simple) {
// Console.WriteLine(article.Content);
// }

// Console.WriteLine("Boolean query: 'white or fox or pink'");
// var boolQuery = session.QueryAsync<Article, ArticleByWord>().Where(a => a.Word.IsIn(new [] { "white", "fox", "pink" })).List().Result;

// foreach (var article in boolQuery)
// {
// Console.WriteLine(article.Content);
// }
// }
// }
// }
//}
using System;
using Microsoft.Data.Sqlite;
using YesSql.Core.Services;
using YesSql.Samples.FullText.Indexes;
using YesSql.Samples.FullText.Models;
using YesSql.Storage.InMemory;

namespace YesSql.Samples.FullText
{
internal class Program
{
private static void Main(string[] args)
{
var store = new Store(cfg =>
{
cfg.ConnectionFactory = new DbConnectionFactory<SqliteConnection>(@"Data Source=:memory:", true);
cfg.DocumentStorageFactory = new InMemoryDocumentStorageFactory();
});

store.InitializeAsync().Wait();

using (var session = store.CreateSession())
{
session.ExecuteMigration(x => x
.CreateReduceIndexTable(nameof(ArticleByWord), table => table
.Column<int>("Count")
.Column<string>("Word")
)
);
}

// register available indexes
store.RegisterIndexes<ArticleIndexProvider>();

// creating articles
using (var session = store.CreateSession())
{
session.Save(new Article { Content = "This is a white fox" });
session.Save(new Article { Content = "This is a brown cat" });
session.Save(new Article { Content = "This is a pink elephant" });
session.Save(new Article { Content = "This is a white tiger" });
}

using (var session = store.CreateSession())
{
Console.WriteLine("Simple term: 'white'");
var simple = session.QueryAsync<Article, ArticleByWord>().Where(a => a.Word == "white").List().Result;

foreach (var article in simple)
{
Console.WriteLine(article.Content);
}

Console.WriteLine("Boolean query: 'white or fox or pink'");
var boolQuery = session.QueryAsync<Article, ArticleByWord>().Where(a => a.Word.IsIn(new[] { "white", "fox", "pink" })).List().Result;

foreach (var article in boolQuery)
{
Console.WriteLine(article.Content);
}
}
}
}
}
21 changes: 11 additions & 10 deletions samples/YesSql.Samples.FullText/Tokenizers/ITokenFilter.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

//namespace YesSql.Samples.FullText.Tokenizers {
// public interface ITokenFilter
// {
// IEnumerable<string> Filter(IEnumerable<string> tokens);
// }
//}
namespace YesSql.Samples.FullText.Tokenizers
{
public interface ITokenFilter
{
IEnumerable<string> Filter(IEnumerable<string> tokens);
}
}
15 changes: 8 additions & 7 deletions samples/YesSql.Samples.FullText/Tokenizers/ITokenizer.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//using System.Collections.Generic;
using System.Collections.Generic;

//namespace YesSql.Samples.FullText.Tokenizers {
// public interface ITokenizer
// {
// IEnumerable<string> Tokenize(string text);
// }
//}
namespace YesSql.Samples.FullText.Tokenizers
{
public interface ITokenizer
{
IEnumerable<string> Tokenize(string text);
}
}
24 changes: 12 additions & 12 deletions samples/YesSql.Samples.FullText/Tokenizers/StopWordFilter.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//using System.Collections.Generic;
//using System.Linq;
using System.Collections.Generic;
using System.Linq;

//namespace YesSql.Samples.FullText.Tokenizers
//{
// public class StopWordFilter : ITokenFilter
// {
// public IEnumerable<string> Filter(IEnumerable<string> tokens)
// {
// return tokens.Where(token => token.Length >= 2);
// }
// }
//}
namespace YesSql.Samples.FullText.Tokenizers
{
public class StopWordFilter : ITokenFilter
{
public IEnumerable<string> Filter(IEnumerable<string> tokens)
{
return tokens.Where(token => token.Length >= 2);
}
}
}
Loading

0 comments on commit c146d96

Please sign in to comment.