SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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>
19 
20 namespace shogun
21 {
22 template <class ST> struct SGSparseVectorEntry;
23 class VwExample;
24 
35  class CStreamingFile: public CSGObject
36  {
37  public:
40 
46  CStreamingFile(const char* fname, char rw='r');
47 
49  virtual ~CStreamingFile();
50 
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 
286  virtual const char* get_name() const { return "StreamingFile"; }
287 
288  protected:
289 
293  char task;
295  char* filename;
296 
297  };
298 }
299 #endif //__STREAMING_FILE_H__

SHOGUN Machine Learning Toolbox - Documentation