1 /* 2 Copyright (C) 2003-2007 MySQL AB, 2008 Sun Microsystems, Inc. 3 All rights reserved. Use is subject to license terms. 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License, version 2.0, 7 as published by the Free Software Foundation. 8 9 This program is also distributed with certain software (including 10 but not limited to OpenSSL) that is licensed under separate terms, 11 as designated in a particular file or component or in included license 12 documentation. The authors of MySQL hereby grant you an additional 13 permission to link the program and your derivative works with the 14 separately licensed software that they have included with MySQL. 15 16 This program is distributed in the hope that it will be useful, 17 but WITHOUT ANY WARRANTY; without even the implied warranty of 18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 GNU General Public License, version 2.0, for more details. 20 21 You should have received a copy of the GNU General Public License 22 along with this program; if not, write to the Free Software 23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 24 */ 25 26 #ifndef HUGO_TRANSACTIONS_HPP 27 #define HUGO_TRANSACTIONS_HPP 28 29 30 #include <NDBT.hpp> 31 #include <HugoCalculator.hpp> 32 #include <HugoOperations.hpp> 33 class NDBT_Stats; 34 35 class HugoTransactions : public HugoOperations { 36 public: 37 HugoTransactions(const NdbDictionary::Table&, 38 const NdbDictionary::Index* idx = 0); 39 ~HugoTransactions(); 40 int loadTable(Ndb*, 41 int records, 42 int batch = 512, 43 bool allowConstraintViolation = true, 44 int doSleep = 0, 45 bool oneTrans = false, 46 int updateValue = 0, 47 bool abort = false); 48 49 int loadTableStartFrom(Ndb*, 50 int startFrom, 51 int records, 52 int batch = 512, 53 bool allowConstraintViolation = true, 54 int doSleep = 0, 55 bool oneTrans = false, 56 int updateValue = 0, 57 bool abort = false); 58 59 int scanReadRecords(Ndb*, 60 int records, 61 int abort = 0, 62 int parallelism = 0, 63 NdbOperation::LockMode = NdbOperation::LM_Read, 64 int scan_flags = 0); 65 66 int scanReadRecords(Ndb*, 67 const NdbDictionary::Index*, 68 int records, 69 int abort = 0, 70 int parallelism = 0, 71 NdbOperation::LockMode = NdbOperation::LM_Read, 72 int scan_flags = 0); 73 74 int pkReadRecords(Ndb*, 75 int records, 76 int batchsize = 1, 77 NdbOperation::LockMode = NdbOperation::LM_Read, 78 int rand = 0); 79 80 int pkReadUnlockRecords(Ndb*, 81 int records, 82 int batchsize = 1, 83 NdbOperation::LockMode = NdbOperation::LM_Read); 84 85 int scanUpdateRecords(Ndb*, NdbScanOperation::ScanFlag, 86 int records, 87 int abort = 0, 88 int parallelism = 0); 89 90 int scanUpdateRecords(Ndb*, 91 int records, 92 int abort = 0, 93 int parallelism = 0); 94 95 int scanUpdateRecords1(Ndb*, 96 int records, 97 int abort = 0, 98 int parallelism = 0); 99 int scanUpdateRecords2(Ndb*, 100 int records, 101 int abort = 0, 102 int parallelism = 0); 103 int scanUpdateRecords3(Ndb*, 104 int records, 105 int abort = 0, 106 int parallelism = 0); 107 108 int pkUpdateRecords(Ndb*, 109 int records, 110 int batchsize = 1, 111 int doSleep = 0); 112 int pkInterpretedUpdateRecords(Ndb*, 113 int records, 114 int batchsize = 1); 115 int pkDelRecords(Ndb*, 116 int records = 0, 117 int batch = 1, 118 bool allowConstraintViolation = true, 119 int doSleep = 0); 120 121 int pkRefreshRecords(Ndb*, int startFrom, int count = 1, int batch = 1); 122 123 int lockRecords(Ndb*, 124 int records, 125 int percentToLock = 1, 126 int lockTime = 1000); 127 128 int fillTable(Ndb*, 129 int batch=512); 130 131 int fillTableStartFrom(Ndb*, int startFrom, int batch=512); 132 133 /** 134 * Reading using UniqHashIndex with key = pk 135 */ 136 int indexReadRecords(Ndb*, 137 const char * idxName, 138 int records, 139 int batchsize = 1); 140 141 int indexUpdateRecords(Ndb*, 142 const char * idxName, 143 int records, 144 int batchsize = 1); 145 setRetryMax(int retryMax=100)146 void setRetryMax(int retryMax = 100) { m_retryMax = retryMax; } 147 148 Uint64 m_latest_gci; 149 setStatsLatency(NDBT_Stats * stats)150 void setStatsLatency(NDBT_Stats* stats) { m_stats_latency = stats; } 151 152 // allows multiple threads to update separate batches setThrInfo(int thr_count,int thr_no)153 void setThrInfo(int thr_count, int thr_no) { 154 m_thr_count = thr_count; 155 m_thr_no = thr_no; 156 } 157 158 protected: 159 NDBT_ResultRow row; 160 int m_defaultScanUpdateMethod; 161 int m_retryMax; 162 163 NDBT_Stats* m_stats_latency; 164 165 int m_thr_count; // 0 if no separation between threads 166 int m_thr_no; 167 }; 168 169 170 171 172 #endif 173 174