Search in sources :

Example 1 with CaseInsensitiveString

use of org.openntf.domino.types.CaseInsensitiveString in project org.openntf.domino by OpenNTF.

the class DocumentScanner method processValue.

public void processValue(final CaseInsensitiveString name, final Object value, final String address) {
    if (value instanceof CharSequence) {
        String chkVal = value.toString();
        if (DominoUtils.isUnid(chkVal) || DominoUtils.isReplicaId(chkVal) || DominoUtils.isMetaversalId(chkVal) || DominoUtils.isNumber(chkVal)) {
            // System.out.println("TEMP DEBUG skipping processing on value of '" + chkVal + "'");
            return;
        }
    }
    if (value instanceof String) {
        String val = (String) value;
        Scanner s = new Scanner(val);
        s.useDelimiter(REGEX_NONALPHANUMERIC);
        while (s.hasNext()) {
            CharSequence token = scrubToken(s.next(), caseSensitive_);
            if (token != null && (token.length() > 2) && !isStopped(token)) {
                tokenCount_++;
                processToken(token, name, address);
            }
        }
        s.close();
    }
    if (isTrackFieldValues()) {
        Map<CharSequence, NavigableSet<Comparable>> vmap = getFieldValueMap();
        NavigableSet<Comparable> valueSet = null;
        if (!vmap.containsKey(name)) {
            valueSet = new ConcurrentSkipListSet<Comparable>();
            vmap.put(name, valueSet);
        } else {
            valueSet = vmap.get(name);
        }
        Comparable c = TypeUtils.toComparable(value);
        if (c != null) {
            valueSet.add(c);
        }
    }
    if (isTrackValueLocation()) {
        Map<CharSequence, Set<CharSequence>> tlval = getValueLocationMap(String.valueOf(value));
        if (tlval.containsKey(name)) {
            Set<CharSequence> tllist = tlval.get(name);
            tllist.add(address);
        } else {
            Set<CharSequence> tllist = new ConcurrentSkipListSet<CharSequence>();
            tllist.add(address);
            tlval.put(name, tllist);
        }
    }
}
Also used : Scanner(java.util.Scanner) NavigableSet(java.util.NavigableSet) HashSet(java.util.HashSet) Set(java.util.Set) NavigableSet(java.util.NavigableSet) ConcurrentSkipListSet(java.util.concurrent.ConcurrentSkipListSet) ConcurrentSkipListSet(java.util.concurrent.ConcurrentSkipListSet) CaseInsensitiveString(org.openntf.domino.types.CaseInsensitiveString)

Example 2 with CaseInsensitiveString

use of org.openntf.domino.types.CaseInsensitiveString in project org.openntf.domino by OpenNTF.

the class DocumentScanner method processName.

protected void processName(final CharSequence name, final CharSequence itemName, final Session session, final String address) {
    Map<CharSequence, Integer> tfmap = getTokenFreqMap();
    Map<CharSequence, NavigableSet<CharSequence>> tmap = getFieldTokenMap();
    NavigableSet<CharSequence> tokenSet = null;
    if (!tmap.containsKey(itemName)) {
        tokenSet = new ConcurrentSkipListSet<CharSequence>();
        tmap.put(itemName, tokenSet);
    } else {
        tokenSet = tmap.get(itemName);
    }
    tokenSet.add(name);
    if (DominoUtils.isHierarchicalName(name.toString())) {
        CharSequence cn = caseSensitive_ ? DominoUtils.toCommonName(name.toString()) : new CaseInsensitiveString(DominoUtils.toCommonName(name.toString()));
        tokenSet.add(cn);
        if (tfmap.containsKey(cn)) {
            tfmap.put(cn, tfmap.get(cn) + 1);
        } else {
            tfmap.put(cn, 1);
        }
        if (isTrackNameLocation()) {
            Map<CharSequence, Set<CharSequence>> tlval = getNameLocationMap(name.toString());
            if (tlval.containsKey(itemName)) {
                Set<CharSequence> tllist = tlval.get(itemName);
                tllist.add(address);
            } else {
                Set<CharSequence> tllist = new ConcurrentSkipListSet<CharSequence>();
                tllist.add(address);
                tlval.put(itemName, tllist);
            }
        }
    } else {
        CharSequence lname = caseSensitive_ ? name : new CaseInsensitiveString(name);
        if (tfmap.containsKey(lname)) {
            tfmap.put(lname, tfmap.get(lname) + 1);
        } else {
            tfmap.put(lname, 1);
        }
    }
    if (this.isSplitNameTokens()) {
        if (name instanceof String) {
            String val = (String) name;
            try (Scanner s = new Scanner(val)) {
                s.useDelimiter(REGEX_NONALPHANUMERIC);
                while (s.hasNext()) {
                    CharSequence token = scrubToken(s.next(), caseSensitive_);
                    if (token != null && (token.length() > 2) && !isStopped(token)) {
                        tokenCount_++;
                        processToken(token, itemName, address);
                    }
                }
            }
        }
    }
    if (isTrackFieldValues()) {
        Map<CharSequence, NavigableSet<Comparable>> vmap = getFieldValueMap();
        NavigableSet<Comparable> valueSet = null;
        if (!vmap.containsKey(name)) {
            valueSet = new ConcurrentSkipListSet<Comparable>();
            vmap.put(name, valueSet);
        } else {
            valueSet = vmap.get(name);
        }
        valueSet.add(name.toString());
    }
}
Also used : Scanner(java.util.Scanner) NavigableSet(java.util.NavigableSet) HashSet(java.util.HashSet) Set(java.util.Set) NavigableSet(java.util.NavigableSet) ConcurrentSkipListSet(java.util.concurrent.ConcurrentSkipListSet) ConcurrentSkipListSet(java.util.concurrent.ConcurrentSkipListSet) CaseInsensitiveString(org.openntf.domino.types.CaseInsensitiveString) CaseInsensitiveString(org.openntf.domino.types.CaseInsensitiveString)

