@Override public Key createKey(IndexableItem indexableItem) throws JasDBStorageException { Key createdKey = wrappedKeyFactory.createKey(indexableItem); this.valueLoader.enrichKey(indexableItem, createdKey); return createdKey; }
@Override public void enrichKey(IndexableItem indexableItem, Key key) throws JasDBStorageException { for(KeyFactory keyFactory : keyFactories) { Key createdKey = keyFactory.createKey(indexableItem); key.addKey(keyNameMapper, keyFactory.getFieldName(), createdKey); } } }
public static void bulkInsertIndex(Index index, KeyInfo keyInfo, Iterator<IndexableItem> indexableItems) throws JasDBStorageException { KeyFactory keyFactory = keyInfo.getKeyFactory(); long counter = 0; int interval = 0; long start = System.currentTimeMillis(); while(indexableItems.hasNext()) { IndexableItem indexableItem = indexableItems.next(); if(keyFactory.isMultiValueKey(indexableItem)) { Set<Key> keys = keyFactory.createMultivalueKeys(indexableItem); for(Key key : keys) { index.insertIntoIndex(key); } } else { if(KeyUtil.isAnyDataPresent(indexableItem, index)) { Key key = keyFactory.createKey(indexableItem); index.insertIntoIndex(key); } } interval++; counter++; if(interval >= REPORT_INTERVAL) { LOG.info("Index: {} rebuild at: {} items", index, counter); interval = 0; } } long end = System.currentTimeMillis(); LOG.info("Finished rebuild for: {} items in: {}", counter, (end - start)); } }
public static Set<Key> createEntityKeys(Entity entity, Index index) throws JasDBStorageException { StatRecord createKey = StatisticsMonitor.createRecord("bag:createKey"); KeyFactory keyFactory = index.getKeyInfo().getKeyFactory(); Set<Key> insertKeys; if(keyFactory.isMultiValueKey(entity)) { insertKeys = keyFactory.createMultivalueKeys(entity); } else { insertKeys = new HashSet<>(); insertKeys.add(keyFactory.createKey(entity)); } createKey.stop(); return insertKeys; }
isInIndex = !index.searchIndex(new EqualsCondition(keyFactory.createKey(indexableItem)), Index.NO_SEARCH_LIMIT).isEmpty();