if (tableContext != null) {
return tableContext;
}
LOG.info("Creating table context for table [{0}]", name);
Configuration configuration = getSystemConfiguration();
BlurConfiguration blurConfiguration = getSystemBlurConfiguration();
Map<String, String> tableProperties = tableDescriptor.getTableProperties();
if (tableProperties != null) {
for (Entry<String, String> prop : tableProperties.entrySet()) {
configuration.set(prop.getKey(), prop.getValue());
blurConfiguration.set(prop.getKey(), prop.getValue());
}
}
tableContext = new TableContext();
tableContext._configuration = configuration;
tableContext._blurConfiguration = blurConfiguration;
tableContext._tablePath = new Path(tableUri);
tableContext._walTablePath = new Path(tableContext._tablePath, LOGS);
tableContext._defaultFieldName = SUPER;
tableContext._table = name;
tableContext._descriptor = tableDescriptor;
tableContext._timeBetweenCommits = configuration.getLong(BLUR_SHARD_TIME_BETWEEN_COMMITS, 60000);
tableContext._timeBetweenRefreshs = configuration.getLong(BLUR_SHARD_TIME_BETWEEN_REFRESHS, 5000);
tableContext._defaultPrimeDocTerm = new Term(BlurConstants.PRIME_DOC, BlurConstants.PRIME_DOC_VALUE);
tableContext._defaultScoreType = ScoreType.SUPER;
boolean strict = tableDescriptor.isStrictTypes();
String defaultMissingFieldType = tableDescriptor.getDefaultMissingFieldType();
boolean defaultMissingFieldLessIndexing = tableDescriptor.isDefaultMissingFieldLessIndexing();
Map<String, String> defaultMissingFieldProps = emptyIfNull(tableDescriptor.getDefaultMissingFieldProps());
Path storagePath = new Path(tableContext._tablePath, TYPES);
try {
HdfsFieldManager hdfsFieldManager = new HdfsFieldManager(SUPER, new NoStopWordStandardAnalyzer(), storagePath,
configuration, strict, defaultMissingFieldType, defaultMissingFieldLessIndexing, defaultMissingFieldProps);
loadCustomTypes(tableContext, blurConfiguration, hdfsFieldManager);
hdfsFieldManager.loadFromStorage();
tableContext._fieldManager = hdfsFieldManager;
} catch (IOException e) {
throw new RuntimeException(e);
}
Class<?> c1 = configuration.getClass(BLUR_SHARD_INDEX_DELETION_POLICY_MAXAGE,
KeepOnlyLastCommitDeletionPolicy.class);
tableContext._indexDeletionPolicy = (IndexDeletionPolicy) configure(ReflectionUtils.newInstance(c1, configuration),
tableContext);
Class<?> c2 = configuration.getClass(BLUR_SHARD_INDEX_SIMILARITY, FairSimilarity.class);
tableContext._similarity = (Similarity) configure(ReflectionUtils.newInstance(c2, configuration), tableContext);
String readInterceptorClass = blurConfiguration.get(BLUR_SHARD_READ_INTERCEPTOR);
if (readInterceptorClass == null || readInterceptorClass.trim().isEmpty()) {
tableContext._readInterceptor = DEFAULT_INTERCEPTOR;
} else {
try {
@SuppressWarnings("unchecked")