SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
StreamingVwCacheFile.cpp
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  */
11 
12 using namespace shogun;
13 
15  : CStreamingFile()
16 {
17  buf=NULL;
18  init(C_NATIVE);
19 }
20 
22  : CStreamingFile()
23 {
24  init(cache_type);
25 }
26 
28  : CStreamingFile(fname, rw)
29 {
30  init(cache_type);
31 }
32 
34 {
35  SG_UNREF(env);
37 }
38 
40 {
42  len = 1;
43  else
44  len = -1;
45 }
46 
48 {
50  len = 1;
51  else
52  len = -1;
53 }
54 
56 {
57  SG_REF(env_to_use);
58  SG_UNREF(env);
59  env = env_to_use;
60 
62 
63  switch (cache_format)
64  {
65  case C_NATIVE:
67  return;
68  case C_PROTOBUF:
69  SG_ERROR("Protocol buffers cache support is not implemented yet!\n")
70  }
71 
72  SG_ERROR("Unexpected cache type to use for reading!\n")
73 }
74 
76 {
77  buf->reset_file();
78 
79  // Recheck the cache so the parser can directly proceed with the examples
80  if (cache_format == C_NATIVE)
81  ((CVwNativeCacheReader*) cache_reader)->check_cache_metadata();
82 }
83 
84 void CStreamingVwCacheFile::init(EVwCacheType cache_type)
85 {
86  cache_format = cache_type;
87  env = new CVwEnvironment();
88 
89  switch (cache_type)
90  {
91  case C_NATIVE:
92  if (buf)
94  else
95  cache_reader=NULL;
96  return;
97  case C_PROTOBUF:
98  SG_ERROR("Protocol buffers cache support is not implemented yet!\n")
99  }
100 
101  SG_ERROR("Unrecognized cache type to read from!\n")
102 }

SHOGUN Machine Learning Toolbox - Documentation