linearregression / hypertable

Automatically exported from code.google.com/p/hypertable
GNU General Public License v2.0
0 stars 0 forks source link

Thrift namespaces #256

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Its a little confusing when generating the thrift output that you get a
"gen" and "gen2" folder; would be better as "Client" and "HQL"
respectively. That way, when importing into (for example) python, it reads
better for those coming to the code later on:

from hyperthrift.Client import ClientService
from hyperthrift.HQL import HqlService

Original issue reported on code.google.com by phillip....@gmail.com on 9 Mar 2009 at 10:52

GoogleCodeExporter commented 9 years ago
Proposal for changes to thrift files below.

Mostly just changes to the namespace declarations
and HQL service methods.

Comments removed for brevity.

#--  Client.thrift  ------------------------

namespace cpp   Hypertable.Client
namespace java  org.hypertable.client
namespace perl  Hypertable.Client
namespace php   Hypertable_Client
namespace py    hyperthrift.Client
namespace rb    Hypertable.Client

typedef i64 Scanner
typedef i64 Mutator
typedef binary Value

struct RowInterval {
  1: optional string start_row
  2: optional bool start_inclusive = 1
  3: optional string end_row    # 'end' chokes ruby
  4: optional bool end_inclusive = 1
}

struct CellInterval {
  1: optional string start_row
  2: optional string start_column
  3: optional bool start_inclusive = 1
  4: optional string end_row
  5: optional string end_column
  6: optional bool end_inclusive = 1
}

struct ScanSpec {
  1: optional list<RowInterval> row_intervals
  2: optional list<CellInterval> cell_intervals
  3: optional bool return_deletes = 0
  4: optional i32 revs = 0
  5: optional i32 row_limit = 0
  6: optional i64 start_time
  7: optional i64 end_time
  8: optional list<string> columns
}

enum CellFlag {
  DELETE_ROW = 0,
  DELETE_CF = 1,
  DELETE_CELL = 2,
  INSERT = 255
}

struct Cell {
  1: optional string row_key
  2: optional string column_family
  3: optional string column_qualifier
  4: optional Value value
  5: optional i64 timestamp
  6: optional i64 revision
  7: optional i16 flag = INSERT
}

exception ClientException {
  1: i32 code
  2: string what
}

service ClientService {

  void create_table(1:string name, 2:string schema)
    throws (1:ClientException e),

  Scanner open_scanner(1:string name, 2:ScanSpec scan_spec)
    throws (1:ClientException e),

  void close_scanner(1:Scanner scanner) 
    throws (1:ClientException e),

  list<Cell> next_cells(1:Scanner scanner) 
    throws (1:ClientException e),

  list<Cell> get_row(1:string name, 2:string row) 
    throws (1:ClientException e),

  Value get_cell(1:string name, 2:string row, 3:string column)
    throws (1:ClientException e),

  list<Cell> get_cells(1:string name, 2:ScanSpec scan_spec)
    throws (1:ClientException e),

  Mutator open_mutator(1:string name) 
    throws (1:ClientException e),

  void close_mutator(1:Mutator mutator, 2:bool flush = 1)
    throws (1:ClientException e),

  void set_cell(1:Mutator mutator, 2:Cell cell) 
    throws (1:ClientException e),

  void set_cells(1:Mutator mutator, 2:list<Cell> cells)
    throws (1:ClientException e),

  void flush_mutator(1:Mutator mutator) 
    throws (1:ClientException e),

  i32 get_table_id(1:string name) 
    throws (1:ClientException e),

  string get_schema(1:string name) 
    throws (1:ClientException e),

  list<string> get_tables() 
    throws (1:ClientException e),

  void drop_table(1:string name, 2:bool if_exists = 1)
    throws (1:ClientException e),
}

#--  Hql.thrift  ---------------------------

include "Client.thrift"

namespace cpp   Hypertable.Query
namespace java  org.hypertable.query
namespace perl  Hypertable.Query
namespace php   Hypertable_Query
namespace py    hyperthrift.Query # ditto
namespace rb    Hypertable.Query

struct HqlResult {
  1: optional list<string> results,
  2: optional list<Client.Cell> cells,
  3: optional i64 scanner,
  4: optional i64 mutator
}

service HqlService 
  extends Client.ClientService {

  HqlResult exec(
      1:string command, 
      2:bool noflush = 0,
      3:bool unbuffered = 0
    )
    throws (1:Client.ClientException e),

  HqlResult query(
      1:string command
    ) 
    throws (1:Client.ClientException e)
}

Original comment by phillip....@gmail.com on 10 Mar 2009 at 7:12

GoogleCodeExporter commented 9 years ago
Maybe it would be good to standardise on "hyperthrift" as the main library 
across all
languages?

Original comment by phillip....@gmail.com on 10 Mar 2009 at 7:16

GoogleCodeExporter commented 9 years ago
Thanks for the suggestions. Users are not expected to use thrift generated file
directly though.

They should use a client library (so timeouts etc can be easily specified) and 
use
client.hql_exec etc. So I wouldn't remove the hql_ prefixes.

HyperThrift sounds like a good name, and we already have libHyperThrift for C++ 
clients.

Original comment by vic...@gmail.com on 10 Mar 2009 at 11:25

GoogleCodeExporter commented 9 years ago
is it possible to have a different namespaces in the same file?

Original comment by viju...@gmail.com on 25 Feb 2010 at 9:29

GoogleCodeExporter commented 9 years ago

Original comment by nuggetwh...@gmail.com on 14 Jan 2012 at 8:32