@Test public void testSupport() { assertTrue( index.supports(of(String.class, Cardinality.SINGLE), Text.CONTAINS)); assertTrue( index.supports(of(String.class, Cardinality.SINGLE), Text.CONTAINS_PREFIX)); assertFalse(index.supports(of(String.class, Cardinality.SINGLE), Text.CONTAINS_REGEX)); assertFalse(index.supports(of(String.class, Cardinality.SINGLE), Text.REGEX)); assertFalse(index.supports(of(String.class, Cardinality.SINGLE), Text.PREFIX)); assertFalse(index.supports(of(String.class, Cardinality.SINGLE), Cmp.EQUAL)); assertFalse(index.supports(of(String.class, Cardinality.SINGLE), Cmp.NOT_EQUAL)); assertTrue(index.supports(of(String.class, Cardinality.SINGLE, new Parameter<>(MAPPING, Mapping.TEXT)), Text.CONTAINS)); assertTrue(index.supports(of(String.class, Cardinality.SINGLE, new Parameter<>(MAPPING, Mapping.TEXT)), Text.CONTAINS_PREFIX)); 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.TEXT)), Text.CONTAINS_REGEX)); assertFalse(index.supports(of(String.class, Cardinality.SINGLE, new Parameter<>(MAPPING, Mapping.TEXT)), Text.REGEX)); assertFalse(index.supports(of(String.class, Cardinality.SINGLE, new Parameter<>(MAPPING, Mapping.TEXT)), Text.PREFIX)); assertFalse(index.supports(of(String.class, Cardinality.SINGLE, new Parameter<>(MAPPING, Mapping.TEXT)), Cmp.EQUAL)); assertFalse(index.supports(of(String.class, Cardinality.SINGLE, new Parameter<>(MAPPING, Mapping.TEXT)), Cmp.NOT_EQUAL)); assertFalse(index.supports(of(String.class, Cardinality.SINGLE, new Parameter<>(MAPPING, Mapping.STRING)), Text.CONTAINS)); assertFalse(index.supports(of(String.class, Cardinality.SINGLE, new Parameter<>(MAPPING, Mapping.STRING)), Text.CONTAINS_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.PREFIX)); 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)); 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)); 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.DISJOINT)); 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.CONTAINS)); 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)); }
@Override public boolean supports(KeyInformation information, JanusGraphPredicate janusgraphPredicate) { 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 janusgraphPredicate instanceof Cmp; } else if (dataType == Geoshape.class) { if (information.getCardinality() != Cardinality.SINGLE) return false; return janusgraphPredicate == Geo.INTERSECT || janusgraphPredicate == Geo.WITHIN || janusgraphPredicate == Geo.CONTAINS; } else if (AttributeUtils.isString(dataType)) { switch (mapping) { case DEFAULT: case TEXT: return janusgraphPredicate == Text.CONTAINS || janusgraphPredicate == Text.CONTAINS_PREFIX || janusgraphPredicate == Text.CONTAINS_FUZZY; case STRING: return janusgraphPredicate instanceof Cmp || janusgraphPredicate == Text.PREFIX || janusgraphPredicate == Text.REGEX || janusgraphPredicate == Text.FUZZY; case TEXTSTRING: return janusgraphPredicate instanceof Text || janusgraphPredicate instanceof Cmp; } } else if (dataType == Date.class || dataType == Instant.class) { return janusgraphPredicate instanceof Cmp; } else if (dataType == Boolean.class) { return janusgraphPredicate == Cmp.EQUAL || janusgraphPredicate == Cmp.NOT_EQUAL; } else if (dataType == UUID.class) { return janusgraphPredicate == Cmp.EQUAL || janusgraphPredicate == Cmp.NOT_EQUAL; } return false; }
LuceneIndex implements IndexProvider { @Override public boolean supports(KeyInformation information, JanusGraphPredicate janusgraphPredicate) { 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 janusgraphPredicate instanceof Cmp; } else if (dataType == Geoshape.class) { if (information.getCardinality() != Cardinality.SINGLE) return false; return janusgraphPredicate == Geo.INTERSECT || janusgraphPredicate == Geo.WITHIN || janusgraphPredicate == Geo.CONTAINS; } else if (AttributeUtils.isString(dataType)) { switch (mapping) { case DEFAULT: case TEXT: return janusgraphPredicate == Text.CONTAINS || janusgraphPredicate == Text.CONTAINS_PREFIX || janusgraphPredicate == Text.CONTAINS_FUZZY; case STRING: return janusgraphPredicate instanceof Cmp || janusgraphPredicate == Text.PREFIX || janusgraphPredicate == Text.REGEX || janusgraphPredicate == Text.FUZZY; case TEXTSTRING: return janusgraphPredicate instanceof Text || janusgraphPredicate instanceof Cmp; } } else if (dataType == Date.class || dataType == Instant.class) { return janusgraphPredicate instanceof Cmp; } else if (dataType == Boolean.class) { return janusgraphPredicate == Cmp.EQUAL || janusgraphPredicate == Cmp.NOT_EQUAL; } else if (dataType == UUID.class) { return janusgraphPredicate == Cmp.EQUAL || janusgraphPredicate == Cmp.NOT_EQUAL; } return false; } }
LuceneIndex implements IndexProvider { @Override public boolean supports(KeyInformation information, JanusGraphPredicate janusgraphPredicate) { 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 janusgraphPredicate instanceof Cmp; } else if (dataType == Geoshape.class) { if (information.getCardinality() != Cardinality.SINGLE) return false; return janusgraphPredicate == Geo.INTERSECT || janusgraphPredicate == Geo.WITHIN || janusgraphPredicate == Geo.CONTAINS; } else if (AttributeUtils.isString(dataType)) { switch (mapping) { case DEFAULT: case TEXT: return janusgraphPredicate == Text.CONTAINS || janusgraphPredicate == Text.CONTAINS_PREFIX || janusgraphPredicate == Text.CONTAINS_FUZZY; case STRING: return janusgraphPredicate instanceof Cmp || janusgraphPredicate == Text.PREFIX || janusgraphPredicate == Text.REGEX || janusgraphPredicate == Text.FUZZY; case TEXTSTRING: return janusgraphPredicate instanceof Text || janusgraphPredicate instanceof Cmp; } } else if (dataType == Date.class || dataType == Instant.class) { return janusgraphPredicate instanceof Cmp; } else if (dataType == Boolean.class) { return janusgraphPredicate == Cmp.EQUAL || janusgraphPredicate == Cmp.NOT_EQUAL; } else if (dataType == UUID.class) { return janusgraphPredicate == Cmp.EQUAL || janusgraphPredicate == Cmp.NOT_EQUAL; } return false; } LuceneIndex(Configuration config); }
LuceneIndex implements IndexProvider { @Override public boolean supports(KeyInformation information, JanusGraphPredicate janusgraphPredicate) { 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 janusgraphPredicate instanceof Cmp; } else if (dataType == Geoshape.class) { if (information.getCardinality() != Cardinality.SINGLE) return false; return janusgraphPredicate == Geo.INTERSECT || janusgraphPredicate == Geo.WITHIN || janusgraphPredicate == Geo.CONTAINS; } else if (AttributeUtils.isString(dataType)) { switch (mapping) { case DEFAULT: case TEXT: return janusgraphPredicate == Text.CONTAINS || janusgraphPredicate == Text.CONTAINS_PREFIX || janusgraphPredicate == Text.CONTAINS_FUZZY; case STRING: return janusgraphPredicate instanceof Cmp || janusgraphPredicate == Text.PREFIX || janusgraphPredicate == Text.REGEX || janusgraphPredicate == Text.FUZZY; case TEXTSTRING: return janusgraphPredicate instanceof Text || janusgraphPredicate instanceof Cmp; } } else if (dataType == Date.class || dataType == Instant.class) { return janusgraphPredicate instanceof Cmp; } else if (dataType == Boolean.class) { return janusgraphPredicate == Cmp.EQUAL || janusgraphPredicate == Cmp.NOT_EQUAL; } else if (dataType == UUID.class) { return janusgraphPredicate == Cmp.EQUAL || janusgraphPredicate == Cmp.NOT_EQUAL; } return false; } LuceneIndex(Configuration config); @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); @Override BaseTransactionConfigurable beginTransaction(BaseTransactionConfig config); @Override boolean supports(KeyInformation information, JanusGraphPredicate janusgraphPredicate); @Override boolean supports(KeyInformation information); @Override String mapKey2Field(String key, KeyInformation information); @Override IndexFeatures getFeatures(); @Override void close(); @Override void clearStorage(); @Override boolean exists(); }
LuceneIndex implements IndexProvider { @Override public boolean supports(KeyInformation information, JanusGraphPredicate janusgraphPredicate) { 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 janusgraphPredicate instanceof Cmp; } else if (dataType == Geoshape.class) { if (information.getCardinality() != Cardinality.SINGLE) return false; return janusgraphPredicate == Geo.INTERSECT || janusgraphPredicate == Geo.WITHIN || janusgraphPredicate == Geo.CONTAINS; } else if (AttributeUtils.isString(dataType)) { switch (mapping) { case DEFAULT: case TEXT: return janusgraphPredicate == Text.CONTAINS || janusgraphPredicate == Text.CONTAINS_PREFIX || janusgraphPredicate == Text.CONTAINS_FUZZY; case STRING: return janusgraphPredicate instanceof Cmp || janusgraphPredicate == Text.PREFIX || janusgraphPredicate == Text.REGEX || janusgraphPredicate == Text.FUZZY; case TEXTSTRING: return janusgraphPredicate instanceof Text || janusgraphPredicate instanceof Cmp; } } else if (dataType == Date.class || dataType == Instant.class) { return janusgraphPredicate instanceof Cmp; } else if (dataType == Boolean.class) { return janusgraphPredicate == Cmp.EQUAL || janusgraphPredicate == Cmp.NOT_EQUAL; } else if (dataType == UUID.class) { return janusgraphPredicate == Cmp.EQUAL || janusgraphPredicate == Cmp.NOT_EQUAL; } return false; } LuceneIndex(Configuration config); @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); @Override BaseTransactionConfigurable beginTransaction(BaseTransactionConfig config); @Override boolean supports(KeyInformation information, JanusGraphPredicate janusgraphPredicate); @Override boolean supports(KeyInformation information); @Override String mapKey2Field(String key, KeyInformation information); @Override IndexFeatures getFeatures(); @Override void close(); @Override void clearStorage(); @Override boolean exists(); static final int DEFAULT_GEO_MAX_LEVELS; static final double DEFAULT_GEO_DIST_ERROR_PCT; }