private void threadexec(object obj) { IDBTask task = (IDBTask)obj; task.call(); ((BasicDBTask)task).Finish(); }
public void execute(IDBTask task) { if (conns.Count == 0) { throw new Exception("Empty DBConnection pool, task execute failed."); } task.setDBConnection(conns[0]); task.call(); }
public int append(ITable table) { if (cols != table.columns()) { throw new Exception("The input table doesn't match the schema of the target table."); } for (int i = 0; i < cols; ++i) { IVector curCol = table.getColumn(i); checkColumnType(i, curCol.getDataCategory(), curCol.getDataType()); } for (int i = 0; i < threadCount; ++i) { chunkIndices[i].Clear(); } List <int> keys = domain.getPartitionKeys(table.getColumn(partitionColumnIdx)); int rows = keys.Count; for (int i = 0; i < rows; ++i) { int key = keys[i]; if (key >= 0) { chunkIndices[key % threadCount].Add(i); } } List <IDBTask> tasks = new List <IDBTask>(threadCount); for (int i = 0; i < threadCount; ++i) { List <int> chunk = chunkIndices[i]; if (chunk.Count == 0) { continue; } int count = chunk.Count; int[] array = new int[count]; for (int j = 0; j < count; ++j) { array[j] = chunk[j]; } ITable subTable = table.getSubTable(array); List <IEntity> args = new List <IEntity>(1); args.Add(subTable); tasks.Add(new BasicDBTask(appendScript, args)); } pool.execute(tasks); int affected = 0; for (int i = 0; i < tasks.Count; ++i) { IDBTask task = tasks[i]; if (task.isSuccessful()) { IEntity re = task.getResults(); if (re.getDataType() == DATA_TYPE.DT_VOID) { affected = 0; } else { affected += ((BasicInt)task.getResults()).getValue(); } } } return(affected); }