Пример #1
0
 public void WriteWordRelation(FSWordRelationship relation)
 {
     CellSet.Row row = TableDomainMappers.WordRelationToRow(relation);
     CellSet set = new CellSet();
     set.rows.Add(row);
     HadoopContext.HBaseClient.StoreCells(HadoopContext.WordRelationTableName, set);
 }
Пример #2
0
        public void WriteWordRelation(FSWordRelationship relation)
        {
            CellSet.Row row = TableDomainMappers.WordRelationToRow(relation);
            CellSet     set = new CellSet();

            set.rows.Add(row);
            HadoopContext.HBaseClient.StoreCells(HadoopContext.WordRelationTableName, set);
        }
Пример #3
0
 public IEnumerable<FSWordRelationship> FindRelationsWithWord(string word)
 {
     var query = from o in HadoopContext.WordRelationsTable
                 where o.rScore > 0 && (o.WordOne.CompareTo(word) == 0 || o.WordTwo.CompareTo(word) == 0)
                 select new { o.Id, o.WordOne, o.WordOneId, o.WordTwo, o.WordTwoId, o.rScore };
     query.ExecuteQuery().Wait();
     var results = query.ToList();
     List<FSWordRelationship> relations = new List<FSWordRelationship>();
     foreach (var r in results)
     {
         FSWordRelationship relation = new FSWordRelationship(r.Id, r.WordOne, r.WordOneId, r.WordTwo, r.WordTwoId, r.rScore);
         relations.Add(relation);
     }
     return relations;
 }
Пример #4
0
        public IEnumerable <FSWordRelationship> FindRelationsWithWord(string word)
        {
            var query = from o in HadoopContext.WordRelationsTable
                        where o.rScore > 0 && (o.WordOne.CompareTo(word) == 0 || o.WordTwo.CompareTo(word) == 0)
                        select new { o.Id, o.WordOne, o.WordOneId, o.WordTwo, o.WordTwoId, o.rScore };

            query.ExecuteQuery().Wait();
            var results = query.ToList();
            List <FSWordRelationship> relations = new List <FSWordRelationship>();

            foreach (var r in results)
            {
                FSWordRelationship relation = new FSWordRelationship(r.Id, r.WordOne, r.WordOneId, r.WordTwo, r.WordTwoId, r.rScore);
                relations.Add(relation);
            }
            return(relations);
        }
Пример #5
0
        public static CellSet.Row WordRelationToRow(FSWordRelationship relation)
        {
            var row = new CellSet.Row {
                key = Encoding.UTF8.GetBytes(relation.Id)
            };

            row.values.Add(
                new Cell
            {
                column = Encoding.UTF8.GetBytes("d:WordOne"),
                data   = Encoding.UTF8.GetBytes(relation.WordOne)
            });
            row.values.Add(
                new Cell
            {
                column = Encoding.UTF8.GetBytes("d:WordOneId"),
                data   = Encoding.UTF8.GetBytes(relation.WordOneId.ToString())
            });
            row.values.Add(
                new Cell
            {
                column = Encoding.UTF8.GetBytes("d:WordTwo"),
                data   = Encoding.UTF8.GetBytes(relation.WordTwo)
            });
            row.values.Add(
                new Cell
            {
                column = Encoding.UTF8.GetBytes("d:WordTwoId"),
                data   = Encoding.UTF8.GetBytes(relation.WordTwoId.ToString())
            });
            row.values.Add(
                new Cell
            {
                column = Encoding.UTF8.GetBytes("d:RScore"),
                data   = Encoding.UTF8.GetBytes(relation.rScore.ToString())
            });
            return(row);
        }
