Example usage for com.amazonaws.services.glue.model GetTablesResult getNextToken

List of usage examples for com.amazonaws.services.glue.model GetTablesResult getNextToken

Introduction

In this page you can find the example usage for com.amazonaws.services.glue.model GetTablesResult getNextToken.

Prototype


public String getNextToken() 

Source Link

Document

A continuation token, present if the current list segment is not the last.

Usage

From source file:com.facebook.presto.hive.metastore.glue.GlueHiveMetastore.java

License:Apache License

@Override
public Optional<List<String>> getAllTables(String databaseName) {
    try {//from   w  w w.  j  a  va2s .co  m
        List<String> tableNames = new ArrayList<>();
        String nextToken = null;

        do {
            GetTablesResult result = glueClient
                    .getTables(new GetTablesRequest().withDatabaseName(databaseName).withNextToken(nextToken));
            result.getTableList().forEach(table -> tableNames.add(table.getName()));
            nextToken = result.getNextToken();
        } while (nextToken != null);

        return Optional.of(tableNames);
    } catch (EntityNotFoundException e) {
        // database does not exist
        return Optional.empty();
    } catch (AmazonServiceException e) {
        throw new PrestoException(HIVE_METASTORE_ERROR, e);
    }
}

From source file:com.facebook.presto.hive.metastore.glue.GlueHiveMetastore.java

License:Apache License

@Override
public Optional<List<String>> getAllViews(String databaseName) {
    try {/*from  www  .j  a v a 2 s .co m*/
        List<String> views = new ArrayList<>();
        String nextToken = null;

        do {
            GetTablesResult result = glueClient
                    .getTables(new GetTablesRequest().withDatabaseName(databaseName).withNextToken(nextToken));
            result.getTableList().stream().filter(table -> VIRTUAL_VIEW.name().equals(table.getTableType()))
                    .forEach(table -> views.add(table.getName()));
            nextToken = result.getNextToken();
        } while (nextToken != null);

        return Optional.of(views);
    } catch (EntityNotFoundException e) {
        // database does not exist
        return Optional.empty();
    } catch (AmazonServiceException e) {
        throw new PrestoException(HIVE_METASTORE_ERROR, e);
    }
}