public Collection<Integer> getTypeIndexes(String root, boolean uniqueOnly) { Collection<Integer> result = new HashSet<>(); //idxDict.keySet(p); for (Map.Entry<Integer, Index> e: idxDict.entrySet()) { if (root.equals(e.getValue().getTypePath())) { if (uniqueOnly) { if (!e.getValue().isUnique()) { continue; } } result.add(e.getKey()); } } logger.trace("getTypeIndexes.exit; returning {} path for root: {}, unique: {}", result.size(), root, uniqueOnly); return result; }
public void addIndex(long docId, int pathId, String path, Object value) throws BagriException { // shouldn't we index NULL values too? create special NULL class for this.. if (value != null) { Collection<Index> indices = getPathIndices(pathId, path); if (indices.isEmpty()) { return; } IndexKey xid = factory.newIndexKey(pathId, value); for (Index idx: indices) { //indexPath(idx, docId, pathId, value); if (idx.isEnabled()) { long txId = idx.isUnique() ? txMgr.getCurrentTxId() : TX_NO; ValueIndexator indexator = new ValueIndexator(docId, txId); if (indexAsynch) { idxCache.submitToKey(xid, indexator); } else { // this does not work in transaction! idxCache.executeOnKey(xid, indexator); } logger.trace("addIndex; index submit for key {}", xid); } } } }
boolean first = false; IndexedValue xidx = entry.getValue(); if (idx.isUnique()) { long id = DocumentKey.toDocumentId(docKey); if (!checkUniquiness((UniqueDocument) xidx, id)) {
@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()); }