@Override public void process(StaticBuffer key, Map<SliceQuery, EntryList> entries, ScanMetrics metrics) { //The queries are already tailored enough => everything should be removed try { BackendTransaction mutator = writeTx.getTxHandle(); final List<Entry> deletions; if (entries.size()==1) deletions = Iterables.getOnlyElement(entries.values()); else { int size = IteratorUtils.stream(entries.values().iterator()).map( e -> e.size()).reduce(0, (x,y) -> x+y); deletions = new ArrayList<>(size); entries.values().forEach(e -> deletions.addAll(e)); } metrics.incrementCustom(DELETED_RECORDS_COUNT,deletions.size()); if (isRelationTypeIndex()) { mutator.mutateEdges(key, KCVSCache.NO_ADDITIONS, deletions); } else { mutator.mutateIndex(key, KCVSCache.NO_ADDITIONS, deletions); } } catch (final Exception e) { mgmt.rollback(); writeTx.rollback(); metrics.incrementCustom(FAILED_TX); throw new TitanException(e.getMessage(), e); } }
return true; } catch (RuntimeException e) { mgmt.rollback(); throw e;
} catch (final Exception e) { if (null != mgmt && mgmt.isOpen()) mgmt.rollback(); if (writeTx!=null && writeTx.isOpen()) writeTx.rollback();
mgmt.rollback(); writeTx.rollback(); metrics.incrementCustom(FAILED_TX);
@Override public void process(StaticBuffer key, Map<SliceQuery, EntryList> entries, ScanMetrics metrics) { //The queries are already tailored enough => everything should be removed try { BackendTransaction mutator = writeTx.getTxHandle(); final List<Entry> deletions; if (entries.size()==1) deletions = Iterables.getOnlyElement(entries.values()); else { int size = IteratorUtils.stream(entries.values().iterator()).map( e -> e.size()).reduce(0, (x,y) -> x+y); deletions = new ArrayList<>(size); entries.values().forEach(e -> deletions.addAll(e)); } metrics.incrementCustom(DELETED_RECORDS_COUNT,deletions.size()); if (isRelationTypeIndex()) { mutator.mutateEdges(key, KCVSCache.NO_ADDITIONS, deletions); } else { mutator.mutateIndex(key, KCVSCache.NO_ADDITIONS, deletions); } } catch (final Exception e) { mgmt.rollback(); writeTx.rollback(); metrics.incrementCustom(FAILED_TX); throw new TitanException(e.getMessage(), e); } }
return true; } catch (RuntimeException e) { mgmt.rollback(); throw e;
return true; } catch (RuntimeException e) { mgmt.rollback(); throw e;
/** * Create in the db model a new property and the class it uses. * * @param propertyName Entry name in the model. * @param c Class for the entry. */ private void makeIfNotExistProperty(String propertyName, Class<?> c) { ManagementSystem manager = (ManagementSystem) getTitanGraph().openManagement(); if (!manager.containsPropertyKey(propertyName)) { manager.makePropertyKey(propertyName).dataType(c).cardinality(Cardinality.SINGLE).make(); System.out.println("adding key " + propertyName); manager.commit(); } else { manager.rollback(); } }
} catch (final Exception e) { if (null != mgmt && mgmt.isOpen()) mgmt.rollback(); if (writeTx!=null && writeTx.isOpen()) writeTx.rollback();
mgmt.rollback(); writeTx.rollback(); metrics.incrementCustom(FAILED_TX);