public static < P extends ParaObject > List < P > readPageFromTable ( String appid , Pager p ) { Pager pager = ( p != null ) ? p : new Pager ( ) ; ScanRequest scanRequest = new ScanRequest ( ) . withTableName ( getTableNameForAppid ( appid ) ) . withLimit ( pager . getLimit ( ) ) . withReturnConsumedCapacity ( ReturnConsumedCapacity . TOTAL ) ; if ( ! StringUtils . isBlank ( pager . getLastKey ( ) ) ) { scanRequest = scanRequest . withExclusiveStartKey ( Collections . singletonMap ( Config . _KEY , new AttributeValue ( pager . getLastKey ( ) ) ) ) ; } ScanResult result = getClient ( ) . scan ( scanRequest ) ; LinkedList < P > results = new LinkedList <> ( ) ; for ( Map < String , AttributeValue > item : result . getItems ( ) ) { P obj = fromRow ( item ) ; if ( obj != null ) { results . add ( obj ) ; } } if ( result . getLastEvaluatedKey ( ) != null ) { pager . setLastKey ( result . getLastEvaluatedKey ( ) . get ( Config . _KEY ) . getS ( ) ) ; } else if ( ! results . isEmpty ( ) ) { // set last key to be equal to the last result - end reached. pager . setLastKey ( results . peekLast ( ) . getId ( ) ) ; } return results ; }
Reads a page from a standard DynamoDB table .