Search in sources :

Example 1 with Admin

use of com.mapr.db.Admin in project drill by apache.

the class IndexPlanTest method setupTableIndexes.

/**
 *  A sample row of this 10K table:
 *   ------------------+-----------------------------+--------+
 *   | 1012  | {"city":"pfrrs","state":"pc"}  | {"email":"KfFzKUZwNk@gmail.com","phone":"6500005471"}  |
 *   {"ssn":"100007423"}  | {"fname":"KfFzK","lname":"UZwNk"}  | {"age":53.0,"income":45.0}  | 1012   |
 *
 * This test suite generate random content to fill all the rows, since the random function always start from
 * the same seed for different runs, when the row count is not changed, the data in table will always be the same,
 * thus the query result could be predicted and verified.
 */
@BeforeClass
public static void setupTableIndexes() throws Exception {
    Properties overrideProps = new Properties();
    overrideProps.setProperty("format-maprdb.json.useNumRegionsForDistribution", "true");
    updateTestCluster(1, DrillConfig.create(overrideProps));
    MaprDBTestsSuite.setupTests();
    MaprDBTestsSuite.createPluginAndGetConf(getDrillbitContext());
    test(incrnonCoveringSelectivityThreshold);
    System.out.print("setupTableIndexes begins");
    Admin admin = MaprDBTestsSuite.getAdmin();
    if (admin != null) {
        if (admin.tableExists(PRIMARY_TABLE_NAME)) {
            admin.deleteTable(PRIMARY_TABLE_NAME);
        }
    }
    LargeTableGen gen = new LargeTableGen(MaprDBTestsSuite.getAdmin());
    /**
     * indexDef is an array of string, LargeTableGen.generateTableWithIndex will take it as parameter to generate indexes
     * for primary table.
     * indexDef[3*i] defines i-th index's indexName, NOTE: IF the name begins with "hash", it is a hash index
     * indexDef[3*i+1] indexed field,
     * and indexDef[3*i+2] defines i-th index's non-indexed fields
     */
    final String[] indexDef = { "i_ssn", "id.ssn", "contact.phone", // mainly for composite key test
    "i_state_city", // mainly for composite key test
    "address.state,address.city", // mainly for composite key test
    "name.fname,name.lname", "i_age", "personal.age", "", "i_age_desc", "personal.age:desc", "", "i_income", "personal.income", "", "i_lic", "driverlicense", "reverseid", "i_state_city_dl", "address.state,address.city", "driverlicense", "i_cast_int_ssn", "$CAST(id.ssn@INT)", "contact.phone", "i_cast_vchar_lic", "$CAST(driverlicense@STRING)", "contact.email", "i_state_age_phone", "address.state,personal.age,contact.phone", "name.fname", "i_cast_age_income_phone", "$CAST(personal.age@INT),$CAST(personal.income@INT),contact.phone", "name.fname", "i_age_with_fname", "personal.age", "name.fname", "i_rowid_cast_date_birthdate", "rowid", "$CAST(personal.birthdate@DATE)", "hash_i_reverseid", "reverseid", "", "hash_i_cast_timestamp_firstlogin", "$CAST(activity.irs.firstlogin@TIMESTAMP)", "id.ssn" };
    gen.generateTableWithIndex(PRIMARY_TABLE_NAME, PRIMARY_TABLE_SIZE, indexDef);
}
Also used : Properties(java.util.Properties) Admin(com.mapr.db.Admin) BeforeClass(org.junit.BeforeClass)

Example 2 with Admin

use of com.mapr.db.Admin in project drill by apache.

the class IndexPlanTest method cleanupTableIndexes.

@AfterClass
public static void cleanupTableIndexes() throws Exception {
    Admin admin = MaprDBTestsSuite.getAdmin();
    if (admin != null) {
        if (admin.tableExists(PRIMARY_TABLE_NAME)) {
        // admin.deleteTable(PRIMARY_TABLE_NAME);
        }
    }
    test(defaultnonCoveringSelectivityThreshold);
}
Also used : Admin(com.mapr.db.Admin) AfterClass(org.junit.AfterClass)

Example 3 with Admin

use of com.mapr.db.Admin in project drill by apache.

the class MapRDBIndexDiscover method admin.

@SuppressWarnings("deprecation")
private Admin admin() {
    assert getOriginalScan() instanceof MapRDBGroupScan;
    final MapRDBGroupScan dbGroupScan = (MapRDBGroupScan) getOriginalScan();
    final UserGroupInformation currentUser = ImpersonationUtil.createProxyUgi(dbGroupScan.getUserName());
    final Configuration conf = dbGroupScan.getFormatPlugin().getFsConf();
    final Admin admin;
    try {
        admin = currentUser.doAs((PrivilegedExceptionAction<Admin>) () -> MapRDB.getAdmin(conf));
    } catch (Exception e) {
        throw new DrillRuntimeException("Failed to get Admin instance for user: " + currentUser.getUserName(), e);
    }
    return admin;
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) MapRDBGroupScan(org.apache.drill.exec.store.mapr.db.MapRDBGroupScan) PrivilegedExceptionAction(java.security.PrivilegedExceptionAction) Admin(com.mapr.db.Admin) DrillRuntimeException(org.apache.drill.common.exceptions.DrillRuntimeException) DrillRuntimeException(org.apache.drill.common.exceptions.DrillRuntimeException) IOException(java.io.IOException) DBException(com.mapr.db.exceptions.DBException) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation)

Aggregations

Admin (com.mapr.db.Admin)3 DBException (com.mapr.db.exceptions.DBException)1 IOException (java.io.IOException)1 PrivilegedExceptionAction (java.security.PrivilegedExceptionAction)1 Properties (java.util.Properties)1 DrillRuntimeException (org.apache.drill.common.exceptions.DrillRuntimeException)1 MapRDBGroupScan (org.apache.drill.exec.store.mapr.db.MapRDBGroupScan)1 Configuration (org.apache.hadoop.conf.Configuration)1 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)1 AfterClass (org.junit.AfterClass)1 BeforeClass (org.junit.BeforeClass)1