Package org.voltdb.catalog

Examples of org.voltdb.catalog.ConflictPair


            } else {
                procConflicts = cSet.getWritewriteconflicts();
                cType = ConflictType.WRITE_WRITE;
            }
            for (Conflict c : conflicts.get(conflict_proc)) {
                ConflictPair cp = procConflicts.add(c.toString());
                cp.setAlwaysconflicting(c.alwaysConflicting);
                cp.setStatement0(c.stmt0);
                cp.setStatement1(c.stmt1);
                cp.setConflicttype(cType.getValue());
                for (Table table : c.tables) {
                    TableRef ref = cp.getTables().add(table.getName());
                    ref.setTable(table);
                }
            } // FOR
        } // FOR
    }
View Full Code Here


                Procedure dest_otherProc = dest_db.getProcedures().get(src_conflicts.getProcedure().getName());
                ConflictSet dest_conflicts = dest_proc.getConflicts().add(src_conflicts.getName());
                dest_conflicts.setProcedure(dest_otherProc);
               
                for (ConflictPair src_pair : src_conflicts.getReadwriteconflicts()) {
                    ConflictPair dest_pair = clone(src_pair, dest_db.getCatalog());
                    dest_pair.setStatement0(dest_proc.getStatements().get(src_pair.getStatement0().getName()));
                    dest_pair.setStatement1(dest_otherProc.getStatements().get(src_pair.getStatement1().getName()));
                    for (TableRef src_ref : src_pair.getTables()) {
                        TableRef dest_ref = dest_pair.getTables().add(src_ref.getName());
                        dest_ref.setTable(dest_db.getTables().get(src_ref.getTable().getName()));
                    } // FOR
                } // FOR
                for (ConflictPair src_pair : src_conflicts.getWritewriteconflicts()) {
                    ConflictPair dest_pair = clone(src_pair, dest_db.getCatalog());
                    dest_pair.setStatement0(dest_proc.getStatements().get(src_pair.getStatement0().getName()));
                    dest_pair.setStatement1(dest_otherProc.getStatements().get(src_pair.getStatement1().getName()));
                    for (TableRef src_ref : src_pair.getTables()) {
                        TableRef dest_ref = dest_pair.getTables().add(src_ref.getName());
                        dest_ref.setTable(dest_db.getTables().get(src_ref.getTable().getName()));
                    } // FOR
                } // FOR
            }
        } // FOR
View Full Code Here

           
            for (int i1 = 0, cnt1 = queries1.size(); i1 < cnt1; i1++) {
                stmt1 = queries1.get(i1);
                if (stmt0.statement.getReadonly() && stmt1.statement.getReadonly()) continue;
               
                ConflictPair cp = cache0.conflicts.get(stmt1.statement);
                // If there isn't a ConflictPair, then there isn't a conflict
                if (cp == null) {
                    continue;
                }
                // If the ConflictPair is marked as always conflicting, then
                // we can stop right here
                else if (cp.getAlwaysconflicting()) {
                    if (debug.val) LOG.debug(String.format("%s - Marked as always conflicting", cp.fullName()));
                    return (false);
                }
               
                // Otherwise, at this point we know that we have two queries that both
                // reference the same table(s). Therefore, we need to evaluate the values
                // of the primary keys referenced in the queries to see whether they conflict
                cache1 = this.stmtCache.get(stmt1.statement);
                mappings1 = this.catalogContext.paramMappings.get(stmt1.statement, stmt1.counter);
                if (mappings1 == null) {
                    LOG.warn(String.format("The ParameterMappings for %s in candidate %s is null?\n%s",
                             stmt1, ts1, StringUtil.join("\n", queries1)));
                    return (false);
                }
               
                boolean allEqual = true;
                for (Column col : cache0.colParams.keySet()) {
                    // If either StmtParameters are null, then that's a conflict!
                    StmtParameter param0 = cache0.colParams.get(col);
                    StmtParameter param1 = cache1.colParams.get(col);
                   
                    // It's ok if we're missing one of the parameters that we need if
                    // the values are still not the same. It's only a problem if they're
                    // all the same because we have no idea know whether they're
                    // actually the same or not
                    if (param0 == null || param1 == null) {
                        if (trace.val)
                            LOG.trace(String.format("%s - Missing StmtParameters for %s [param0=%s / param1=%s]",
                                      cp.fullName(), col.fullName(), param0, param1));
                        continue;
                    }
                   
                    // Similarly, if we don't have a ParameterMapping then there is nothing
                    // else we can do. Again, this is ok as long as at least one of the
                    // pkey values are different.
                    ParameterMapping pm0 = CollectionUtil.first(mappings0.get(param0));
                    ParameterMapping pm1 = CollectionUtil.first(mappings1.get(param1));
                    if (pm0 == null) {
                        if (trace.val)
                            LOG.trace(String.format("%s - No ParameterMapping for %s",
                                      cp.fullName(), param0.fullName()));
                        continue;
                    }
                    else if (pm1 == null) {
                        if (trace.val)
                            LOG.trace(String.format("%s - No ParameterMapping for %s",
                                      cp.fullName(), param1.fullName()));
                        continue;
                    }
                   
                    // If the values are not equal, then we can stop checking the
                    // other columns right away.
                    if (this.equalParameters(params0, pm0, params1, pm1) == false) {
                        if (trace.val)
                            LOG.trace(String.format("%s - Parameter values are equal for %s [param0=%s / param1=%s]",
                                      cp.fullName(), col.fullName(), param0, param1));
                        allEqual = false;
                        break;
                    }
                } // FOR (col)
               
                // If all the parameters are equal, than means they are likely to be
                // accessing the same row in the table. That's a conflict!
                if (allEqual) {
                    if (debug.val)
                        LOG.debug(String.format("%s - All known parameter values are equal", cp.fullName()));
                    return (false);
                }
            } // FOR (stmt1)
        } // FOR (stmt0)
        return (true);
