Search code examples
thrift

Thrift How to realize the paging


I use thrift .I want do paging logic.How to do?

for example in java I can do it

Class Page{
  public int total; 
  public int pageSize; 
  public int pageNum; 
  public int totalPageNum; 
  public List<T> elements; 
}
Page findXx(){
   return page;
}

how to do it with thrift . thrift does not support generic


Solution

  • you can use map to do it。 but it is ugly。

       struct PageRange {
            1: i32 startPageNum
            2: i32 pageSize
            3: i32 totalPageNum
            4: i32 totalNum
    }
      map<PageRange,list<T>> query();