Example #1
0
 /// <summary>
 ///    Initializes a new instance of the <see cref="Scanner" /> class.
 /// </summary>
 /// <param name="tableName">The HBase table name.</param>
 /// <param name="resource">The resource.</param>
 /// <param name="stargate">The current Stargate.</param>
 public Scanner(string tableName, string resource, IStargate stargate)
 {
     _cachedResults = new List <CellSet>();
     _stargate      = stargate;
     Table          = tableName;
     Resource       = resource;
 }
Example #2
0
        private static void DemonstrateWriting(IStargate stargate)
        {
            // update a single cell value:
            stargate.WriteValue("100", "access-logs", "elton|jericho|201510", "t", "2908");
            Console.WriteLine("Updated single cell");

            // set multiple cell values:
            var update = new Cell(new Identifier
            {
                Row = "elton|jericho|201510",
                CellDescriptor = new HBaseCellDescriptor
                {
                    Column = "t",
                    Qualifier = "2908"
                }
            }, "120");

            var insert = new Cell(new Identifier
            {
                Row = "elijah|jericho|201511",
                CellDescriptor = new HBaseCellDescriptor
                {
                    Column = "t",
                    Qualifier = "1117"
                }
            }, "360");

            var cells = new CellSet(new Cell[] { update, insert });
            cells.Table = "access-logs";

            stargate.WriteCells(cells);
            Console.WriteLine("Updated multiple cells");
        }
Example #3
0
 /// <summary>
 ///    Initializes a new instance of the <see cref="Scanner" /> class.
 /// </summary>
 /// <param name="tableName">The HBase table name.</param>
 /// <param name="resource">The resource.</param>
 /// <param name="stargate">The current Stargate.</param>
 public Scanner(string tableName, string resource, IStargate stargate)
 {
     _cachedResults = new List<CellSet>();
     _stargate = stargate;
     Table = tableName;
     Resource = resource;
 }
Example #4
0
        private static void DemonstrateReading(IStargate stargate)
        {
            // reading data for one row:
            var value = stargate.ReadValue("access-logs", "elton|jericho|201511", "t", "1106");
            Console.WriteLine("Single cell value: " + value);

            var cellSet = stargate.FindCells("access-logs", "elton|jericho|201511");
            value = cellSet.First(x => x.Identifier.CellDescriptor.Qualifier == "1106").Value;
            Console.WriteLine("LINQed cell value: " + value);
        }
Example #5
0
        public static void BootstrapSchema(this IStargate client)
        {
            var tables = client.GetTableNames();

            if (!tables.Contains("mail"))
            {
                client.CreateTable(new TableSchema
                {
                    Name    = "mail",
                    Columns = new List <ColumnSchema>
                    {
                        new ColumnSchema
                        {
                            Name = "m"
                        }
                    }
                });
            }
        }
Example #6
0
        private static void DemonstrateScanning(IStargate stargate)
        {
            // scanning rows:
            var options = new ScannerOptions
            {
                TableName = "access-logs",
                StartRow = "elton|jericho|201510",
                StopRow = "elton|jericho|x",
            };
            var scanner = stargate.CreateScanner(options);
            var totalUsage = 0;
            while (scanner.MoveNext())
            {
                var cells = scanner.Current;
                foreach (var cell in cells)
                {
                    totalUsage += int.Parse(cell.Value);
                }
            }
            Console.WriteLine("Sum from row scan: " + totalUsage);

            // scanning with a filter:
            options = new ScannerOptions
            {
                TableName = "access-logs",
                StartRow = "elton|jericho|201510",
                StopRow = "elton|jericho|x",
                Filter = new ColumnPrefixFilter("11")
            };
            scanner = stargate.CreateScanner(options);
            totalUsage = 0;
            while (scanner.MoveNext())
            {
                var cells = scanner.Current;
                foreach (var cell in cells)
                {
                    totalUsage += int.Parse(cell.Value);
                }
            }
            Console.WriteLine("Sum from filtered row scan: " + totalUsage);
        }
Example #7
0
 public MailTable(IStargate client)
 {
     _client = client;
 }
Example #8
0
 /// <summary>
 ///    Deletes the item with matching values from HBase.
 /// </summary>
 /// <param name="gate">The gate.</param>
 /// <param name="table">The table.</param>
 /// <param name="row">The row.</param>
 /// <param name="column">The column.</param>
 /// <param name="qualifier">The qualifier.</param>
 /// <param name="timestamp">The timestamp.</param>
 public static void DeleteItem(this IStargate gate, string table, string row, string column = null, string qualifier = null, long?timestamp = null)
 {
     gate.DeleteItem(BuildIdentifier(table, row, column, qualifier, timestamp));
 }
Example #9
0
 public static Task DeleteItemAsync(this IStargate gate, string table, string row, string column = null, string qualifier = null,
                                    long?timestamp = null)
 {
     return(gate.DeleteItemAsync(BuildIdentifier(table, row, column, qualifier, timestamp)));
 }
Example #10
0
 /// <summary>
 ///    Writes the value to HBase using the identifier values.
 /// </summary>
 /// <param name="gate">The gate.</param>
 /// <param name="value">The value.</param>
 /// <param name="table">The table.</param>
 /// <param name="row">The row.</param>
 /// <param name="column">The column.</param>
 /// <param name="qualifier">The qualifier.</param>
 /// <param name="timestamp">The timestamp.</param>
 public static void WriteValue(this IStargate gate, string value, string table, string row, string column, string qualifier = null,
                               long?timestamp = null)
 {
     gate.WriteValue(BuildIdentifier(table, row, column, qualifier, timestamp), value);
 }
Example #11
0
 public static Task WriteValueAsync(this IStargate gate, string value, string table, string row, string column, string qualifier = null,
                                    long?timestamp = null)
 {
     return(gate.WriteValueAsync(BuildIdentifier(table, row, column, qualifier, timestamp), value));
 }
Example #12
0
 /// <summary>
 /// Finds the cells with the matching attributes.
 /// </summary>
 /// <param name="gate">The gate.</param>
 /// <param name="table">The table.</param>
 /// <param name="row">The row.</param>
 /// <param name="column">The column.</param>
 /// <param name="qualifier">The qualifier.</param>
 /// <param name="beginTimestamp">The begin timestamp (exclusive).</param>
 /// <param name="endTimestamp">The end timestamp (exclusive).</param>
 /// <param name="maxVersions">The maximum versions to return.</param>
 public static CellSet FindCells(this IStargate gate, string table, string row = null, string column = null, string qualifier = null,
                                 long?beginTimestamp = null, long?endTimestamp = null, int?maxVersions = null)
 {
     return(gate.FindCells(BuildQuery(table, row, column, qualifier, beginTimestamp, endTimestamp, maxVersions)));
 }
Example #13
0
 /// <summary>
 ///    Reads the value at the matching location.
 /// </summary>
 /// <param name="gate">The gate.</param>
 /// <param name="table">The table.</param>
 /// <param name="row">The row.</param>
 /// <param name="column">The column.</param>
 /// <param name="qualifier">The qualifier.</param>
 /// <param name="timestamp">The timestamp.</param>
 public static string ReadValue(this IStargate gate, string table, string row, string column, string qualifier = null, long?timestamp = null)
 {
     return(gate.ReadValue(BuildIdentifier(table, row, column, qualifier, timestamp)));
 }
Example #14
0
 public RestDatabaseService(string BaseUrl)
 {
     this.BaseUrl     = BaseUrl;
     this.StargateApi = Stargate.Create(BaseUrl);
 }
Example #15
0
 public MailTable(IStargate client)
 {
     _client = client;
 }