private String[] splitKey(String fspKey) {
    if (!fspKey.isEmpty() && isSkewedStoredAsSubDirectories) {
      for (String dir : lbCtx.getSkewedValuesDirNames()) {
        int index = fspKey.indexOf(dir);
        if (index >= 0) {
          return new String[] {fspKey.substring(0, index), fspKey.substring(index + 1)};
        }
      }
    }
    return new String[] {fspKey, null};
  }
This is server side code to create key in order to save statistics to stats database.
Client side will read it via StatsTask.java aggregateStats().
Client side reads it via db query prefix which is based on partition spec.
Since store-as-subdir information is not part of partition spec, we have to
remove store-as-subdir information from variable "keyPrefix" calculation.
But we have to keep store-as-subdir information in variable "key" calculation
since each skewed value has a row in stats db and "key" is db key,
otherwise later value overwrites previous value.
Performance impact due to string handling is minimum since this method is
only called once in FileSinkOperator closeOp().
For example,
create table test skewed by (key, value) on (('484','val_484') stored as DIRECTORIES;
skewedValueDirList contains 2 elements:
1. key=484/value=val_484
2. HIVE_LIST_BUCKETING_DEFAULT_DIR_NAME/HIVE_LIST_BUCKETING_DEFAULT_DIR_NAME
Case #1: Static partition with store-as-sub-dir
spSpec has SP path
fspKey has either
key=484/value=val_484 or
HIVE_LIST_BUCKETING_DEFAULT_DIR_NAME/HIVE_LIST_BUCKETING_DEFAULT_DIR_NAME
After filter, fspKey is empty, storedAsDirPostFix has either
key=484/value=val_484 or
HIVE_LIST_BUCKETING_DEFAULT_DIR_NAME/HIVE_LIST_BUCKETING_DEFAULT_DIR_NAME
so, at the end, "keyPrefix" doesnt have subdir information but "key" has
Case #2: Dynamic partition with store-as-sub-dir. Assume dp part is hr
spSpec has SP path
fspKey has either
hr=11/key=484/value=val_484 or
hr=11/HIVE_LIST_BUCKETING_DEFAULT_DIR_NAME/HIVE_LIST_BUCKETING_DEFAULT_DIR_NAME
After filter, fspKey is hr=11, storedAsDirPostFix has either
key=484/value=val_484 or
HIVE_LIST_BUCKETING_DEFAULT_DIR_NAME/HIVE_LIST_BUCKETING_DEFAULT_DIR_NAME
so, at the end, "keyPrefix" doesn't have subdir information from skewed but "key" has

In a word, fspKey is consists of DP(dynamic partition spec) + LB(list bucketing spec)
In stats publishing, full partition spec consists of prefix part of stat key
but list bucketing spec is regarded as a postfix of stat key. So we split it here.
ql/src/java/org/apache/hadoop/hive/ql/exec/FileSinkOperator.java