BulkFetchHandler<DataObj, ParamObj>

dtl


BulkFetchHandler<DataObj, ParamObj>

Category: functors Component type: concept

Description

A BulkFetchHandler is a special kind of LoggingHandler that is intended for use with fetches made through bulk_copy(). The only difference between this and a LoggingHandler is that this handler records the row numbers of any elements that fail or throw during SelValidate and provides methods to retrieve these row numbers.

Definition

Defined in the DBView.h header file.

Associated types

AlwaysThrowsHandler, LoggingHandler, IOHandler.

Example:

(See also bulk_fetch_helper defined in dtl_algo.h).
// bulk copy example illustrating use of BulkFetchHandler

void BulkCopyExample()

{



	 ExampleCharred results[20];

	 

	 typedef DBView<ExampleCharred> DBV;





	 DBV view(DBV::Args().tables("DB_EXAMPLE").SelValidate(

		 BulkSelVal()

		).handler(

		   BulkFetchHandler<ExampleCharred>()

		)

	 );



         DBV::select_iterator it(view.begin());



	 cout << "***" << endl;

	 cout << "Reading first 10 Example objects using bulk_copy() ..." << endl;



         bulk_copy(it, &results[0], &results[10]);

	 

	 const BulkFetchHandler<ExampleCharred> &fetch_handler = 

		 it.get_io_handler((BulkFetchHandler *) NULL);

	 vector<size_t> failures = fetch_handler.GetFailures();



	 copy(&results[0], &results[10], ostream_iterator(cout, "\n"));



	 cout << "Objects failing validation: " << endl;

	 vector<size_t>::iterator val_it;



	 for (val_it = failures.begin(); val_it != failures.end(); ++val_it)

	 {

		cout << results[*val_it] << endl;

	 }



	 cout << "***" << endl;

	 

	 cout << "Reading next 10 Example objects using bulk_copy() ... " << endl;

         bulk_copy(it, &results[0], &results[10]);



	 failures = fetch_handler.GetFailures();

	 

	 copy(&results[0], &results[10], ostream_iterator(cout, "\n"));

	 

	 cout << "Objects failing validation: " << endl;



	 for (val_it = failures.begin(); val_it != failures.end(); ++val_it)

	 {

		cout << results[*val_it] << endl;

	 }



	 cout << "***" << endl;

	 

	 cout << "Finally read 10 more Example objects using bulk_copy() ... " << endl;

         bulk_copy(it, &results[10], &results[20]);

	 

	 failures = fetch_handler.GetFailures();



	 copy(&results[10], &results[20], ostream_iterator(cout, "\n"));



	 cout << "Objects failing validation: " << endl;



	 for (val_it = failures.begin(); val_it != failures.end(); ++val_it)

	 {

		cout << results[10 + *val_it] << endl;

	 }



}

Public Base Classes

LoggingHandler

Template parameters

Parameter Description Default
DataObj The value type of objects in a DBView.  
ParamObj The type of object used to specify the postfix parameters to the DBView. DefaultParamObj<DataObj> 

 

Notation

X A type that is a model of BulkFetchHandler
a Object of type X

Expression semantics

Name Expression Precondition Semantics Postcondition
Default constructor
X a()
  Construct the function object.  
Copy constructor
X a(const X &b)
  Copy construct the BulkFetchHandler.  
Assignment Operator X operator=(const X &b)   Assign the BulkFetchHandler.  
Apply bulk fetch handler
dtl_ios_base::MeansOfRecovery operator()(RootException &ex, dtl_ios_base &base, DataObj &data, ParamObj &params)
  This operator takes references to the thrown RootException object, the dtl_ios_base (iterator) which threw, and the DataObj and ParamObj relevant to the exception. Logs the exception to the vector of LoggedTriple's and then tells the iterator to suppress the error (dtl_ios_base::SUPPRESS_ERROR).  
Get indexes of failed elements
const vector<size_t> &GetFailures() const
  Returns the logged exceptions as a vector of LoggedTriple's. Note that all copies of this handler share the same error log vector.  

 

See also

bulk_copy, AlwaysThrowsHandler, LoggingHandler, IOHandler, DBView, IndexedDBView


[DTL Home]

Copyright © 2002, Michael Gradman and Corwin Joy.

Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appears in all copies and that both that copyright notice and this permission notice appear in supporting documentation. Corwin Joy and Michael Gradman make no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty.

SourceForge Logo

This site written using the ORB. [The ORB]