@Test public void testSupport() { assertTrue(index.supports(of(String.class, Cardinality.SINGLE))); assertTrue(index.supports(of(String.class, Cardinality.SINGLE, new Parameter("mapping", Mapping.TEXT)))); assertTrue(index.supports(of(String.class, Cardinality.SINGLE, new Parameter("mapping",Mapping.STRING)))); assertFalse(index.supports(of(String.class, Cardinality.SINGLE, new Parameter("mapping",Mapping.TEXTSTRING)))); assertTrue(index.supports(of(Double.class, Cardinality.SINGLE))); assertFalse(index.supports(of(Double.class, Cardinality.SINGLE, new Parameter("mapping",Mapping.TEXT)))); assertTrue(index.supports(of(Long.class, Cardinality.SINGLE))); assertTrue(index.supports(of(Long.class, Cardinality.SINGLE, new Parameter("mapping",Mapping.DEFAULT)))); assertTrue(index.supports(of(Integer.class, Cardinality.SINGLE))); assertTrue(index.supports(of(Short.class, Cardinality.SINGLE))); assertTrue(index.supports(of(Byte.class, Cardinality.SINGLE))); assertTrue(index.supports(of(Float.class, Cardinality.SINGLE))); assertFalse(index.supports(of(Object.class, Cardinality.SINGLE))); assertFalse(index.supports(of(Exception.class, Cardinality.SINGLE))); assertTrue(index.supports(of(String.class, Cardinality.SINGLE), Text.CONTAINS)); assertTrue(index.supports(of(String.class, Cardinality.SINGLE, new Parameter("mapping", Mapping.DEFAULT)), Text.CONTAINS_PREFIX)); assertTrue(index.supports(of(String.class, Cardinality.SINGLE, new Parameter("mapping", Mapping.TEXT)), Text.CONTAINS_REGEX)); assertTrue(index.supports(of(String.class, Cardinality.SINGLE, new Parameter("mapping", Mapping.TEXT)), Text.CONTAINS_FUZZY)); assertFalse(index.supports(of(String.class, Cardinality.SINGLE, new Parameter("mapping", Mapping.TEXTSTRING)), Text.REGEX)); assertTrue(index.supports(of(String.class, Cardinality.SINGLE, new Parameter("mapping",Mapping.TEXT)), Text.CONTAINS)); assertFalse(index.supports(of(String.class, Cardinality.SINGLE, new Parameter("mapping", Mapping.DEFAULT)), Text.PREFIX)); assertTrue(index.supports(of(String.class, Cardinality.SINGLE, new Parameter("mapping", Mapping.STRING)), Text.PREFIX)); assertTrue(index.supports(of(String.class, Cardinality.SINGLE, new Parameter("mapping", Mapping.STRING)), Text.REGEX)); assertTrue(index.supports(of(String.class, Cardinality.SINGLE, new Parameter("mapping", Mapping.STRING)), Text.FUZZY)); assertTrue(index.supports(of(String.class, Cardinality.SINGLE, new Parameter("mapping",Mapping.STRING)), Cmp.EQUAL)); assertTrue(index.supports(of(String.class, Cardinality.SINGLE, new Parameter("mapping",Mapping.STRING)), Cmp.NOT_EQUAL)); assertFalse(index.supports(of(String.class, Cardinality.SINGLE, new Parameter("mapping",Mapping.TEXTSTRING)), Cmp.NOT_EQUAL)); assertTrue(index.supports(of(Double.class, Cardinality.SINGLE), Cmp.EQUAL)); assertTrue(index.supports(of(Double.class, Cardinality.SINGLE), Cmp.GREATER_THAN_EQUAL)); assertTrue(index.supports(of(Double.class, Cardinality.SINGLE), Cmp.LESS_THAN)); assertTrue(index.supports(of(Double.class, Cardinality.SINGLE, new Parameter("mapping",Mapping.DEFAULT)), Cmp.LESS_THAN)); assertFalse(index.supports(of(Double.class, Cardinality.SINGLE, new Parameter("mapping",Mapping.TEXT)), Cmp.LESS_THAN)); assertTrue(index.supports(of(Geoshape.class, Cardinality.SINGLE))); assertTrue(index.supports(of(Geoshape.class, Cardinality.SINGLE), Geo.WITHIN)); assertTrue(index.supports(of(Geoshape.class, Cardinality.SINGLE), Geo.INTERSECT)); assertFalse(index.supports(of(Geoshape.class, Cardinality.SINGLE), Geo.CONTAINS)); assertFalse(index.supports(of(Geoshape.class, Cardinality.SINGLE), Geo.DISJOINT)); assertTrue(index.supports(of(Geoshape.class, Cardinality.SINGLE, new Parameter("mapping",Mapping.PREFIX_TREE)), Geo.CONTAINS)); assertTrue(index.supports(of(Geoshape.class, Cardinality.SINGLE, new Parameter("mapping",Mapping.PREFIX_TREE)), Geo.WITHIN)); assertTrue(index.supports(of(Geoshape.class, Cardinality.SINGLE, new Parameter("mapping",Mapping.PREFIX_TREE)), Geo.INTERSECT)); assertFalse(index.supports(of(Geoshape.class, Cardinality.SINGLE, new Parameter("mapping",Mapping.PREFIX_TREE)), Geo.DISJOINT)); assertFalse(index.supports(of(Double.class, Cardinality.SINGLE), Geo.INTERSECT)); assertFalse(index.supports(of(Long.class, Cardinality.SINGLE), Text.CONTAINS)); assertTrue(index.supports(of(Date.class, Cardinality.SINGLE), Cmp.EQUAL)); assertTrue(index.supports(of(Date.class, Cardinality.SINGLE), Cmp.LESS_THAN_EQUAL)); assertTrue(index.supports(of(Date.class, Cardinality.SINGLE), Cmp.LESS_THAN)); assertTrue(index.supports(of(Date.class, Cardinality.SINGLE), Cmp.GREATER_THAN)); assertTrue(index.supports(of(Date.class, Cardinality.SINGLE), Cmp.GREATER_THAN_EQUAL)); assertTrue(index.supports(of(Date.class, Cardinality.SINGLE), Cmp.NOT_EQUAL)); assertTrue(index.supports(of(Boolean.class, Cardinality.SINGLE), Cmp.EQUAL)); assertTrue(index.supports(of(Boolean.class, Cardinality.SINGLE), Cmp.NOT_EQUAL)); assertTrue(index.supports(of(UUID.class, Cardinality.SINGLE), Cmp.EQUAL)); assertTrue(index.supports(of(UUID.class, Cardinality.SINGLE), Cmp.NOT_EQUAL)); }
@Override public boolean supports(KeyInformation information, JanusGraphPredicate predicate) { final Class<?> dataType = information.getDataType(); final Mapping mapping = Mapping.getMapping(information); if (mapping!=Mapping.DEFAULT && !AttributeUtils.isString(dataType) && !(mapping==Mapping.PREFIX_TREE && AttributeUtils.isGeo(dataType))) return false; if (Number.class.isAssignableFrom(dataType)) { return predicate instanceof Cmp; } else if (dataType == Geoshape.class) { switch(mapping) { case DEFAULT: return predicate == Geo.WITHIN || predicate == Geo.INTERSECT; case PREFIX_TREE: return predicate == Geo.INTERSECT || predicate == Geo.WITHIN || predicate == Geo.CONTAINS; } } else if (AttributeUtils.isString(dataType)) { switch(mapping) { case DEFAULT: case TEXT: return predicate == Text.CONTAINS || predicate == Text.CONTAINS_PREFIX || predicate == Text.CONTAINS_REGEX || predicate == Text.CONTAINS_FUZZY; case STRING: return predicate instanceof Cmp || predicate==Text.REGEX || predicate==Text.PREFIX || predicate == Text.FUZZY; } } else if (dataType == Date.class || dataType == Instant.class) { return predicate instanceof Cmp; } else if (dataType == Boolean.class) { return predicate == Cmp.EQUAL || predicate == Cmp.NOT_EQUAL; } else if (dataType == UUID.class) { return predicate == Cmp.EQUAL || predicate==Cmp.NOT_EQUAL; } return false; }
SolrIndex implements IndexProvider { @Override public boolean supports(KeyInformation information, JanusGraphPredicate predicate) { final Class<?> dataType = information.getDataType(); final Mapping mapping = Mapping.getMapping(information); if (mapping!=Mapping.DEFAULT && !AttributeUtils.isString(dataType) && !(mapping==Mapping.PREFIX_TREE && AttributeUtils.isGeo(dataType))) return false; if (Number.class.isAssignableFrom(dataType)) { return predicate instanceof Cmp; } else if (dataType == Geoshape.class) { switch(mapping) { case DEFAULT: return predicate == Geo.WITHIN || predicate == Geo.INTERSECT; case PREFIX_TREE: return predicate == Geo.INTERSECT || predicate == Geo.WITHIN || predicate == Geo.CONTAINS; } } else if (AttributeUtils.isString(dataType)) { switch(mapping) { case DEFAULT: case TEXT: return predicate == Text.CONTAINS || predicate == Text.CONTAINS_PREFIX || predicate == Text.CONTAINS_REGEX || predicate == Text.CONTAINS_FUZZY; case STRING: return predicate instanceof Cmp || predicate==Text.REGEX || predicate==Text.PREFIX || predicate == Text.FUZZY; } } else if (dataType == Date.class || dataType == Instant.class) { return predicate instanceof Cmp; } else if (dataType == Boolean.class) { return predicate == Cmp.EQUAL || predicate == Cmp.NOT_EQUAL; } else if (dataType == UUID.class) { return predicate == Cmp.EQUAL || predicate==Cmp.NOT_EQUAL; } return false; } }
SolrIndex implements IndexProvider { @Override public boolean supports(KeyInformation information, JanusGraphPredicate predicate) { final Class<?> dataType = information.getDataType(); final Mapping mapping = Mapping.getMapping(information); if (mapping!=Mapping.DEFAULT && !AttributeUtils.isString(dataType) && !(mapping==Mapping.PREFIX_TREE && AttributeUtils.isGeo(dataType))) return false; if (Number.class.isAssignableFrom(dataType)) { return predicate instanceof Cmp; } else if (dataType == Geoshape.class) { switch(mapping) { case DEFAULT: return predicate == Geo.WITHIN || predicate == Geo.INTERSECT; case PREFIX_TREE: return predicate == Geo.INTERSECT || predicate == Geo.WITHIN || predicate == Geo.CONTAINS; } } else if (AttributeUtils.isString(dataType)) { switch(mapping) { case DEFAULT: case TEXT: return predicate == Text.CONTAINS || predicate == Text.CONTAINS_PREFIX || predicate == Text.CONTAINS_REGEX || predicate == Text.CONTAINS_FUZZY; case STRING: return predicate instanceof Cmp || predicate==Text.REGEX || predicate==Text.PREFIX || predicate == Text.FUZZY; } } else if (dataType == Date.class || dataType == Instant.class) { return predicate instanceof Cmp; } else if (dataType == Boolean.class) { return predicate == Cmp.EQUAL || predicate == Cmp.NOT_EQUAL; } else if (dataType == UUID.class) { return predicate == Cmp.EQUAL || predicate==Cmp.NOT_EQUAL; } return false; } SolrIndex(final Configuration config); }
SolrIndex implements IndexProvider { @Override public boolean supports(KeyInformation information, JanusGraphPredicate predicate) { final Class<?> dataType = information.getDataType(); final Mapping mapping = Mapping.getMapping(information); if (mapping!=Mapping.DEFAULT && !AttributeUtils.isString(dataType) && !(mapping==Mapping.PREFIX_TREE && AttributeUtils.isGeo(dataType))) return false; if (Number.class.isAssignableFrom(dataType)) { return predicate instanceof Cmp; } else if (dataType == Geoshape.class) { switch(mapping) { case DEFAULT: return predicate == Geo.WITHIN || predicate == Geo.INTERSECT; case PREFIX_TREE: return predicate == Geo.INTERSECT || predicate == Geo.WITHIN || predicate == Geo.CONTAINS; } } else if (AttributeUtils.isString(dataType)) { switch(mapping) { case DEFAULT: case TEXT: return predicate == Text.CONTAINS || predicate == Text.CONTAINS_PREFIX || predicate == Text.CONTAINS_REGEX || predicate == Text.CONTAINS_FUZZY; case STRING: return predicate instanceof Cmp || predicate==Text.REGEX || predicate==Text.PREFIX || predicate == Text.FUZZY; } } else if (dataType == Date.class || dataType == Instant.class) { return predicate instanceof Cmp; } else if (dataType == Boolean.class) { return predicate == Cmp.EQUAL || predicate == Cmp.NOT_EQUAL; } else if (dataType == UUID.class) { return predicate == Cmp.EQUAL || predicate==Cmp.NOT_EQUAL; } return false; } 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 boolean supports(KeyInformation information, JanusGraphPredicate predicate) { final Class<?> dataType = information.getDataType(); final Mapping mapping = Mapping.getMapping(information); if (mapping!=Mapping.DEFAULT && !AttributeUtils.isString(dataType) && !(mapping==Mapping.PREFIX_TREE && AttributeUtils.isGeo(dataType))) return false; if (Number.class.isAssignableFrom(dataType)) { return predicate instanceof Cmp; } else if (dataType == Geoshape.class) { switch(mapping) { case DEFAULT: return predicate == Geo.WITHIN || predicate == Geo.INTERSECT; case PREFIX_TREE: return predicate == Geo.INTERSECT || predicate == Geo.WITHIN || predicate == Geo.CONTAINS; } } else if (AttributeUtils.isString(dataType)) { switch(mapping) { case DEFAULT: case TEXT: return predicate == Text.CONTAINS || predicate == Text.CONTAINS_PREFIX || predicate == Text.CONTAINS_REGEX || predicate == Text.CONTAINS_FUZZY; case STRING: return predicate instanceof Cmp || predicate==Text.REGEX || predicate==Text.PREFIX || predicate == Text.FUZZY; } } else if (dataType == Date.class || dataType == Instant.class) { return predicate instanceof Cmp; } else if (dataType == Boolean.class) { return predicate == Cmp.EQUAL || predicate == Cmp.NOT_EQUAL; } else if (dataType == UUID.class) { return predicate == Cmp.EQUAL || predicate==Cmp.NOT_EQUAL; } return false; } 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; }