List of usage examples for org.apache.hadoop.conf Configuration getBoolean
public boolean getBoolean(String name, boolean defaultValue)
name
property as a boolean
. From source file:org.apache.lens.server.api.query.QueryContext.java
License:Apache License
/** * Instantiates a new query context.//from w ww. ja va 2s.c om * * @param userQuery the user query * @param user the user * @param qconf the qconf * @param conf the conf * @param drivers All the drivers * @param selectedDriver the selected driver * @param submissionTime the submission time */ QueryContext(String userQuery, String user, LensConf qconf, Configuration conf, Collection<LensDriver> drivers, LensDriver selectedDriver, long submissionTime, boolean mergeDriverConf) { super(userQuery, user, qconf, conf, drivers, mergeDriverConf); this.submissionTime = submissionTime; this.queryHandle = new QueryHandle(UUID.randomUUID()); this.status = new QueryStatus(0.0f, null, Status.NEW, "Query just got created", false, null, null, null); this.lensConf = qconf; this.conf = conf; this.isPersistent = conf.getBoolean(LensConfConstants.QUERY_PERSISTENT_RESULT_SET, LensConfConstants.DEFAULT_PERSISTENT_RESULT_SET); this.isDriverPersistent = conf.getBoolean(LensConfConstants.QUERY_PERSISTENT_RESULT_INDRIVER, LensConfConstants.DEFAULT_DRIVER_PERSISTENT_RESULT_SET); this.userQuery = userQuery; if (selectedDriver != null) { this.setSelectedDriver(selectedDriver); } this.lensConf = qconf; this.driverStatus = new DriverQueryStatus(); }
From source file:org.apache.lens.server.metastore.CubeMetastoreServiceImpl.java
License:Apache License
private List<String> getNativeTablesFromDB(LensSessionHandle sessionid, String dbName, boolean prependDbName) throws LensException { IMetaStoreClient msc;//from w ww. ja va 2 s .c o m try { msc = getSession(sessionid).getMetaStoreClient(); List<String> tables = msc.getAllTables(dbName); Configuration conf = getSession(sessionid).getSessionConf(); if (!conf.getBoolean(LensConfConstants.EXCLUDE_CUBE_TABLES, LensConfConstants.DEFAULT_EXCLUDE_CUBE_TABLES)) { return tables; } List<String> result = new ArrayList<>(); if (tables != null && !tables.isEmpty()) { List<org.apache.hadoop.hive.metastore.api.Table> tblObjects = msc.getTableObjectsByName(dbName, tables); for (Table tbl : tblObjects) { if (tbl.getParameters().get(MetastoreConstants.TABLE_TYPE_KEY) == null) { if (prependDbName) { result.add(dbName + "." + tbl.getTableName()); } else { result.add(tbl.getTableName()); } } } } return result; } catch (Exception e) { throw new LensException("Error getting native tables from DB", e); } }
From source file:org.apache.lens.server.query.QueryExecutionServiceImpl.java
License:Apache License
/** * This method is used to add a timed out query to cancellation pool. * The query gets cancelled asynchronously * Note : lens.query.cancel.on.timeout should be true for cancellation *//*from www .j a v a2 s. c om*/ private void addQueryToCancellationPool(QueryContext queryCtx, Configuration config, long timeoutMillis) { if (config.getBoolean(CANCEL_QUERY_ON_TIMEOUT, DEFAULT_CANCEL_QUERY_ON_TIMEOUT)) { log.info("Query {} could not be completed within the specified timeout interval. It will be cancelled", queryCtx.getQueryHandleString()); queryCancellationPool.submit(new CancelQueryTask(queryCtx.getQueryHandle())); } else { log.info( "Query {} could not be completed within the specified timeout interval. Query cancellation is disabled", queryCtx.getQueryHandleString()); } }
From source file:org.apache.lens.server.query.TestQueryService.java
License:Apache License
public void checkDefaultConfigConsistency() { Configuration conf = LensSessionImpl.createDefaultConf(); assertNotNull(conf.get("lens.query.enable.persistent.resultset")); boolean isDriverPersistent = conf.getBoolean("lens.query.enable.persistent.resultset", false); conf.setBoolean("lens.query.enable.persistent.resultset", isDriverPersistent ? false : true); conf.set("new_random_property", "new_random_property"); // Get the default conf again and verify its not modified by previous operations conf = LensSessionImpl.createDefaultConf(); boolean isDriverPersistentNow = conf.getBoolean("lens.query.enable.persistent.resultset", false); assertEquals(isDriverPersistentNow, isDriverPersistent); assertNull(conf.get("new_random_property")); }
From source file:org.apache.mahout.cf.taste.hadoop.als.PredictionMapper.java
License:Apache License
@Override protected void setup(Context ctx) throws IOException, InterruptedException { Configuration conf = ctx.getConfiguration(); recommendationsPerUser = conf.getInt(RecommenderJob.NUM_RECOMMENDATIONS, RecommenderJob.DEFAULT_NUM_RECOMMENDATIONS); maxRating = Float.parseFloat(conf.get(RecommenderJob.MAX_RATING)); usesLongIDs = conf.getBoolean(ParallelALSFactorizationJob.USES_LONG_IDS, false); if (usesLongIDs) { userIDIndex = TasteHadoopUtils.readIDIndexMap(conf.get(RecommenderJob.USER_INDEX_PATH), conf); itemIDIndex = TasteHadoopUtils.readIDIndexMap(conf.get(RecommenderJob.ITEM_INDEX_PATH), conf); }/*from w w w. j a v a 2 s. co m*/ }
From source file:org.apache.mahout.cf.taste.hadoop.item.AggregateAndRecommendReducer.java
License:Apache License
@Override protected void setup(Context context) throws IOException { Configuration conf = context.getConfiguration(); recommendationsPerUser = conf.getInt(NUM_RECOMMENDATIONS, DEFAULT_NUM_RECOMMENDATIONS); booleanData = conf.getBoolean(RecommenderJob.BOOLEAN_DATA, false); indexItemIDMap = TasteHadoopUtils.readIDIndexMap(conf.get(ITEMID_INDEX_PATH), conf); idReader = new IDReader(conf); idReader.readIDs();//from www . j a v a2 s . co m itemsToRecommendFor = idReader.getItemIds(); }
From source file:org.apache.mahout.cf.taste.hadoop.item.ItemIDIndexMapper.java
License:Apache License
@Override protected void setup(Context context) { Configuration jobConf = context.getConfiguration(); transpose = jobConf.getBoolean(ToEntityPrefsMapper.TRANSPOSE_USER_ITEM, false); }
From source file:org.apache.mahout.cf.taste.hadoop.ToEntityPrefsMapper.java
License:Apache License
@Override protected void setup(Context context) { Configuration jobConf = context.getConfiguration(); booleanData = jobConf.getBoolean(RecommenderJob.BOOLEAN_DATA, false); transpose = jobConf.getBoolean(TRANSPOSE_USER_ITEM, false); ratingShift = Float.parseFloat(jobConf.get(RATING_SHIFT, "0.0")); }
From source file:org.apache.mahout.cf.taste.hbase.item.AggregateAndRecommendReducer.java
License:Apache License
@Override protected void setup(Context context) throws IOException { Configuration conf = context.getConfiguration(); booleanData = conf.getBoolean(RecommenderJob.BOOLEAN_DATA, false); indexItemIDMap = TasteHadoopUtils.readIDIndexMap(conf.get(ITEMID_INDEX_PATH), conf); idReader = new IDReader(conf); idReader.readIDs();/* w ww. ja va 2s. co m*/ itemsToRecommendFor = idReader.getItemIds(); workingTable = conf.get(RecommenderJob.PARAM_WORKING_TABLE); trainingEnviorement = conf.getBoolean(RecommenderJob.PARAM_TRAINING_ENVIOREMENT, false); recommendationsCf = conf.get(RecommenderJob.PARAM_CF_RECOMMENDATIONS); hbaseClient = new HBaseClient(conf); }
From source file:org.apache.mahout.cf.taste.hbase.ToEntityPrefsMapper.java
License:Apache License
@Override protected void setup(Context context) { Configuration jobConf = context.getConfiguration(); booleanData = jobConf.getBoolean(RecommenderJob.BOOLEAN_DATA, false); ratingShift = Float.parseFloat(jobConf.get(RATING_SHIFT, "0.0")); fcRatings = Bytes.toBytes(jobConf.get(RecommenderJob.PARAM_CF_RATINGS)); }