@Test public void testMapKey2Field_IllegalCharacter() { assertThrows(IllegalArgumentException.class, () -> { KeyInformation keyInfo = new StandardKeyInformation(Boolean.class, Cardinality.SINGLE); index.mapKey2Field("here is an illegal character: •", keyInfo); }); }
@Override public String mapKey2Field(String key, KeyInformation keyInfo) { IndexProvider.checkKeyValidity(key); key = key.replace(' ', REPLACEMENT_CHAR); if (!dynFields) return key; if (ParameterType.MAPPED_NAME.hasParameter(keyInfo.getParameters())) return key; String postfix; final Class dataType = keyInfo.getDataType(); if (AttributeUtils.isString(dataType)) { final Mapping map = getStringMapping(keyInfo); switch (map) { case TEXT: postfix = "_t"; break; case STRING: postfix = "_s"; break; default: throw new IllegalArgumentException("Unsupported string mapping: " + map); } } else if (AttributeUtils.isWholeNumber(dataType)) { if (dataType.equals(Long.class)) postfix = "_l"; else postfix = "_i"; } else if (AttributeUtils.isDecimal(dataType)) { if (dataType.equals(Float.class)) postfix = "_f"; else postfix = "_d"; } else if (dataType.equals(Geoshape.class)) { postfix = "_g"; } else if (dataType.equals(Date.class) || dataType.equals(Instant.class)) { postfix = "_dt"; } else if (dataType.equals(Boolean.class)) { postfix = "_b"; } else if (dataType.equals(UUID.class)) { postfix = "_uuid"; } else throw new IllegalArgumentException("Unsupported data type ["+dataType+"] for field: " + key); if (keyInfo.getCardinality() == Cardinality.SET || keyInfo.getCardinality() == Cardinality.LIST) { postfix += "s"; } return key+postfix; }
SolrIndex implements IndexProvider { @Override public String mapKey2Field(String key, KeyInformation keyInfo) { IndexProvider.checkKeyValidity(key); key = key.replace(' ', REPLACEMENT_CHAR); if (!dynFields) return key; if (ParameterType.MAPPED_NAME.hasParameter(keyInfo.getParameters())) return key; String postfix; final Class dataType = keyInfo.getDataType(); if (AttributeUtils.isString(dataType)) { final Mapping map = getStringMapping(keyInfo); switch (map) { case TEXT: postfix = "_t"; break; case STRING: postfix = "_s"; break; default: throw new IllegalArgumentException("Unsupported string mapping: " + map); } } else if (AttributeUtils.isWholeNumber(dataType)) { if (dataType.equals(Long.class)) postfix = "_l"; else postfix = "_i"; } else if (AttributeUtils.isDecimal(dataType)) { if (dataType.equals(Float.class)) postfix = "_f"; else postfix = "_d"; } else if (dataType.equals(Geoshape.class)) { postfix = "_g"; } else if (dataType.equals(Date.class) || dataType.equals(Instant.class)) { postfix = "_dt"; } else if (dataType.equals(Boolean.class)) { postfix = "_b"; } else if (dataType.equals(UUID.class)) { postfix = "_uuid"; } else throw new IllegalArgumentException("Unsupported data type ["+dataType+"] for field: " + key); if (keyInfo.getCardinality() == Cardinality.SET || keyInfo.getCardinality() == Cardinality.LIST) { postfix += "s"; } return key+postfix; } }
SolrIndex implements IndexProvider { @Override public String mapKey2Field(String key, KeyInformation keyInfo) { IndexProvider.checkKeyValidity(key); key = key.replace(' ', REPLACEMENT_CHAR); if (!dynFields) return key; if (ParameterType.MAPPED_NAME.hasParameter(keyInfo.getParameters())) return key; String postfix; final Class dataType = keyInfo.getDataType(); if (AttributeUtils.isString(dataType)) { final Mapping map = getStringMapping(keyInfo); switch (map) { case TEXT: postfix = "_t"; break; case STRING: postfix = "_s"; break; default: throw new IllegalArgumentException("Unsupported string mapping: " + map); } } else if (AttributeUtils.isWholeNumber(dataType)) { if (dataType.equals(Long.class)) postfix = "_l"; else postfix = "_i"; } else if (AttributeUtils.isDecimal(dataType)) { if (dataType.equals(Float.class)) postfix = "_f"; else postfix = "_d"; } else if (dataType.equals(Geoshape.class)) { postfix = "_g"; } else if (dataType.equals(Date.class) || dataType.equals(Instant.class)) { postfix = "_dt"; } else if (dataType.equals(Boolean.class)) { postfix = "_b"; } else if (dataType.equals(UUID.class)) { postfix = "_uuid"; } else throw new IllegalArgumentException("Unsupported data type ["+dataType+"] for field: " + key); if (keyInfo.getCardinality() == Cardinality.SET || keyInfo.getCardinality() == Cardinality.LIST) { postfix += "s"; } return key+postfix; } SolrIndex(final Configuration config); }
SolrIndex implements IndexProvider { @Override public String mapKey2Field(String key, KeyInformation keyInfo) { IndexProvider.checkKeyValidity(key); key = key.replace(' ', REPLACEMENT_CHAR); if (!dynFields) return key; if (ParameterType.MAPPED_NAME.hasParameter(keyInfo.getParameters())) return key; String postfix; final Class dataType = keyInfo.getDataType(); if (AttributeUtils.isString(dataType)) { final Mapping map = getStringMapping(keyInfo); switch (map) { case TEXT: postfix = "_t"; break; case STRING: postfix = "_s"; break; default: throw new IllegalArgumentException("Unsupported string mapping: " + map); } } else if (AttributeUtils.isWholeNumber(dataType)) { if (dataType.equals(Long.class)) postfix = "_l"; else postfix = "_i"; } else if (AttributeUtils.isDecimal(dataType)) { if (dataType.equals(Float.class)) postfix = "_f"; else postfix = "_d"; } else if (dataType.equals(Geoshape.class)) { postfix = "_g"; } else if (dataType.equals(Date.class) || dataType.equals(Instant.class)) { postfix = "_dt"; } else if (dataType.equals(Boolean.class)) { postfix = "_b"; } else if (dataType.equals(UUID.class)) { postfix = "_uuid"; } else throw new IllegalArgumentException("Unsupported data type ["+dataType+"] for field: " + key); if (keyInfo.getCardinality() == Cardinality.SET || keyInfo.getCardinality() == Cardinality.LIST) { postfix += "s"; } return key+postfix; } SolrIndex(final Configuration config); @SuppressWarnings("unchecked") @Override void register(String store, String key, KeyInformation information, BaseTransaction tx); @Override void mutate(Map<String, Map<String, IndexMutation>> mutations, KeyInformation.IndexRetriever information,
                       BaseTransaction tx); @Override void restore(Map<String, Map<String, List<IndexEntry>>> documents,
                        KeyInformation.IndexRetriever information, BaseTransaction tx); @Override Stream<String> query(IndexQuery query, KeyInformation.IndexRetriever information,
                                BaseTransaction tx); @Override Stream<RawQuery.Result<String>> query(RawQuery query, KeyInformation.IndexRetriever information,
                                                 BaseTransaction tx); @Override Long totals(RawQuery query, KeyInformation.IndexRetriever information,
                       BaseTransaction tx); String buildQueryFilter(Condition<JanusGraphElement> condition, KeyInformation.StoreRetriever information); @Override BaseTransactionConfigurable beginTransaction(BaseTransactionConfig config); @Override void close(); @Override void clearStorage(); @Override boolean supports(KeyInformation information, JanusGraphPredicate predicate); @Override boolean supports(KeyInformation information); @Override String mapKey2Field(String key, KeyInformation keyInfo); @Override IndexFeatures getFeatures(); @Override boolean exists(); }
