protected DataBlock writeKey(TreeBlock treeBlock, Key key, DataBlock dataBlock) throws JasDBStorageException { return keyInfo.getKeyFactory().writeKey(key, dataBlock); }
protected KeyLoadResult loadKeyResult(TreeBlock treeBlock, int offset, DataBlock dataBlock) throws JasDBStorageException { return keyInfo.getKeyFactory().loadKey(offset, dataBlock); }
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; }
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)); } }
protected static EqualsCondition validateCondition(KeyInfo keyInfo, SearchCondition condition) throws JasDBStorageException { if(condition instanceof EqualsCondition) { EqualsCondition equalsCondition = (EqualsCondition) condition; KeyFactory keyFactory = keyInfo.getKeyFactory(); if(!keyFactory.supportsKey(equalsCondition.getKey())) { Key supportedKey = keyFactory.convertKey(equalsCondition.getKey()); return new EqualsCondition(supportedKey); } else { return equalsCondition; } } else { throw new JasDBStorageException("Invalid Equals condition input: " + condition); } }
public static IndexScanReport doIndexScan(Index index, KeyInfo keyInfo, Iterator<IndexableItem> indexableItems, boolean fullScan) throws JasDBStorageException { KeyFactory keyFactory = keyInfo.getKeyFactory(); long indexedItems = 0; long expectedItems = 0;
private RangeCondition validateRangeCondition(SearchCondition condition) throws JasDBStorageException { if(condition instanceof RangeCondition) { KeyFactory factory = keyInfo.getKeyFactory(); RangeCondition rangeCondition = (RangeCondition) condition; rangeCondition.setStart(validateKey(factory, rangeCondition.getStart())); rangeCondition.setEnd(validateKey(factory, rangeCondition.getEnd())); return rangeCondition; } else { throw new JasDBStorageException("Invalid Range condition input: " + condition); } }