public class IndexServiceImpl extends Object implements IndexService
NOP_PROJECTION| 构造器和说明 |
|---|
IndexServiceImpl(StorageService storageService,
TableDef tableDef,
KeyComparator keyComparator) |
| 限定符和类型 | 方法和说明 |
|---|---|
Iterator<GenericRecord> |
getQueryAllIterator(Optional<List<String>> recordProjection,
boolean ascOrder)
Return an iterator to query all records of a tablespace.
|
Iterator<GenericRecord> |
getQueryIteratorBySk(String skName,
List<Object> lower,
ComparisonOperator lowerOperator,
List<Object> upper,
ComparisonOperator upperOperator,
Optional<List<String>> recordProjection,
boolean ascOrder)
Return record iterator by secondary key (SK) in a tablespace.
|
Iterator<GenericRecord> |
getRangeQueryIterator(List<Object> lower,
ComparisonOperator lowerOperator,
List<Object> upper,
ComparisonOperator upperOperator,
Optional<List<String>> recordProjection,
boolean ascOrder)
The implementation is different from the way
queryAll(Optional, Optional) works. |
Iterator<GenericRecord> |
getSkRangeQueryIterator(TableDef skTableDef,
long skRootPageNumber,
List<Object> lower,
ComparisonOperator lowerOperator,
List<Object> upper,
ComparisonOperator upperOperator,
boolean ascOrder)
Return secondary key (SK) record iterator in a tablespace.
|
Index |
loadIndexPage(long pageNumber)
Load index page by page number.
|
List<GenericRecord> |
queryAll(Optional<java.util.function.Predicate<GenericRecord>> recordPredicate,
Optional<List<String>> recordProjection)
Query all records in a tablespace.
|
List<GenericRecord> |
queryByPageNumber(int pageNumber)
Query all records by single index page.
|
List<GenericRecord> |
queryByPageNumber(long pageNumber)
Query all records by single index page.
|
GenericRecord |
queryByPrimaryKey(List<Object> key,
Optional<List<String>> recordProjection)
Query record by primary key in a tablespace with projection list.
|
List<GenericRecord> |
rangeQueryByPrimaryKey(List<Object> lower,
ComparisonOperator lowerOperator,
List<Object> upper,
ComparisonOperator upperOperator,
Optional<java.util.function.Predicate<GenericRecord>> recordPredicate,
Optional<List<String>> recordProjection)
Range query records by primary key in a tablespace.
|
public IndexServiceImpl(StorageService storageService, TableDef tableDef, KeyComparator keyComparator)
public List<GenericRecord> queryByPageNumber(int pageNumber)
queryByPageNumber 在接口中 IndexServicepageNumber - page number (int type), can be leaf or non-leaf pagepublic List<GenericRecord> queryByPageNumber(long pageNumber)
queryByPageNumber 在接口中 IndexServicepageNumber - page number (long type), can be leaf or non-leaf pagepublic List<GenericRecord> queryAll(Optional<java.util.function.Predicate<GenericRecord>> recordPredicate, Optional<List<String>> recordProjection)
Note this will cause out-of-memory if the table size is too big. Make sure fields are included in projection for predicate to use.
queryAll 在接口中 IndexServicerecordPredicate - optional filtering, if predicate returns true upon
record, then it will be added to result setrecordProjection - optional projection of selected column names, if no present, all
fields will be includedpublic GenericRecord queryByPrimaryKey(List<Object> key, Optional<List<String>> recordProjection)
For single key, the the list size should be one, for composite key the size will be more than one.
queryByPrimaryKey 在接口中 IndexServicekey - primary key, single key or a composite keyrecordProjection - optional projection of selected column names, if no present, all
fields will be includedpublic Iterator<GenericRecord> getQueryAllIterator(Optional<List<String>> recordProjection, boolean ascOrder)
Leverage getRangeQueryIterator(List, ComparisonOperator, List, ComparisonOperator, Optional, boolean).
This is friendly to memory since only one page is loaded per batch.
getQueryAllIterator 在接口中 IndexServicerecordProjection - optional projection of selected column names, if no present, all
fields will be includedascOrder - if set result records in ascending orderpublic Iterator<GenericRecord> getRangeQueryIterator(List<Object> lower, ComparisonOperator lowerOperator, List<Object> upper, ComparisonOperator upperOperator, Optional<List<String>> recordProjection, boolean ascOrder)
queryAll(Optional, Optional) works.
This method will do point query to search the nearest lower and upper bound record, then visit the leaf
page, go through all the level 0 pages by the double-linked pages.
While queryAll(Optional, Optional) traverses b+ tree in a depth-first way.
getRangeQueryIterator 在接口中 IndexServicelower - lower boundlowerOperator - comparison operator for lowerupper - upper boundupperOperator - comparison operator for upperrecordProjection - optional projection of selected column names, if no present, all
fields will be includedascOrder - if set result records in ascending orderpublic Iterator<GenericRecord> getQueryIteratorBySk(String skName, List<Object> lower, ComparisonOperator lowerOperator, List<Object> upper, ComparisonOperator upperOperator, Optional<List<String>> recordProjection, boolean ascOrder)
This is friendly to memory since only one page is loaded per batch.
For single key the lower or upper list size should be one, for composite key the size will be more than one.
getQueryIteratorBySk 在接口中 IndexServiceskName - secondary key name in SHOW CREATE TABLE commandlower - lower boundlowerOperator - comparison operator for lowerupper - upper boundupperOperator - comparison operator for upperascOrder - if set result records in ascending orderrecordProjection - optional projection of selected column names, if no present, all
fields will be includedpublic Iterator<GenericRecord> getSkRangeQueryIterator(TableDef skTableDef, long skRootPageNumber, List<Object> lower, ComparisonOperator lowerOperator, List<Object> upper, ComparisonOperator upperOperator, boolean ascOrder)
skTableDef - secondary key virtual table definitionskRootPageNumber - secondary key root page numberlower - lower boundlowerOperator - comparison operator for lowerupper - upper boundupperOperator - comparison operator for upperascOrder - if set result records in ascending orderpublic List<GenericRecord> rangeQueryByPrimaryKey(List<Object> lower, ComparisonOperator lowerOperator, List<Object> upper, ComparisonOperator upperOperator, Optional<java.util.function.Predicate<GenericRecord>> recordPredicate, Optional<List<String>> recordProjection)
For single key the lower or upper list size should be one, for composite key the size will be more than one.
Leverage getRangeQueryIterator(List, ComparisonOperator, List, ComparisonOperator, Optional, boolean)
if range is specified, or else fallback to queryAll(Optional, Optional).
rangeQueryByPrimaryKey 在接口中 IndexServicelower - if rangeQuery is true, then this is the lower boundlowerOperator - if rangeQuery is true, then this is the comparison operator for lowerupper - if rangeQuery is true, then this is the upper boundupperOperator - if rangeQuery is true, then this is the comparison operator for upperrecordPredicate - optional. evaluating record, if true then it will be added to
result set, else skip itrecordProjection - optional projection of selected column names, if no present, all
fields will be includedpublic Index loadIndexPage(long pageNumber)
IndexServiceloadIndexPage 在接口中 IndexServicepageNumber - page numberCopyright © 2019–2020 Alibaba Group Holding Limited. All rights reserved.