当前位置: 首页>>代码示例>>Java>>正文


Java StringUtil类代码示例

本文整理汇总了Java中org.apache.kylin.common.util.StringUtil的典型用法代码示例。如果您正苦于以下问题:Java StringUtil类的具体用法?Java StringUtil怎么用?Java StringUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


StringUtil类属于org.apache.kylin.common.util包,在下文中一共展示了StringUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import org.apache.kylin.common.util.StringUtil; //导入依赖的package包/类
void init(DataModelDesc model) {
    table = table.toUpperCase();
    if (columns != null) {
        StringUtil.toUpperCaseArray(columns, columns);
    }

    if (model != null) {
        table = model.findTable(table).getAlias();
        if (columns != null) {
            for (int i = 0; i < columns.length; i++) {
                TblColRef column = model.findColumn(table, columns[i]);

                if (column.getColumnDesc().isComputedColumn() && !model.isFactTable(column.getTableRef())) {
                    throw new RuntimeException("Computed Column on lookup table is not allowed");
                }

                columns[i] = column.getName();
            }
        }
    }
}
 
开发者ID:apache,项目名称:kylin,代码行数:22,代码来源:ModelDimensionDesc.java

示例2: createMergeCuboidDataStep

import org.apache.kylin.common.util.StringUtil; //导入依赖的package包/类
public MapReduceExecutable createMergeCuboidDataStep(CubeSegment seg, List<CubeSegment> mergingSegments, String jobID, Class<? extends AbstractHadoopJob> clazz) {

        final List<String> mergingCuboidPaths = Lists.newArrayList();
        for (CubeSegment merging : mergingSegments) {
            mergingCuboidPaths.add(getCuboidRootPath(merging) + "*");
        }
        String formattedPath = StringUtil.join(mergingCuboidPaths, ",");
        String outputPath = getCuboidRootPath(jobID);

        MapReduceExecutable mergeCuboidDataStep = new MapReduceExecutable();
        mergeCuboidDataStep.setName(ExecutableConstants.STEP_NAME_MERGE_CUBOID);
        StringBuilder cmd = new StringBuilder();

        appendMapReduceParameters(cmd);
        appendExecCmdParameters(cmd, BatchConstants.ARG_CUBE_NAME, seg.getCubeInstance().getName());
        appendExecCmdParameters(cmd, BatchConstants.ARG_SEGMENT_ID, seg.getUuid());
        appendExecCmdParameters(cmd, BatchConstants.ARG_INPUT, formattedPath);
        appendExecCmdParameters(cmd, BatchConstants.ARG_OUTPUT, outputPath);
        appendExecCmdParameters(cmd, BatchConstants.ARG_JOB_NAME, "Kylin_Merge_Cuboid_" + seg.getCubeInstance().getName() + "_Step");

        mergeCuboidDataStep.setMapReduceParams(cmd.toString());
        mergeCuboidDataStep.setMapReduceJobClass(clazz);
        return mergeCuboidDataStep;
    }
 
开发者ID:apache,项目名称:kylin,代码行数:25,代码来源:HBaseMRSteps.java

示例3: configureSparkJob

import org.apache.kylin.common.util.StringUtil; //导入依赖的package包/类
public static void configureSparkJob(final CubeSegment seg, final SparkExecutable sparkExecutable,
        final String jobId, final String cuboidRootPath) {
    IJoinedFlatTableDesc flatTableDesc = EngineFactory.getJoinedFlatTableDesc(seg);
    sparkExecutable.setParam(SparkCubingByLayer.OPTION_CUBE_NAME.getOpt(), seg.getRealization().getName());
    sparkExecutable.setParam(SparkCubingByLayer.OPTION_SEGMENT_ID.getOpt(), seg.getUuid());
    sparkExecutable.setParam(SparkCubingByLayer.OPTION_INPUT_TABLE.getOpt(),
            seg.getConfig().getHiveDatabaseForIntermediateTable() + "." + flatTableDesc.getTableName());
    sparkExecutable.setParam(SparkCubingByLayer.OPTION_META_URL.getOpt(),
            getSegmentMetadataUrl(seg.getConfig(), seg.getUuid()));
    sparkExecutable.setParam(SparkCubingByLayer.OPTION_OUTPUT_PATH.getOpt(), cuboidRootPath);
    sparkExecutable.setJobId(jobId);

    StringBuilder jars = new StringBuilder();

    StringUtil.appendWithSeparator(jars, findJar("org.htrace.HTraceConfiguration", null)); // htrace-core.jar
    StringUtil.appendWithSeparator(jars, findJar("org.apache.htrace.Trace", null)); // htrace-core.jar
    StringUtil.appendWithSeparator(jars, findJar("org.cloudera.htrace.HTraceConfiguration", null)); // htrace-core.jar
    StringUtil.appendWithSeparator(jars, findJar("com.yammer.metrics.core.Gauge", null)); // metrics-core.jar
    StringUtil.appendWithSeparator(jars, findJar("com.google.common.collect.Maps", "guava")); //guava.jar

    StringUtil.appendWithSeparator(jars, seg.getConfig().getSparkAdditionalJars());
    sparkExecutable.setJars(jars.toString());
    sparkExecutable.setName(ExecutableConstants.STEP_NAME_BUILD_SPARK_CUBE);
}
 
