关于spark:SparkESClickHouse-构建DMP用户画像

36次阅读

共计 1229 个字符,预计需要花费 4 分钟才能阅读完成。

获取 ZY:Spark+ES+ClickHouse 构建 DMP 用户画像

importjava.util.Arrays;
importjava.util.Collections;
importjava.util.List;

publicclassListPageUtil{

 
/**
 * 每页浮现条数
 */
privateintpageSize;
 
/**
 * 总页数
 */
privateintpageCount;
 
/**
 * 原汇合
 */
privateListdata;

publicListPageUtil(Listdata,intpageSize) {if(data ==null|| data.isEmpty()) {thrownewIllegalArgumentException("data must be not empty!");
    }

    this.data = data;
    this.pageSize = pageSize;
    this.pageCount = data.size()/pageSize;
    if(data.size()%pageSize!=0){this.pageCount++;}
}

/**
 * 失去分页后的数据
 *
 * @param pageNum 页码
 * @return 分页后后果
 */
publicListgetPagedList(intpageNum) {intfromIndex = (pageNum -1) * pageSize;
    if(fromIndex >= data.size()) {returnCollections.emptyList();
    }

    inttoIndex = pageNum * pageSize;
    if(toIndex >= data.size()) {toIndex = data.size();
    }
    returndata.subList(fromIndex, toIndex);
}

publicintgetPageSize() {returnpageSize;}

publicListgetData() {returndata;}

publicintgetPageCount() {returnpageCount;}

publicstaticvoidmain(String[] args) {Integer[] array = {1,2,3,4,5,6,7,8,9,10,11,12};
    Listlist = Arrays.asList(array);

    ListPageUtilpager =newListPageUtil(list,10);
    
    System.out.println(pager.getPageCount());

    Listpage1 = pager.getPagedList(1);
    System.out.println(page1);

    Listpage2 = pager.getPagedList(2);
    System.out.println(page2);

    Listpage3 = pager.getPagedList(3);
    System.out.println(page3);
}

}

正文完
 0