SHOGUN
v2.0.0
Main Page
Related Pages
Modules
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
src
shogun
io
streaming
StreamingVwFile.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_VWFILE_H__
11
#define __STREAMING_VWFILE_H__
12
13
#include <
shogun/io/streaming/StreamingFile.h
>
14
#include <
shogun/classifier/vw/vw_common.h
>
15
#include <
shogun/classifier/vw/VwParser.h
>
16
17
namespace
shogun
18
{
20
typedef
int32_t (
CVwParser
::*
parse_func
)(
CIOBuffer
*,
VwExample
*&);
21
26
class
CStreamingVwFile
:
public
CStreamingFile
27
{
28
public
:
33
CStreamingVwFile
();
34
41
CStreamingVwFile
(
const
char
* fname,
char
rw=
'r'
);
42
46
virtual
~CStreamingVwFile
();
47
54
void
set_parser_type
(
E_VW_PARSER_TYPE
type =
T_VW
);
55
66
virtual
void
get_vector
(
VwExample
* &ex, int32_t &len);
67
77
virtual
void
get_vector_and_label
(
VwExample
* &ex, int32_t &len,
float64_t
&label);
78
84
void
set_env
(
CVwEnvironment
* env_to_use)
85
{
86
parser
->
set_env
(env_to_use);
87
}
88
94
CVwEnvironment
*
get_env
()
95
{
96
SG_REF
(
env
);
97
return
env
;
98
}
99
105
void
set_write_to_cache
(
bool
write_cache)
106
{
107
write_to_cache
= write_cache;
108
parser
->
set_write_cache
(write_cache);
109
}
110
116
bool
get_write_to_cache
() {
return
write_to_cache
; }
117
118
inline
virtual
bool
is_seekable
() {
return
false
; }
119
121
inline
virtual
const
char
*
get_name
()
const
122
{
123
return
"StreamingVwFile"
;
124
}
125
126
public
:
128
parse_func
parse_example
;
129
130
private
:
134
virtual
void
init();
135
136
protected
:
138
CVwParser
*
parser
;
139
141
E_VW_PARSER_TYPE
parser_type
;
142
144
CVwEnvironment
*
env
;
145
147
bool
write_to_cache
;
148
};
149
}
150
#endif //__STREAMING_VWFILE_H__
SHOGUN
Machine Learning Toolbox - Documentation