@Override public Path[] dropIndex(Index index) throws BagriException { // we must not do translate here! Set<Integer> paths = getPathsForIndex(index); Path[] result = new Path[paths.size()]; int idx = 0; for (Integer pathId: paths) { idxDict.remove(pathId); //indexStats.deleteStats(index.getName()); if (index.isRange()) { rangeIndex.remove(pathId); logger.trace("deleteIndex; unregistered range index path: {}", index.getName()); } result[idx] = mdlMgr.getPath(pathId); idx++; } patterns.remove(index); return result; }
@Override public Path[] createIndex(Index index) throws BagriException { Set<Integer> paths = getPathsForIndex(index); Path[] result = new Path[paths.size()]; int idx = 0; for (Integer pathId: paths) { //idxDict.putIfAbsent(pathId, index); idxDict.put(pathId, index); //indexStats.initStats(index.getName()); if (index.isRange()) { rangeIndex.put(pathId, new TreeMap<Comparable, Integer>()); logger.trace("createIndex; registered range index path: {}", index.getName()); } result[idx] = mdlMgr.getPath(pathId); idx++; } if (isPatternIndex(index)) { //String path = mdlMgr.normalizePath(index.getPath()); String path = index.getPath(); path = path.replaceAll("\\{", Matcher.quoteReplacement("\\{")); path = path.replaceAll("\\}", Matcher.quoteReplacement("\\}")); patterns.put(index, Pattern.compile(PathBuilder.regexFromPath(path))); } return result; }
public Set<Long> getIndexedDocuments(int pathId, PathExpression pex, Object value) { logger.trace("getIndexedDocuments.enter; pathId: {}, PEx: {}, value: {}", pathId, pex, value); Set<Long> result = null; Index idx = idxDict.get(pathId); if (idx != null && idx.isEnabled()) { if (Comparison.EQ.equals(pex.getCompType())) { if (value instanceof Collection) { result = getIndexedDocuments(idx, pathId, (Iterable) value); } else { result = getIndexedDocuments(idx, pathId, value); } } else { value = getIndexedValue(idx, pathId, value); if (idx.isRange() && value instanceof Comparable) { result = getIndexedDocuments(idx, pathId, pex.getCompType(), (Comparable) value); } else { logger.debug("getIndexedDocuments; value is not comparable: {}", value.getClass()); } } } logger.trace("getIndexedDocuments.exit; returning: {}", result == null ? null : result.size()); return result; }
xidx.addDocument(docKey, txId); if (idx.isRange()) { TreeMap<Comparable, Integer> range = rangeIndex.get(pathId); Integer count = range.get(value);
@Override public void write(ObjectDataOutput out, Index xIndex) throws IOException { super.writeEntity(out, xIndex); out.writeUTF(xIndex.getName()); out.writeUTF(xIndex.getDocumentType()); out.writeUTF(xIndex.getTypePath()); out.writeUTF(xIndex.getPath()); out.writeUTF(xIndex.getDataType().toString()); out.writeBoolean(xIndex.isCaseSensitive()); out.writeBoolean(xIndex.isRange()); out.writeBoolean(xIndex.isUnique()); out.writeUTF(xIndex.getDescription()); out.writeBoolean(xIndex.isEnabled()); }