Example 3 with CaseInsensitiveString

use of org.openntf.domino.types.CaseInsensitiveString in project org.openntf.domino by OpenNTF.

the class DocumentScanner method scrubToken.

public static CharSequence scrubToken(final String token, final boolean caseSensitive) {
    // Matcher puncMatch = REGEX_PUNCTUATION.matcher(token);
    // String result = puncMatch.replaceAll("");
    Matcher pMatch = REGEX_PREFIX_TRIM.matcher(token);
    // $NON-NLS-1$
    String result = pMatch.replaceAll("");
    Matcher sMatch = REGEX_SUFFIX_TRIM.matcher(result);
    // $NON-NLS-1$
    result = sMatch.replaceAll("");
    result = result.trim();
    if (DominoUtils.isHex(result)) {
        return null;
    }
    return caseSensitive ? result : new CaseInsensitiveString(result.toLowerCase());
}
Also used : Matcher(java.util.regex.Matcher) CaseInsensitiveString(org.openntf.domino.types.CaseInsensitiveString) CaseInsensitiveString(org.openntf.domino.types.CaseInsensitiveString)

Example 4 with CaseInsensitiveString

use of org.openntf.domino.types.CaseInsensitiveString in project org.openntf.domino by OpenNTF.

the class IndexDatabase method restoreTokenLocationMap.

/* (non-Javadoc)
	 * @see org.openntf.domino.big.impl.IIndexDatabase#restoreTokenLocationMap(java.lang.CharSequence, java.lang.Object)
	 */
@Override
public Map<CharSequence, Set<CharSequence>> restoreTokenLocationMap(final CharSequence token, final Object mapKey) {
    Map result = null;
    Document doc = getTermDocument(token.toString());
    String itemName = TERM_MAP_PREFIX + String.valueOf(mapKey);
    if (doc.hasItem(itemName)) {
        result = doc.getItemValue(itemName, Map.class);
    } else {
        result = new ConcurrentHashMap<CaseInsensitiveString, Set<String>>(8, 0.9f, 1);
    }
    return result;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) CaseInsensitiveString(org.openntf.domino.types.CaseInsensitiveString) Document(org.openntf.domino.Document) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) CaseInsensitiveString(org.openntf.domino.types.CaseInsensitiveString)

Example 5 with CaseInsensitiveString

use of org.openntf.domino.types.CaseInsensitiveString in project org.openntf.domino by OpenNTF.

the class IndexDatabase method getTermUnidInItems.

/* (non-Javadoc)
	 * @see org.openntf.domino.big.impl.IIndexDatabase#getTermUnidInItems(java.lang.CharSequence, java.util.Collection)
	 */
@Override
public Set<CharSequence> getTermUnidInItems(final CharSequence term, final Collection<String> itemNames) {
    Set<CharSequence> unids = new HashSet<CharSequence>();
    Document doc = getTermDocument(term);
    for (Item item : doc.getItems()) {
        String itemName = item.getName();
        if (itemName.startsWith(TERM_MAP_PREFIX)) {
            // String dbid = itemName.substring(TERM_MAP_PREFIX.length());
            Map termMap = doc.getItemValue(itemName, Map.class);
            for (String key : itemNames) {
                CaseInsensitiveString ciskey = new CaseInsensitiveString(key);
                Object termObj = termMap.get(ciskey);
                if (termObj != null) {
                    if (termObj instanceof Collection) {
                        unids.addAll((Collection) termObj);
                    } else if (termObj instanceof CharSequence) {
                        unids.add(((CharSequence) termObj).toString());
                    } else {
                        unids.add(String.valueOf(termObj));
                    }
                }
            }
        }
    }
    return unids;
}
Also used : Item(org.openntf.domino.Item) Collection(java.util.Collection) DocumentCollection(org.openntf.domino.DocumentCollection) CaseInsensitiveString(org.openntf.domino.types.CaseInsensitiveString) Document(org.openntf.domino.Document) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) CaseInsensitiveString(org.openntf.domino.types.CaseInsensitiveString) HashSet(java.util.HashSet)

Aggregations

CaseInsensitiveString (org.openntf.domino.types.CaseInsensitiveString)34 Map (java.util.Map)15 LinkedHashMap (java.util.LinkedHashMap)13 Document (org.openntf.domino.Document)13 Set (java.util.Set)12 JsonJavaObject (com.ibm.commons.util.io.json.JsonJavaObject)11 ArrayList (java.util.ArrayList)11 HashSet (java.util.HashSet)11 EdgeFrame (com.tinkerpop.frames.EdgeFrame)10 VertexFrame (com.tinkerpop.frames.VertexFrame)10 HashMap (java.util.HashMap)9 DVertexFrame (org.openntf.domino.graph2.builtin.DVertexFrame)9 Method (java.lang.reflect.Method)8 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)8 JsonObject (com.ibm.commons.util.io.json.JsonObject)7 UserAccessException (org.openntf.domino.exceptions.UserAccessException)7 List (java.util.List)6 DEdgeFrame (org.openntf.domino.graph2.builtin.DEdgeFrame)6 DbInfoVertex (org.openntf.domino.graph2.builtin.DbInfoVertex)5 ViewVertex (org.openntf.domino.graph2.builtin.ViewVertex)5