Пример #6
0
        public IEnumerable <FSWordRelationship> FindRelationsWithWord(string word)
        {
            Scanner s = new Scanner()
            {
                batch = 1000
            };
            ScannerInformation        si        = client.CreateScanner(HadoopContext.HBaseWordRelationTableName, s);
            CellSet                   next      = null;
            CellSet                   readRows  = new CellSet();
            List <FSWordRelationship> relations = new List <FSWordRelationship>();

            while ((next = client.ScannerGetNext(si)) != null)
            {
                foreach (CellSet.Row row in next.rows)
                {
                    //convert row into desired domain type....
                    var    w1        = row.values.Find(w => Encoding.UTF8.GetString(w.column) == "d:WordOne");
                    string wordOne   = Encoding.UTF8.GetString(w1.data);
                    var    w1Id      = row.values.Find(w => Encoding.UTF8.GetString(w.column) == "d:WordOneId");
                    int    wordOneId = Convert.ToInt32(Encoding.UTF8.GetString(w1Id.data));
                    var    w2        = row.values.Find(w => Encoding.UTF8.GetString(w.column) == "d:WordTwo");
                    string wordTwo   = Encoding.UTF8.GetString(w2.data);
                    var    w2Id      = row.values.Find(w => Encoding.UTF8.GetString(w.column) == "d:WordTwoId");
                    int    wordTwoId = Convert.ToInt32(Encoding.UTF8.GetString(w2Id.data));
                    var    rS        = row.values.Find(w => Encoding.UTF8.GetString(w.column) == "d:RScore");
                    var    rScore    = Convert.ToDouble(Encoding.UTF8.GetString(rS.data));
                    var    id        = Encoding.UTF8.GetString(row.key);
                    if (word.CompareTo(wordOne) == 0 || word.CompareTo(wordTwo) == 0 &&
                        !(String.IsNullOrWhiteSpace(wordOne) || String.IsNullOrWhiteSpace(wordTwo)))
                    {
                        FSWordRelationship rel = new FSWordRelationship(id, wordOne, wordOneId, wordTwo, wordTwoId, rScore);
                        relations.Add(rel);
                    }
                }
            }
            return(relations);
        }
Пример #7
0
 public IEnumerable<FSWordRelationship> FindRelationsWithWord(string word)
 {
     Scanner s = new Scanner()
     {
         batch = 1000
     };
     ScannerInformation si = client.CreateScanner(HadoopContext.HBaseWordRelationTableName, s);
     CellSet next = null;
     CellSet readRows = new CellSet();
     List<FSWordRelationship> relations = new List<FSWordRelationship>();
     while ((next = client.ScannerGetNext(si)) != null)
     {
         foreach (CellSet.Row row in next.rows)
         {
             //convert row into desired domain type....
             var w1 = row.values.Find(w => Encoding.UTF8.GetString(w.column) == "d:WordOne");
             string wordOne = Encoding.UTF8.GetString(w1.data);
             var w1Id = row.values.Find(w => Encoding.UTF8.GetString(w.column) == "d:WordOneId");
             int wordOneId = Convert.ToInt32(Encoding.UTF8.GetString(w1Id.data));
             var w2 = row.values.Find(w => Encoding.UTF8.GetString(w.column) == "d:WordTwo");
             string wordTwo = Encoding.UTF8.GetString(w2.data);
             var w2Id = row.values.Find(w => Encoding.UTF8.GetString(w.column) == "d:WordTwoId");
             int wordTwoId = Convert.ToInt32(Encoding.UTF8.GetString(w2Id.data));
             var rS = row.values.Find(w => Encoding.UTF8.GetString(w.column) == "d:RScore");
             var rScore = Convert.ToDouble(Encoding.UTF8.GetString(rS.data));
             var id = Encoding.UTF8.GetString(row.key);
             if (word.CompareTo(wordOne) == 0 || word.CompareTo(wordTwo) == 0
                 && !(String.IsNullOrWhiteSpace(wordOne) || String.IsNullOrWhiteSpace(wordTwo)))
             {
                 FSWordRelationship rel = new FSWordRelationship(id, wordOne, wordOneId, wordTwo, wordTwoId, rScore);
                 relations.Add(rel);
             }
         }
     }
     return relations;
 }
Пример #8
0
 public static CellSet.Row WordRelationToRow(FSWordRelationship relation)
 {
     var row = new CellSet.Row { key = Encoding.UTF8.GetBytes(relation.Id) };
     row.values.Add(
         new Cell
         {
             column = Encoding.UTF8.GetBytes("d:WordOne" ),
             data = Encoding.UTF8.GetBytes(relation.WordOne)
         });
     row.values.Add(
         new Cell
         {
             column = Encoding.UTF8.GetBytes("d:WordOneId"),
             data = Encoding.UTF8.GetBytes(relation.WordOneId.ToString())
         });
     row.values.Add(
         new Cell
         {
             column = Encoding.UTF8.GetBytes("d:WordTwo"),
             data = Encoding.UTF8.GetBytes(relation.WordTwo)
         });
     row.values.Add(
         new Cell
         {
             column = Encoding.UTF8.GetBytes("d:WordTwoId"),
             data = Encoding.UTF8.GetBytes(relation.WordTwoId.ToString())
         });
     row.values.Add(
         new Cell
         {
             column = Encoding.UTF8.GetBytes("d:RScore"),
             data = Encoding.UTF8.GetBytes(relation.rScore.ToString())
         });
     return row;
 }