Пример #1
0
 void commit(Transaction tx) {
   if (tx != null) {
     TxCommitHook hook = txCommitHooks.remove(tx);
     if (hook != null) {
       for (PropertyIndex index : hook.getAddedPropertyIndexes()) {
         addPropertyIndex(index);
       }
     }
   }
 }
Пример #2
0
 public Iterable<PropertyIndex> index(String key) {
   List<PropertyIndex> list = indexMap.get(key);
   TxCommitHook hook = txCommitHooks.get(getTransaction());
   if (hook != null) {
     PropertyIndex index = hook.getIndex(key);
     if (index != null) {
       List<PropertyIndex> added = new ArrayList<PropertyIndex>();
       if (list != null) {
         added.addAll(list);
       }
       added.add(index);
       return added;
     }
   }
   if (list == null) {
     list = Collections.emptyList();
   }
   return list;
 }
Пример #3
0
 // concurent transactions may create duplicate keys, oh well
 PropertyIndex createPropertyIndex(String key) {
   Transaction tx = getTransaction();
   if (tx == null) {
     throw new NotInTransactionException("Unable to create property index for " + key);
   }
   TxCommitHook hook = txCommitHooks.get(tx);
   if (hook == null) {
     hook = new TxCommitHook();
     txCommitHooks.put(tx, hook);
   }
   PropertyIndex index = hook.getIndex(key);
   if (index != null) {
     return index;
   }
   int id = (int) idGenerator.nextId(PropertyIndex.class);
   index = new PropertyIndex(key, id);
   hook.addIndex(index);
   persistenceManager.createPropertyIndex(key, id);
   return index;
 }
Пример #4
0
 public PropertyIndex getIndexFor(int keyId) {
   PropertyIndex index = idToIndexMap.get(keyId);
   if (index == null) {
     TxCommitHook commitHook = txCommitHooks.get(getTransaction());
     if (commitHook != null) {
       index = commitHook.getIndex(keyId);
       if (index != null) {
         return index;
       }
     }
     String indexString;
     indexString = persistenceManager.loadIndex(keyId);
     if (indexString == null) {
       throw new NotFoundException("Index not found [" + keyId + "]");
     }
     index = new PropertyIndex(indexString, keyId);
     addPropertyIndex(index);
   }
   return index;
 }