开发者ID:apache,项目名称:kylin,代码行数:25,代码来源:SparkBatchCubingJobBuilder2.java

示例4: newInstance

import org.apache.kylin.common.util.StringUtil; //导入依赖的package包/类
static DataModelManager newInstance(KylinConfig conf) {
    try {
        String cls = StringUtil.noBlank(conf.getDataModelManagerImpl(), DataModelManager.class.getName());
        Class<? extends DataModelManager> clz = ClassUtil.forName(cls, DataModelManager.class);
        return clz.getConstructor(KylinConfig.class).newInstance(conf);
    } catch (Exception e) {
        throw new RuntimeException("Failed to init DataModelManager from " + conf, e);
    }
}
 
开发者ID:apache,项目名称:kylin,代码行数:10,代码来源:DataModelManager.java

示例5: getDataModelImplClass

import org.apache.kylin.common.util.StringUtil; //导入依赖的package包/类
private Class<DataModelDesc> getDataModelImplClass() {
    try {
        String cls = StringUtil.noBlank(config.getDataModelImpl(), DataModelDesc.class.getName());
        Class<? extends DataModelDesc> clz = ClassUtil.forName(cls, DataModelDesc.class);
        return (Class<DataModelDesc>) clz;
    } catch (ClassNotFoundException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:apache,项目名称:kylin,代码行数:10,代码来源:DataModelManager.java

示例6: containsTable

import org.apache.kylin.common.util.StringUtil; //导入依赖的package包/类
public boolean containsTable(TableDesc table) {
    for (TableRef t : allTableRefs) {
        if (t.getTableIdentity().equals(table.getIdentity())
                && StringUtil.equals(t.getTableDesc().getProject(), table.getProject()))
            return true;
    }
    return false;
}
 
开发者ID:apache,项目名称:kylin,代码行数:9,代码来源:DataModelDesc.java

示例7: parseEncodingConf

import org.apache.kylin.common.util.StringUtil; //导入依赖的package包/类
public static Object[] parseEncodingConf(String encoding) {
    String[] parts = encoding.split("\\s*[(),:]\\s*");
    if (parts == null || parts.length == 0 || parts[0].isEmpty())
        throw new IllegalArgumentException("Not supported row key col encoding: '" + encoding + "'");

    final String encodingName = parts[0];
    final String[] encodingArgs = parts[parts.length - 1].isEmpty() //
            ? StringUtil.subArray(parts, 1, parts.length - 1) : StringUtil.subArray(parts, 1, parts.length);

    return new Object[] { encodingName, encodingArgs };
}
 
开发者ID:apache,项目名称:kylin,代码行数:12,代码来源:DimensionEncoding.java

示例8: RandomGen

import org.apache.kylin.common.util.StringUtil; //导入依赖的package包/类
public RandomGen(ColumnDesc col, String format, int randStart, int randEnd, int cardinality) {
    this.type = col.getType();

    if (type.isStringFamily()) {
        // string
        if (StringUtils.isBlank(format)) {
            String name = col.getName();
            format = name.substring(0, Math.min(4, name.length())) + ColumnGenConfig.$RANDOM;
        }
        Preconditions.checkArgument(format.contains(ColumnGenConfig.$RANDOM));
        initNumberRange(randStart, randEnd, cardinality);
    } else if (type.isTimeFamily()) {
        // time
        format = StringUtil.noBlank(format, DateFormat.DEFAULT_DATETIME_PATTERN_WITHOUT_MILLISECONDS);
        initDateTimeRange(randStart, randEnd, 0);
    } else if (type.isDateTimeFamily()) {
        // date
        format = StringUtil.noBlank(format, DateFormat.DEFAULT_DATE_PATTERN);
        initDateTimeRange(randStart, randEnd, cardinality);
    } else if (type.isIntegerFamily()) {
        // integer
        initNumberRange(randStart, randEnd, cardinality);
        format = StringUtil.noBlank(format, "#");
    } else if (type.isNumberFamily()) {
        // double
        initNumberRange(randStart, randEnd, 0);
        format = StringUtil.noBlank(format, ".##");
    } else {
        throw new IllegalArgumentException();
    }

    this.format = format;
    this.rand = new Random();
}
 
开发者ID:apache,项目名称:kylin,代码行数:35,代码来源:ColumnGenerator.java

示例9: countSizeInBytes

import org.apache.kylin.common.util.StringUtil; //导入依赖的package包/类
private long countSizeInBytes(String[] row) {
    int size = 0;
    for (String s : row) {
        size += s == null ? 1 : StringUtil.utf8Length(s);
        size++; // delimiter
    }
    return size;
}
 
开发者ID:apache,项目名称:kylin,代码行数:9,代码来源:FactDistinctColumnsMapper.java

示例10: handleMetaDataPersistException

import org.apache.kylin.common.util.StringUtil; //导入依赖的package包/类
/**
 * build fail because the metadata store has problem.
 * @param exception
 */
@Override
protected void handleMetaDataPersistException(Exception exception) {
    String title = "[ERROR] - [" + getDeployEnvName() + "] - [" + getProjectName() + "] - "
            + CubingExecutableUtil.getCubeName(this.getParams());
    String content = ExecutableConstants.NOTIFY_EMAIL_TEMPLATE;
    final String UNKNOWN = "UNKNOWN";
    String errMsg = null;
    if (exception != null) {
        final StringWriter out = new StringWriter();
        exception.printStackTrace(new PrintWriter(out));
        errMsg = out.toString();
    }

    content = content.replaceAll("\\$\\{job_name\\}", getName());
    content = content.replaceAll("\\$\\{result\\}", ExecutableState.ERROR.toString());
    content = content.replaceAll("\\$\\{env_name\\}", getDeployEnvName());
    content = content.replaceAll("\\$\\{project_name\\}", getProjectName());
    content = content.replaceAll("\\$\\{cube_name\\}", CubingExecutableUtil.getCubeName(this.getParams()));
    content = content.replaceAll("\\$\\{source_records_count\\}", UNKNOWN);
    content = content.replaceAll("\\$\\{start_time\\}", UNKNOWN);
    content = content.replaceAll("\\$\\{duration\\}", UNKNOWN);
    content = content.replaceAll("\\$\\{mr_waiting\\}", UNKNOWN);
    content = content.replaceAll("\\$\\{last_update_time\\}", UNKNOWN);
    content = content.replaceAll("\\$\\{submitter\\}", StringUtil.noBlank(getSubmitter(), "missing submitter"));
    content = content.replaceAll("\\$\\{error_log\\}",
            Matcher.quoteReplacement(StringUtil.noBlank(errMsg, "no error message")));

    try {
        InetAddress inetAddress = InetAddress.getLocalHost();
        content = content.replaceAll("\\$\\{job_engine\\}", inetAddress.getCanonicalHostName());
    } catch (UnknownHostException e) {
        logger.warn(e.getLocalizedMessage(), e);
    }
    sendMail(Pair.of(title, content));
}
 
开发者ID:apache,项目名称:kylin,代码行数:40,代码来源:CubingJob.java

示例11: init

import org.apache.kylin.common.util.StringUtil; //导入依赖的package包/类
public void init(CubeDesc cubeDesc) {
    cubeRef = cubeDesc;

    for (HBaseColumnFamilyDesc cf : columnFamily) {
        cf.setName(cf.getName().toUpperCase());

        for (HBaseColumnDesc c : cf.getColumns()) {
            c.setQualifier(c.getQualifier().toUpperCase());
            StringUtil.toUpperCaseArray(c.getMeasureRefs(), c.getMeasureRefs());
        }
    }
}
 
开发者ID:apache,项目名称:kylin,代码行数:13,代码来源:HBaseMappingDesc.java

示例12: loadHiveTables

import org.apache.kylin.common.util.StringUtil; //导入依赖的package包/类
@RequestMapping(value = "/{tables}/{project}", method = { RequestMethod.POST }, produces = { "application/json" })
@ResponseBody
public Map<String, String[]> loadHiveTables(@PathVariable String tables, @PathVariable String project, @RequestBody HiveTableRequest request) throws IOException {
    String submitter = SecurityContextHolder.getContext().getAuthentication().getName();
    Map<String, String[]> result = new HashMap<String, String[]>();
    String[] tableNames = StringUtil.splitAndTrim(tables, ",");
    try {
        String[] loaded = tableService.loadHiveTablesToProject(tableNames, project);
        result.put("result.loaded", loaded);
        Set<String> allTables = new HashSet<String>();
        for (String tableName : tableNames) {
            allTables.add(tableService.normalizeHiveTableName(tableName));
        }
        for (String loadedTableName : loaded) {
            allTables.remove(loadedTableName);
        }
        String[] unloaded = new String[allTables.size()];
        allTables.toArray(unloaded);
        result.put("result.unloaded", unloaded);
        if (request.isCalculate()) {
            tableService.calculateCardinalityIfNotPresent(loaded, submitter, project);
        }
    } catch (Throwable e) {
        logger.error("Failed to load Hive Table", e);
        throw new InternalErrorException(e.getLocalizedMessage());
    }
    return result;
}
 
开发者ID:apache,项目名称:kylin,代码行数:29,代码来源:TableController.java

示例13: formatDateTimeInWhereClause

import org.apache.kylin.common.util.StringUtil; //导入依赖的package包/类
private static String formatDateTimeInWhereClause(long datetime) {
    SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    f.setTimeZone(TimeZone.getTimeZone("GMT"));
    Date date = new Date(datetime);
    String str = f.format(date);
    // note "2014-10-01" >= "2014-10-01 00:00:00" is FALSE
    return StringUtil.dropSuffix(str, " 00:00:00");
}
 
开发者ID:KylinOLAP,项目名称:Kylin,代码行数:9,代码来源:JoinedFlatTable.java

示例14: init

import org.apache.kylin.common.util.StringUtil; //导入依赖的package包/类
public void init(Map<String, TableDesc> tables) {
    if (name != null)
        name = name.toUpperCase();
    if (table != null)
        table = table.toUpperCase();
    if (column != null)
        column = column.toUpperCase();

    TableDesc tableDesc = tables.get(table);
    if (tableDesc == null)
        throw new IllegalStateException("Can't find table " + table + " on dimension " + name);

    if (hierarchy != null && hierarchy.length == 0)
        hierarchy = null;
    if (derived != null && derived.length == 0)
        derived = null;

    if (join != null) {
        StringUtil.toUpperCaseArray(join.getForeignKey(), join.getForeignKey());
        StringUtil.toUpperCaseArray(join.getPrimaryKey(), join.getPrimaryKey());
    }

    if (hierarchy != null) {
        for (HierarchyDesc h : hierarchy)
            h.setColumn(h.getColumn().toUpperCase());
    }

    if (derived != null) {
        StringUtil.toUpperCaseArray(derived, derived);
    }
}
 
开发者ID:KylinOLAP,项目名称:Kylin,代码行数:32,代码来源:DimensionDesc.java

示例15: main

import org.apache.kylin.common.util.StringUtil; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
    args = StringUtil.filterSystemArgs(args);

    if (args.length == 0) {
        System.out.println("Usage: MetadataTool reset METADATA_URI");
        System.out.println("Usage: MetadataTool copy  METADATA_URI_SRC  METADATA_URI_DST");
        System.out.println("Usage: MetadataTool list  METADATA_URI      PATH");
        return;
    }

    String exclude = System.getProperty("exclude");
    if (exclude != null) {
        excludes = exclude.split("\\s*,\\s*");
    }

    String cmd = args[0];
    switch (cmd) {
        case "reset":
            reset(args.length == 1 ? KylinConfig.getInstanceFromEnv() : KylinConfig.createInstanceFromUri(args[1]));
            break;
        case "copy":
            copy(args[1], args[2]);
            break;
        case "list":
            list(args[1], args[2]);
            break;
        case "download":
            copy(KylinConfig.getInstanceFromEnv(), KylinConfig.createInstanceFromUri(args[1]));
            break;
        case "upload":
            copy(KylinConfig.createInstanceFromUri(args[1]), KylinConfig.getInstanceFromEnv());
            break;
        case "remove":
            remove(KylinConfig.getInstanceFromEnv(), args[1]);
            break;
        default:
            System.out.println("Unknown cmd: " + cmd);
    }
}
 
开发者ID:KylinOLAP,项目名称:Kylin,代码行数:40,代码来源:ResourceTool.java


注:本文中的org.apache.kylin.common.util.StringUtil类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。