private TIntHashSet[] recoverRecoveryHandlers(SimpleXARecoveryHandler[] handlers) throws SimpleXAResourceException { TIntHashSet[] phaseSets = new TIntHashSet[handlers.length]; boolean allEmpty = true; for (int i = 0; i < handlers.length; i++) { phaseSets[i] = new TIntHashSet(handlers[i].recover()); if (!allEmpty && phaseSets[i].isEmpty()) { throw new SimpleXAResourceException("Unable to find common phase in pre-existing database"); } else if (!phaseSets[i].isEmpty()) { allEmpty = false; } } return !allEmpty ? phaseSets : null; }
public StaticRank(int trainSize, ClassificationScoreDB classification, TIntHashSet categoriesFilter) { this.trainSize = trainSize; this.classification = classification; this.testSize = classification.getDocumentCount(); if (categoriesFilter == null || categoriesFilter.isEmpty()) { this.categoriesFilter = new TIntHashSet((int) (testSize + testSize * 0.25), (float) 0.75); for (short i = 0; i < classification.getDocumentScoresAsSet(0).size(); i++) { this.categoriesFilter.add(i); } } else { this.categoriesFilter = categoriesFilter; } }
private void recoverDatabase(SimpleXARecoveryHandler[] handlers) throws SimpleXAResourceException { assert handlers != null; TIntHashSet[] phaseSets = recoverRecoveryHandlers(handlers); if (phaseSets == null) { clearDatabase(handlers); } else { TIntHashSet phaseSet = intersectPhaseSets(phaseSets); if (phaseSet.isEmpty()) { throw new SimpleXAResourceException("No matching phases between Resource Handlers."); } selectCommonPhase(highestCommonPhaseNumber(phaseSet), handlers); } }
public int[] recover() throws SimpleXAResourceException { int[] nodePhases = persistentNodePool.recover(); int[] stringPhases = persistentStringPool.recover(); // If both are empty then return empty. if (nodePhases.length == 0 && stringPhases.length == 0) { return nodePhases; } // Else if the intersection is empty *error*, TIntHashSet phaseSet = new TIntHashSet(nodePhases); phaseSet.retainAll(stringPhases); if (phaseSet.isEmpty()) { throw new SimpleXAResourceException("No matching phases between Node and String Pools."); } //else return the intersection. return phaseSet.toArray(); }