SHOGUN
3.2.1
首页
相关页面
模块
类
文件
文件列表
文件成员
全部
类
命名空间
文件
函数
变量
类型定义
枚举
枚举值
友元
宏定义
组
页
src
shogun
classifier
vw
cache
VwNativeCacheReader.h
浏览该文件的文档.
1
/*
2
* Copyright (c) 2009 Yahoo! Inc. All rights reserved. The copyrights
3
* embodied in the content of this file are licensed under the BSD
4
* (revised) open source license.
5
*
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 3 of the License, or
9
* (at your option) any later version.
10
*
11
* Written (W) 2011 Shashwat Lal Das
12
* Adaptation of Vowpal Wabbit v5.1.
13
* Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society.
14
*/
15
16
#ifndef _VW_NATIVECACHE_READ_H__
17
#define _VW_NATIVECACHE_READ_H__
18
19
#include <
shogun/classifier/vw/cache/VwCacheReader.h
>
20
21
namespace
shogun
22
{
23
24
#ifndef DOXYGEN_SHOULD_SKIP_THIS
25
// Packed structure for efficient storage
26
struct
one_float
27
{
28
// The float to store
29
float32_t
f;
30
} __attribute__((packed));
31
32
#endif // DOXYGEN_SHOULD_SKIP_THIS
33
39
class
CVwNativeCacheReader
:
public
CVwCacheReader
40
{
41
public
:
45
CVwNativeCacheReader
();
46
53
CVwNativeCacheReader
(
char
* fname,
CVwEnvironment
* env_to_use);
54
61
CVwNativeCacheReader
(int32_t f,
CVwEnvironment
* env_to_use);
62
66
virtual
~CVwNativeCacheReader
();
67
73
virtual
void
set_file
(int32_t f);
74
80
virtual
bool
read_cached_example
(
VwExample
*
const
ae);
81
85
void
check_cache_metadata
();
86
92
virtual
const
char
*
get_name
()
const
{
return
"VwNativeCacheReader"
; }
93
94
private
:
98
void
init();
99
108
char
* run_len_decode(
char
*p,
vw_size_t
& i);
109
117
inline
int32_t ZigZagDecode(uint32_t n)
118
{
119
return
(n >> 1) ^ -
static_cast<
int32_t
>
(n & 1);
120
}
121
130
char
* bufread_label(VwLabel*
const
ld,
char
* c);
131
139
vw_size_t
read_cached_label(VwLabel*
const
ld);
140
148
vw_size_t
read_cached_tag(VwExample*
const
ae);
149
150
151
protected
:
153
CIOBuffer
buf
;
154
155
private
:
156
// Used while parsing
157
const
vw_size_t
char_size;
158
vw_size_t
neg_1;
159
vw_size_t
general;
160
};
161
162
}
163
#endif // _VW_NATIVECACHE_READ_H__
SHOGUN
机器学习工具包 - 项目文档