SolrIndex implements IndexProvider { @Override public String mapKey2Field(String key, KeyInformation keyInfo) { IndexProvider.checkKeyValidity(key); key = key.replace(' ', REPLACEMENT_CHAR); if (!dynFields) return key; if (ParameterType.MAPPED_NAME.hasParameter(keyInfo.getParameters())) return key; String postfix; final Class dataType = keyInfo.getDataType(); if (AttributeUtils.isString(dataType)) { final Mapping map = getStringMapping(keyInfo); switch (map) { case TEXT: postfix = "_t"; break; case STRING: postfix = "_s"; break; default: throw new IllegalArgumentException("Unsupported string mapping: " + map); } } else if (AttributeUtils.isWholeNumber(dataType)) { if (dataType.equals(Long.class)) postfix = "_l"; else postfix = "_i"; } else if (AttributeUtils.isDecimal(dataType)) { if (dataType.equals(Float.class)) postfix = "_f"; else postfix = "_d"; } else if (dataType.equals(Geoshape.class)) { postfix = "_g"; } else if (dataType.equals(Date.class) || dataType.equals(Instant.class)) { postfix = "_dt"; } else if (dataType.equals(Boolean.class)) { postfix = "_b"; } else if (dataType.equals(UUID.class)) { postfix = "_uuid"; } else throw new IllegalArgumentException("Unsupported data type ["+dataType+"] for field: " + key); if (keyInfo.getCardinality() == Cardinality.SET || keyInfo.getCardinality() == Cardinality.LIST) { postfix += "s"; } return key+postfix; } SolrIndex(final Configuration config); @SuppressWarnings("unchecked") @Override void register(String store, String key, KeyInformation information, BaseTransaction tx); @Override void mutate(Map<String, Map<String, IndexMutation>> mutations, KeyInformation.IndexRetriever information,
                       BaseTransaction tx); @Override void restore(Map<String, Map<String, List<IndexEntry>>> documents,
                        KeyInformation.IndexRetriever information, BaseTransaction tx); @Override Stream<String> query(IndexQuery query, KeyInformation.IndexRetriever information,
                                BaseTransaction tx); @Override Stream<RawQuery.Result<String>> query(RawQuery query, KeyInformation.IndexRetriever information,
                                                 BaseTransaction tx); @Override Long totals(RawQuery query, KeyInformation.IndexRetriever information,
                       BaseTransaction tx); String buildQueryFilter(Condition<JanusGraphElement> condition, KeyInformation.StoreRetriever information); @Override BaseTransactionConfigurable beginTransaction(BaseTransactionConfig config); @Override void close(); @Override void clearStorage(); @Override boolean supports(KeyInformation information, JanusGraphPredicate predicate); @Override boolean supports(KeyInformation information); @Override String mapKey2Field(String key, KeyInformation keyInfo); @Override IndexFeatures getFeatures(); @Override boolean exists(); static final ConfigNamespace SOLR_NS; static final ConfigOption<String> SOLR_MODE; static final ConfigOption<Boolean> DYNAMIC_FIELDS; static final ConfigOption<String[]> KEY_FIELD_NAMES; static final ConfigOption<String> TTL_FIELD; static final ConfigOption<String[]> ZOOKEEPER_URL; static final ConfigOption<Integer> NUM_SHARDS; static final ConfigOption<Integer> MAX_SHARDS_PER_NODE; static final ConfigOption<Integer> REPLICATION_FACTOR; static final ConfigOption<String> SOLR_DEFAULT_CONFIG; static final ConfigOption<String[]> HTTP_URLS; static final ConfigOption<Integer> HTTP_CONNECTION_TIMEOUT; static final ConfigOption<Boolean> HTTP_ALLOW_COMPRESSION; static final ConfigOption<Integer> HTTP_MAX_CONNECTIONS_PER_HOST; static final ConfigOption<Integer> HTTP_GLOBAL_MAX_CONNECTIONS; static final ConfigOption<Boolean> WAIT_SEARCHER; static final ConfigOption<Boolean> KERBEROS_ENABLED; }