View Full Code Here

            ConflictSet cs1 = conflicts1.get(procName);
            assertNotNull(cs1);
           
            assertEquals(cs0.getReadwriteconflicts().size(), cs1.getReadwriteconflicts().size());
            for (ConflictPair conflict0 : cs0.getReadwriteconflicts()) {
                ConflictPair conflict1 = cs1.getReadwriteconflicts().get(conflict0.getName());
                assertNotNull(conflict0.fullName(), conflict1);
                assertEquals(conflict0.fullName(), conflict0.getStatement0().getName(), conflict1.getStatement0().getName());
                assertEquals(conflict0.fullName(), conflict0.getStatement1().getName(), conflict1.getStatement1().getName());
                assertEquals(conflict0.fullName(), conflict0.getAlwaysconflicting(), conflict1.getAlwaysconflicting());
                assertEquals(conflict0.fullName(), conflict0.getConflicttype(), conflict1.getConflicttype());
                for (TableRef ref0 : conflict0.getTables()) {
                    TableRef ref1 = conflict1.getTables().get(ref0.getName());
                    assertNotNull(ref0.fullName(), ref1);
                    assertEquals(ref0.fullName(), ref0.getTable().getName(), ref1.getTable().getName());
                } // FOR
            } // FOR
           
            assertEquals(cs0.getWritewriteconflicts().size(), cs1.getWritewriteconflicts().size());
            for (ConflictPair conflict0 : cs0.getWritewriteconflicts()) {
                ConflictPair conflict1 = cs1.getWritewriteconflicts().get(conflict0.getName());
                assertNotNull(conflict0.fullName(), conflict1);
                assertEquals(conflict0.fullName(), conflict0.getStatement0().getName(), conflict1.getStatement0().getName());
                assertEquals(conflict0.fullName(), conflict0.getStatement1().getName(), conflict1.getStatement1().getName());
                assertEquals(conflict0.fullName(), conflict0.getAlwaysconflicting(), conflict1.getAlwaysconflicting());
                assertEquals(conflict0.fullName(), conflict0.getConflicttype(), conflict1.getConflicttype());
                for (TableRef ref0 : conflict0.getTables()) {
                    TableRef ref1 = conflict1.getTables().get(ref0.getName());
                    assertNotNull(ref0.fullName(), ref1);
                    assertEquals(ref0.fullName(), ref0.getTable().getName(), ref1.getTable().getName());
                } // FOR
            } // FOR
View Full Code Here

        // STMT0 is going to try to read to a table that STMT1 will write to
        // So we should be able to see that conflict
        StatementCache cache = this.checker.stmtCache.get(stmt0);
        assertNotNull(stmt0.fullName(), cache);
       
        ConflictPair cp = cache.conflicts.get(stmt1);
        assertNotNull(stmt0.fullName()+"->"+stmt1.fullName(), cp);
        assertTrue(cp.getAlwaysconflicting());
    }
View Full Code Here

TOP

Related Classes of org.voltdb.catalog.ConflictPair

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.