SHOGUN  4.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
StreamingFile.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 2011 Shashwat Lal Das
8  * Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society
9  */
10 #ifndef __STREAMING_FILE_H__
11 #define __STREAMING_FILE_H__
12 
13 #include <shogun/lib/config.h>
14 #include <shogun/lib/common.h>
15 #include <shogun/io/SGIO.h>
16 #include <shogun/base/SGObject.h>
17 #include <shogun/io/IOBuffer.h>
18 
19 namespace shogun
20 {
21 template <class ST> struct SGSparseVectorEntry;
22 class VwExample;
23 
34  class CStreamingFile: public CSGObject
35  {
36  public:
39 
45  CStreamingFile(const char* fname, char rw='r');
46 
48  virtual ~CStreamingFile();
49 
50 #ifndef SWIG // SWIG should skip this
51 
54  void close()
55  {
56  buf->close_file();
57  }
58 
64  virtual bool is_seekable() { return false; }
65 
69  virtual void reset_stream() { SG_ERROR("Unable to reset the input stream!\n") }
70 
80  virtual void get_vector(bool*& vector, int32_t& len);
81  virtual void get_vector(uint8_t*& vector, int32_t& len);
82  virtual void get_vector(char*& vector, int32_t& len);
83  virtual void get_vector(int32_t*& vector, int32_t& len);
84  virtual void get_vector(float32_t*& vector, int32_t& len);
85  virtual void get_vector(float64_t*& vector, int32_t& len);
86  virtual void get_vector(int16_t*& vector, int32_t& len);
87  virtual void get_vector(uint16_t*& vector, int32_t& len);
88  virtual void get_vector(int8_t*& vector, int32_t& len);
89  virtual void get_vector(uint32_t*& vector, int32_t& len);
90  virtual void get_vector(int64_t*& vector, int32_t& len);
91  virtual void get_vector(uint64_t*& vector, int32_t& len);
92  virtual void get_vector(floatmax_t*& vector, int32_t& len);
94 
104  virtual void get_vector_and_label
105  (bool*& vector, int32_t& len, float64_t& label);
106  virtual void get_vector_and_label
107  (uint8_t*& vector, int32_t& len, float64_t& label);
108  virtual void get_vector_and_label
109  (char*& vector, int32_t& len, float64_t& label);
110  virtual void get_vector_and_label
111  (int32_t*& vector, int32_t& len, float64_t& label);
112  virtual void get_vector_and_label
113  (float32_t*& vector, int32_t& len, float64_t& label);
114  virtual void get_vector_and_label
115  (float64_t*& vector, int32_t& len, float64_t& label);
116  virtual void get_vector_and_label
117  (int16_t*& vector, int32_t& len, float64_t& label);
118  virtual void get_vector_and_label
119  (uint16_t*& vector, int32_t& len, float64_t& label);
120  virtual void get_vector_and_label
121  (int8_t*& vector, int32_t& len, float64_t& label);
122  virtual void get_vector_and_label
123  (uint32_t*& vector, int32_t& len, float64_t& label);
124  virtual void get_vector_and_label
125  (int64_t*& vector, int32_t& len, float64_t& label);
126  virtual void get_vector_and_label
127  (uint64_t*& vector, int32_t& len, float64_t& label);
128  virtual void get_vector_and_label
129  (floatmax_t*& vector, int32_t& len, float64_t& label);
131 
141  virtual void get_string(bool*& vector, int32_t& len);
142  virtual void get_string(uint8_t*& vector, int32_t& len);
143  virtual void get_string(char*& vector, int32_t& len);
144  virtual void get_string(int32_t*& vector, int32_t& len);
145  virtual void get_string(float32_t*& vector, int32_t& len);
146  virtual void get_string(float64_t*& vector, int32_t& len);
147  virtual void get_string(int16_t*& vector, int32_t& len);
148  virtual void get_string(uint16_t*& vector, int32_t& len);
149  virtual void get_string(int8_t*& vector, int32_t& len);
150  virtual void get_string(uint32_t*& vector, int32_t& len);
151  virtual void get_string(int64_t*& vector, int32_t& len);
152  virtual void get_string(uint64_t*& vector, int32_t& len);
153  virtual void get_string(floatmax_t*& vector, int32_t& len);
155 
165  virtual void get_string_and_label
166  (bool*& vector, int32_t& len, float64_t& label);
167  virtual void get_string_and_label
168  (uint8_t*& vector, int32_t& len, float64_t& label);
169  virtual void get_string_and_label
170  (char*& vector, int32_t& len, float64_t& label);
171  virtual void get_string_and_label
172  (int32_t*& vector, int32_t& len, float64_t& label);
173  virtual void get_string_and_label
174  (float32_t*& vector, int32_t& len, float64_t& label);
175  virtual void get_string_and_label
176  (float64_t*& vector, int32_t& len, float64_t& label);
177  virtual void get_string_and_label
178  (int16_t*& vector, int32_t& len, float64_t& label);
179  virtual void get_string_and_label
180  (uint16_t*& vector, int32_t& len, float64_t& label);
181  virtual void get_string_and_label
182  (int8_t*& vector, int32_t& len, float64_t& label);
183  virtual void get_string_and_label
184  (uint32_t*& vector, int32_t& len, float64_t& label);
185  virtual void get_string_and_label
186  (int64_t*& vector, int32_t& len, float64_t& label);
187  virtual void get_string_and_label
188  (uint64_t*& vector, int32_t& len, float64_t& label);
189  virtual void get_string_and_label
190  (floatmax_t*& vector, int32_t& len, float64_t& label);
192 
202  virtual void get_sparse_vector
203  (SGSparseVectorEntry<bool>*& vector, int32_t& len);
204  virtual void get_sparse_vector
205  (SGSparseVectorEntry<uint8_t>*& vector, int32_t& len);
206  virtual void get_sparse_vector
207  (SGSparseVectorEntry<char>*& vector, int32_t& len);
208  virtual void get_sparse_vector
209  (SGSparseVectorEntry<int32_t>*& vector, int32_t& len);
210  virtual void get_sparse_vector
211  (SGSparseVectorEntry<float32_t>*& vector, int32_t& len);
212  virtual void get_sparse_vector
213  (SGSparseVectorEntry<float64_t>*& vector, int32_t& len);
214  virtual void get_sparse_vector
215  (SGSparseVectorEntry<int16_t>*& vector, int32_t& len);
216  virtual void get_sparse_vector
217  (SGSparseVectorEntry<uint16_t>*& vector, int32_t& len);
218  virtual void get_sparse_vector
219  (SGSparseVectorEntry<int8_t>*& vector, int32_t& len);
220  virtual void get_sparse_vector
221  (SGSparseVectorEntry<uint32_t>*& vector, int32_t& len);
222  virtual void get_sparse_vector
223  (SGSparseVectorEntry<int64_t>*& vector, int32_t& len);
224  virtual void get_sparse_vector
225  (SGSparseVectorEntry<uint64_t>*& vector, int32_t& len);
226  virtual void get_sparse_vector
227  (SGSparseVectorEntry<floatmax_t>*& vector, int32_t& len);
229 
239  virtual void get_sparse_vector_and_label
240  (SGSparseVectorEntry<bool>*& vector, int32_t& len, float64_t& label);
241  virtual void get_sparse_vector_and_label
242  (SGSparseVectorEntry<uint8_t>*& vector, int32_t& len, float64_t& label);
243  virtual void get_sparse_vector_and_label
244  (SGSparseVectorEntry<char>*& vector, int32_t& len, float64_t& label);
245  virtual void get_sparse_vector_and_label
246  (SGSparseVectorEntry<int32_t>*& vector, int32_t& len, float64_t& label);
247  virtual void get_sparse_vector_and_label
248  (SGSparseVectorEntry<float32_t>*& vector, int32_t& len, float64_t& label);
249  virtual void get_sparse_vector_and_label
250  (SGSparseVectorEntry<float64_t>*& vector, int32_t& len, float64_t& label);
251  virtual void get_sparse_vector_and_label
252  (SGSparseVectorEntry<int16_t>*& vector, int32_t& len, float64_t& label);
253  virtual void get_sparse_vector_and_label
254  (SGSparseVectorEntry<uint16_t>*& vector, int32_t& len, float64_t& label);
255  virtual void get_sparse_vector_and_label
256  (SGSparseVectorEntry<int8_t>*& vector, int32_t& len, float64_t& label);
257  virtual void get_sparse_vector_and_label
258  (SGSparseVectorEntry<uint32_t>*& vector, int32_t& len, float64_t& label);
259  virtual void get_sparse_vector_and_label
260  (SGSparseVectorEntry<int64_t>*& vector, int32_t& len, float64_t& label);
261  virtual void get_sparse_vector_and_label
262  (SGSparseVectorEntry<uint64_t>*& vector, int32_t& len, float64_t& label);
263  virtual void get_sparse_vector_and_label
264  (SGSparseVectorEntry<floatmax_t>*& vector, int32_t& len, float64_t& label);
265 
267 
274  virtual void get_vector(VwExample*& ex, int32_t& len);
275 
283  virtual void get_vector_and_label(VwExample*& ex, int32_t& len, float64_t& label);
284 #endif // #ifndef SWIG // SWIG should skip this
285 
286 
288  virtual const char* get_name() const { return "StreamingFile"; }
289 
290  protected:
291 
295  char task;
297  char* filename;
298 
299  };
300 }
301 #endif //__STREAMING_FILE_H__
An I/O buffer class.
Definition: IOBuffer.h:41
virtual void reset_stream()
Definition: StreamingFile.h:69
virtual void get_string(bool *&vector, int32_t &len)
virtual bool is_seekable()
Definition: StreamingFile.h:64
virtual void get_vector(bool *&vector, int32_t &len)
#define SG_ERROR(...)
Definition: SGIO.h:129
virtual bool close_file()
Definition: IOBuffer.cpp:126
A Streaming File access class.
Definition: StreamingFile.h:34
virtual void get_string_and_label(bool *&vector, int32_t &len, float64_t &label)
virtual const char * get_name() const
char * filename
Name of the handled file.
Class SGObject is the base class of all shogun objects.
Definition: SGObject.h:115
CIOBuffer * buf
Buffer to hold stuff in memory.
double float64_t
Definition: common.h:50
long double floatmax_t
Definition: common.h:51
virtual void get_sparse_vector_and_label(SGSparseVectorEntry< bool > *&vector, int32_t &len, float64_t &label)
Example class for VW.
Definition: vw_example.h:58
float float32_t
Definition: common.h:49
virtual void get_vector_and_label(bool *&vector, int32_t &len, float64_t &label)
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
virtual void get_sparse_vector(SGSparseVectorEntry< bool > *&vector, int32_t &len)
template class SGSparseVectorEntry
Definition: File.h:23

SHOGUN Machine Learning Toolbox - Documentation