本文整理了Java中org.apache.lens.server.api.query.QueryContext.getConf
方法的一些代码示例,展示了QueryContext.getConf
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。QueryContext.getConf
方法的具体详情如下:
包路径:org.apache.lens.server.api.query.QueryContext
类名称:QueryContext
方法名:getConf
暂无
代码示例来源:origin: org.apache.lens/lens-server-api
public String getResultHeader() {
return getConf().get(LensConfConstants.QUERY_OUTPUT_HEADER);
}
代码示例来源:origin: apache/lens
public String getResultFooter() {
return getConf().get(LensConfConstants.QUERY_OUTPUT_FOOTER);
}
代码示例来源:origin: org.apache.lens/lens-server-api
public String getResultFooter() {
return getConf().get(LensConfConstants.QUERY_OUTPUT_FOOTER);
}
代码示例来源:origin: apache/lens
public String getResultHeader() {
return getConf().get(LensConfConstants.QUERY_OUTPUT_HEADER);
}
代码示例来源:origin: apache/lens
@Override
public void write(OutputStream os) throws IOException {
FSDataInputStream fin = null;
try {
FileSystem fs = resultPath.getFileSystem(ctx.getConf());
fin = fs.open(resultPath);
UtilityMethods.pipe(fin, os);
} finally {
if (fin != null) {
fin.close();
}
}
}
};
代码示例来源:origin: org.apache.lens/lens-query-lib
/**
* Inits the header serde.
*
* @throws ClassNotFoundException the class not found exception
* @throws SerDeException the ser de exception
*/
@SuppressWarnings("unchecked")
private void initHeaderSerde() throws ClassNotFoundException, SerDeException {
if (headerSerde == null) {
headerSerde = ReflectionUtils.newInstance(
ctx.getConf().getClass(LensConfConstants.QUERY_OUTPUT_SERDE,
(Class<? extends AbstractSerDe>) Class.forName(LensConfConstants.DEFAULT_OUTPUT_SERDE), SerDe.class),
ctx.getConf());
Properties hprops = new Properties();
if (columnNames.size() > 0) {
hprops.setProperty(serdeConstants.LIST_COLUMNS, StringUtils.join(escapedColumnNames, ","));
}
if (htypes.length() > 0) {
hprops.setProperty(serdeConstants.LIST_COLUMN_TYPES, htypes);
}
headerSerde.initialize(ctx.getConf(), hprops);
headerOI = ObjectInspectorFactory.getStandardStructObjectInspector(columnNames, columnHeaderOIs);
}
}
代码示例来源:origin: org.apache.lens/lens-query-lib
/**
* Inits the output serde.
*/
@SuppressWarnings("unchecked")
private void initOutputSerde() {
try {
outputSerde = ReflectionUtils.newInstance(
ctx.getConf().getClass(LensConfConstants.QUERY_OUTPUT_SERDE,
(Class<? extends AbstractSerDe>) Class.forName(LensConfConstants.DEFAULT_OUTPUT_SERDE), SerDe.class),
ctx.getConf());
Properties props = new Properties();
if (columnNames.size() > 0) {
props.setProperty(serdeConstants.LIST_COLUMNS, StringUtils.join(escapedColumnNames, ","));
}
if (types.length() > 0) {
props.setProperty(serdeConstants.LIST_COLUMN_TYPES, types);
}
outputSerde.initialize(ctx.getConf(), props);
inputOI = ObjectInspectorFactory.getStandardStructObjectInspector(columnNames, columnOIs);
} catch (ClassNotFoundException e) {
throw new IllegalArgumentException(e);
} catch (SerDeException e) {
throw new IllegalArgumentException(e);
}
}
代码示例来源:origin: apache/lens
/**
* Inits the header serde.
*
* @throws ClassNotFoundException the class not found exception
* @throws SerDeException the ser de exception
*/
@SuppressWarnings("unchecked")
private void initHeaderSerde() throws ClassNotFoundException, SerDeException {
if (headerSerde == null) {
headerSerde = ReflectionUtils.newInstance(
ctx.getConf().getClass(LensConfConstants.QUERY_OUTPUT_SERDE,
(Class<? extends AbstractSerDe>) Class.forName(LensConfConstants.DEFAULT_OUTPUT_SERDE), SerDe.class),
ctx.getConf());
Properties hprops = new Properties();
if (columnNames.size() > 0) {
hprops.setProperty(serdeConstants.LIST_COLUMNS, StringUtils.join(escapedColumnNames, ","));
}
if (htypes.length() > 0) {
hprops.setProperty(serdeConstants.LIST_COLUMN_TYPES, htypes);
}
headerSerde.initialize(ctx.getConf(), hprops);
headerOI = ObjectInspectorFactory.getStandardStructObjectInspector(columnNames, columnHeaderOIs);
}
}
代码示例来源:origin: apache/lens
/**
* Inits the output serde.
*/
@SuppressWarnings("unchecked")
private void initOutputSerde() {
try {
outputSerde = ReflectionUtils.newInstance(
ctx.getConf().getClass(LensConfConstants.QUERY_OUTPUT_SERDE,
(Class<? extends AbstractSerDe>) Class.forName(LensConfConstants.DEFAULT_OUTPUT_SERDE), SerDe.class),
ctx.getConf());
Properties props = new Properties();
if (columnNames.size() > 0) {
props.setProperty(serdeConstants.LIST_COLUMNS, StringUtils.join(escapedColumnNames, ","));
}
if (types.length() > 0) {
props.setProperty(serdeConstants.LIST_COLUMN_TYPES, types);
}
outputSerde.initialize(ctx.getConf(), props);
inputOI = ObjectInspectorFactory.getStandardStructObjectInspector(columnNames, columnOIs);
} catch (ClassNotFoundException e) {
throw new IllegalArgumentException(e);
} catch (SerDeException e) {
throw new IllegalArgumentException(e);
}
}
代码示例来源:origin: apache/lens
if (isPersistedInDriver) {
formatter = ReflectionUtils.newInstance(
ctx.getConf().getClass(
LensConfConstants.QUERY_OUTPUT_FORMATTER,
(Class<? extends PersistedOutputFormatter>) Class
.forName(LensConfConstants.DEFAULT_PERSISTENT_OUTPUT_FORMATTER), PersistedOutputFormatter.class),
ctx.getConf());
} else {
formatter = ReflectionUtils.newInstance(
ctx.getConf().getClass(
LensConfConstants.QUERY_OUTPUT_FORMATTER,
(Class<? extends InMemoryOutputFormatter>) Class
.forName(LensConfConstants.DEFAULT_INMEMORY_OUTPUT_FORMATTER), InMemoryOutputFormatter.class),
ctx.getConf());
代码示例来源:origin: apache/lens
private static void deferFormattingIfApplicable(QueryContext ctx) {
long deferPersistenceByMillis = ctx.getConf().getLong("deferPersistenceByMillis", 0);
if (deferPersistenceByMillis > 0) {
try {
log.info("Deferring result formatting by {} millis", deferPersistenceByMillis);
Thread.sleep(deferPersistenceByMillis);
} catch (InterruptedException e) {
// Ignore
}
}
}
代码示例来源:origin: org.apache.lens/lens-query-lib
@Override
public void commit() throws IOException {
rowWriter.close(Reporter.NULL);
if (outputPath != null && rowWriter.getTmpPath() != null) {
FileSystem fs = outputPath.getFileSystem(ctx.getConf());
finalPath = outputPath;
if (rowWriter.getExtn() != null) {
finalPath = new Path(outputPath + rowWriter.getExtn());
}
finalPath = finalPath.makeQualified(fs);
fs.rename(rowWriter.getTmpPath(), finalPath);
ctx.setResultSetPath(finalPath.toString());
fileSize = fs.getFileStatus(finalPath).getLen();
}
}
代码示例来源:origin: apache/lens
@Override
public void commit() throws IOException {
rowWriter.close(Reporter.NULL);
if (outputPath != null && rowWriter.getTmpPath() != null) {
FileSystem fs = outputPath.getFileSystem(ctx.getConf());
finalPath = outputPath;
if (rowWriter.getExtn() != null) {
finalPath = new Path(outputPath + rowWriter.getExtn());
}
finalPath = finalPath.makeQualified(fs);
fs.rename(rowWriter.getTmpPath(), finalPath);
ctx.setResultSetPath(finalPath.toString());
fileSize = fs.getFileStatus(finalPath).getLen();
}
}
代码示例来源:origin: apache/lens
tmpPath = new Path(pathStr, ctx.getQueryHandle().toString() + ".tmp.zip");
if (ctx.getConf().getBoolean(LensConfConstants.READ_RESULT_FROM_HDFS,
LensConfConstants.DEFAULT_READ_RESULT_FROM_HDFS)) {
fs = FileSystemUtil.createFileSystem(ctx.getSubmittedUser(), new Path(pathStr));
} else {
fs = finalPath.getFileSystem(ctx.getConf());
代码示例来源:origin: org.apache.lens/lens-query-lib
public void setupOutputs() throws IOException {
resultFileExtn = ctx.getOuptutFileExtn();
maxSplitRows = ctx.getMaxResultSplitRows();
numRows = 0;
String pathStr = ctx.getResultSetParentDir();
if (StringUtils.isBlank(pathStr)) {
throw new IllegalArgumentException("No output path specified");
}
String finalPathStr = Strings.isNullOrEmpty(ctx.getQueryName()) ? ""
: LensFileOutputFormat.getValidOutputFileName(ctx.getQueryName()) + "-";
finalPath = new Path(pathStr, finalPathStr + ctx.getQueryHandle().toString() + ".zip");
tmpPath = new Path(pathStr, ctx.getQueryHandle().toString() + ".tmp.zip");
fs = finalPath.getFileSystem(ctx.getConf());
zipOut = new ZipOutputStream((fs.create(tmpPath)));
ZipEntry zipEntry = new ZipEntry(getQueryResultFileName());
zipOut.putNextEntry(zipEntry);
encoding = ctx.getResultEncoding();
// Write the UTF-16LE BOM (FF FE)
if (encoding.equals(LensFileOutputFormat.UTF16LE)) {
zipOut.write(0xFF);
zipOut.write(0xFE);
out = new OutputStreamWriter(zipOut, encoding);
} else {
out = new OutputStreamWriter(zipOut, encoding);
}
}
代码示例来源:origin: org.apache.lens/lens-driver-hive
resultSetPath.makeQualified(resultSetPath.getFileSystem(context.getConf())).toString());
builder.append('"').append(resultSetPath).append("\" ");
String outputDirFormat = qdconf.get(LensConfConstants.QUERY_OUTPUT_DIRECTORY_FORMAT);
代码示例来源:origin: apache/lens
public void setupOutputs() throws IOException {
String pathStr = ctx.getResultSetParentDir();
if (StringUtils.isBlank(pathStr)) {
throw new IllegalArgumentException("No output path specified");
}
String outputPathStr = Strings.isNullOrEmpty(ctx.getQueryName()) ? ""
: LensFileOutputFormat.getValidOutputFileName(ctx.getQueryName()) + "-";
outputPath = new Path(pathStr, outputPathStr + ctx.getQueryHandle().toString());
Path tmpWorkPath = new Path(pathStr, ctx.getQueryHandle().toString() + ".tmp");
try {
rowWriter = LensFileOutputFormat.createRecordWriter(ctx.getConf(), tmpWorkPath, Reporter.NULL,
ctx.getCompressOutput(), ctx.getOuptutFileExtn(), ctx.getResultEncoding());
numRows=0;
} catch (IOException e) {
throw new IllegalArgumentException("Could not create tmp path");
}
}
代码示例来源:origin: apache/lens
/**
* Checks if the events needs a HTTP notification.
*
* @param event
* @param queryContext
* @return
*/
protected boolean isHttpNotificationEnabled(QueryEvent event, QueryContext queryContext) {
if (queryContext == null) {
log.warn("Could not find the context for {} for event:{}. {} HTTP Notification will be generated",
event.getQueryHandle(), event.getCurrentValue(), getNotificationType());
return false;
}
boolean isQueryHTTPNotificationEnabled = queryContext.getConf().getBoolean(
QUERY_HTTP_NOTIFICATION_TYPE_PFX + getNotificationType().name(), false);
if (!isQueryHTTPNotificationEnabled) {
log.info("{} HTTP notification for query {} is not enabled",
getNotificationType(), queryContext.getQueryHandleString());
return false;
}
return true;
}
代码示例来源:origin: org.apache.lens/lens-query-lib
public void setupOutputs() throws IOException {
String pathStr = ctx.getResultSetParentDir();
if (StringUtils.isBlank(pathStr)) {
throw new IllegalArgumentException("No output path specified");
}
String outputPathStr = Strings.isNullOrEmpty(ctx.getQueryName()) ? ""
: LensFileOutputFormat.getValidOutputFileName(ctx.getQueryName()) + "-";
outputPath = new Path(pathStr, outputPathStr + ctx.getQueryHandle().toString());
Path tmpWorkPath = new Path(pathStr, ctx.getQueryHandle().toString() + ".tmp");
try {
rowWriter = LensFileOutputFormat.createRecordWriter(ctx.getConf(), tmpWorkPath, Reporter.NULL,
ctx.getCompressOutput(), ctx.getOuptutFileExtn(), ctx.getResultEncoding());
numRows=0;
} catch (IOException e) {
throw new IllegalArgumentException("Could not create tmp path");
}
}
代码示例来源:origin: apache/lens
public static QueryEnded mockQueryEnded(SchedulerJobInstanceHandle instanceHandle, QueryStatus.Status status) {
QueryContext mockContext = PowerMockito.mock(QueryContext.class);
PowerMockito.when(mockContext.getResultSetPath()).thenReturn("/tmp/query1/result");
Configuration conf = new Configuration();
// set the instance handle
conf.set("job_instance_key", instanceHandle.getHandleIdString());
PowerMockito.when(mockContext.getConf()).thenReturn(conf);
// Get the queryHandle.
PowerMockito.when(mockContext.getQueryHandle()).thenReturn(new QueryHandle(UUID.randomUUID()));
QueryEnded queryEnded = PowerMockito.mock(QueryEnded.class);
PowerMockito.when(queryEnded.getQueryContext()).thenReturn(mockContext);
PowerMockito.when(queryEnded.getCurrentValue()).thenReturn(status);
return queryEnded;
}
}
内容来源于网络,如有侵权,请联系作者删除!