blob.h
Go to the documentation of this file.
1 //File: $Id$
2 // Author: John Wu <John.Wu at ACM.org>
3 // Copyright (c) 2009-2016 the Regents of the University of California
6 #ifndef IBIS_BLOB_H
7 #define IBIS_BLOB_H
8 
9 #include "table.h" // ibis::TYPE_T
10 #include "bitvector.h"
11 #include "column.h" // ibis::column
12 
17 class ibis::blob : public ibis::column {
18 public:
19  virtual ~blob() {};
20  blob(const part*, FILE*);
21  blob(const part*, const char*);
22  blob(const ibis::column&);
23 
24  virtual long stringSearch(const char*, ibis::bitvector&) const {return -1;}
25  virtual long stringSearch(const std::vector<std::string>&,
26  ibis::bitvector&) const {return -1;}
27  virtual long stringSearch(const char*) const {return -1;}
28  virtual long stringSearch(const std::vector<std::string>&) const {
29  return -1;}
30 
31  virtual void computeMinMax() {}
32  virtual void computeMinMax(const char*) {}
33  virtual void computeMinMax(const char*, double&, double&, bool&) const {}
34  virtual void loadIndex(const char*, int) const throw () {}
35  virtual long indexSize() const {return -1;}
36  virtual int getValuesArray(void*) const {return -1;}
37 
38  virtual array_t<signed char>*
39  selectBytes(const bitvector&) const {return 0;}
40  virtual array_t<unsigned char>*
41  selectUBytes(const bitvector&) const {return 0;}
42  virtual array_t<int16_t>*
43  selectShorts(const bitvector&) const {return 0;}
44  virtual array_t<uint16_t>*
45  selectUShorts(const bitvector&) const {return 0;}
46  virtual array_t<int32_t>*
47  selectInts(const bitvector&) const {return 0;}
48  virtual array_t<uint32_t>*
49  selectUInts(const bitvector&) const {return 0;}
50  virtual array_t<int64_t>*
51  selectLongs(const bitvector&) const {return 0;}
52  virtual array_t<uint64_t>*
53  selectULongs(const bitvector&) const {return 0;}
54  virtual array_t<float>*
55  selectFloats(const bitvector&) const {return 0;}
56  virtual array_t<double>*
57  selectDoubles(const bitvector&) const {return 0;}
58  virtual std::vector<std::string>*
59  selectStrings(const bitvector&) const {return 0;}
60  virtual std::vector<ibis::opaque>*
61  selectOpaques(const bitvector& mask) const;
62  virtual int getOpaque(uint32_t, ibis::opaque&) const;
63 
64  virtual double getActualMin() const {return DBL_MAX;}
65  virtual double getActualMax() const {return -DBL_MAX;}
66  virtual double getSum() const {return 0;}
67 
68  virtual long append(const void*, const ibis::bitvector&) {return -1;}
69  virtual long append(const char* dt, const char* df, const uint32_t nold,
70  const uint32_t nnew, uint32_t nbuf, char* buf);
71  virtual long writeData(const char* dir, uint32_t nold, uint32_t nnew,
72  ibis::bitvector& mask, const void *va1,
73  void *va2);
74 
75  virtual void write(FILE*) const;
76  virtual void print(std::ostream&) const;
77 
78  long countRawBytes(const bitvector&) const;
79  int selectRawBytes(const bitvector&,
81  int getBlob(uint32_t ind, char *&buf, uint64_t &size) const;
82 
83 protected:
84  int extractAll(const bitvector&,
86  const array_t<char>&,
87  const array_t<int64_t>&) const;
88  int extractSome(const bitvector&,
90  const array_t<char>&, const array_t<int64_t>&,
91  const uint32_t) const;
92  int extractAll(const bitvector&,
94  const char*, const array_t<int64_t>&) const;
95  int extractSome(const bitvector&,
97  const char*, const array_t<int64_t>&, const uint32_t) const;
98  int extractSome(const bitvector&,
100  const char*, const char*, const uint32_t) const;
101  int readBlob(uint32_t ind, char *&buf, uint64_t &size,
102  const array_t<int64_t> &starts, const char *datafile) const;
103  int readBlob(uint32_t ind, char *&buf, uint64_t &size,
104  const char *spfile, const char *datafile) const;
105 }; // ibis::blob
106 
107 std::ostream& operator<<(std::ostream& out, const ibis::opaque& opq);
108 #endif
virtual array_t< double > * selectDoubles(const bitvector &) const
Put the selected values into an array as doubles.
Definition: blob.h:57
virtual long indexSize() const
Compute the index size (in bytes).
Definition: blob.h:35
virtual array_t< unsigned char > * selectUBytes(const bitvector &) const
Return selected rows of the column in an array_t object.
Definition: blob.h:41
int readBlob(uint32_t ind, char *&buf, uint64_t &size, const array_t< int64_t > &starts, const char *datafile) const
Read a single binary object.
Definition: blob.cpp:1423
virtual void computeMinMax(const char *, double &, double &, bool &) const
Compute the actual min/max of the data in directory dir.
Definition: blob.h:33
virtual double getSum() const
Compute the sum of all values by reading the data.
Definition: blob.h:66
A class to provide a minimal support for byte arrays.
Definition: blob.h:17
blob(const part *, FILE *)
Contruct a blob by reading from a metadata file.
Definition: blob.cpp:12
virtual void computeMinMax()
Compute the actual min/max values.
Definition: blob.h:31
virtual array_t< int16_t > * selectShorts(const bitvector &) const
Return selected rows of the column in an array_t object.
Definition: blob.h:43
virtual array_t< int64_t > * selectLongs(const bitvector &) const
Return selected rows of the column in an array_t object.
Definition: blob.h:51
virtual void computeMinMax(const char *)
Compute the actual min/max values.
Definition: blob.h:32
std::ostream & operator<<(std::ostream &out, const ibis::opaque &opq)
Print an opaque object to an output stream.
Definition: blob.cpp:1599
The class to represent a column of a data partition.
Definition: column.h:65
virtual int getOpaque(uint32_t, ibis::opaque &) const
Return the raw binary value for the ith row.
Definition: blob.cpp:1344
virtual array_t< int32_t > * selectInts(const bitvector &) const
Return selected rows of the column in an array_t object.
Definition: blob.h:47
virtual int getValuesArray(void *) const
Copy all rows of the column into an array_t object.
Definition: blob.h:36
virtual void print(std::ostream &) const
Print information about this column.
Definition: blob.cpp:34
virtual std::vector< std::string > * selectStrings(const bitvector &) const
Return the selected rows as strings.
Definition: blob.h:59
virtual double getActualMin() const
A group of functions to compute some basic statistics for the column values.
Definition: blob.h:64
virtual void loadIndex(const char *, int) const
Load the index associated with the column.
Definition: blob.h:34
The class ibis::part represents a partition of a relational table.
Definition: part.h:27
virtual array_t< uint32_t > * selectUInts(const bitvector &) const
Return selected rows of the column in an array_t object.
Definition: blob.h:49
virtual double getActualMax() const
Compute the actual maximum value by reading the data or examining the index.
Definition: blob.h:65
int selectRawBytes(const bitvector &, array_t< char > &, array_t< uint64_t > &) const
Extract the blobs from the rows marked 1 in the mask.
Definition: blob.cpp:805
A data structure to represent a sequence of bits.
Definition: bitvector.h:62
virtual long writeData(const char *dir, uint32_t nold, uint32_t nnew, ibis::bitvector &mask, const void *va1, void *va2)
Write the content of BLOBs packed into two arrays va1 and va2.
Definition: blob.cpp:400
Definition of Word-Aligned Hybrid code.
FastBit Table Interface.
int getBlob(uint32_t ind, char *&buf, uint64_t &size) const
Extract a single binary object.
Definition: blob.cpp:1363
virtual long append(const void *, const ibis::bitvector &)
Append the records in vals to the current working dataset.
Definition: blob.h:68
virtual void write(FILE *) const
Write metadata about the column.
Definition: blob.cpp:27
virtual array_t< float > * selectFloats(const bitvector &) const
Put selected values of a float column into an array.
Definition: blob.h:55
long countRawBytes(const bitvector &) const
Count the number of bytes in the blobs selected by the mask.
Definition: blob.cpp:670
virtual array_t< uint16_t > * selectUShorts(const bitvector &) const
Return selected rows of the column in an array_t object.
Definition: blob.h:45
virtual array_t< signed char > * selectBytes(const bitvector &) const
Retrieve selected 1-byte integer values.
Definition: blob.h:39
virtual std::vector< ibis::opaque > * selectOpaques(const bitvector &mask) const
Extract the blobs from the rows marked 1 in the mask.
Definition: blob.cpp:630
virtual array_t< uint64_t > * selectULongs(const bitvector &) const
Return selected rows of the column in an array_t object.
Definition: blob.h:53
Define the class ibis::column.
int extractAll(const bitvector &, array_t< char > &, array_t< uint64_t > &, const array_t< char > &, const array_t< int64_t > &) const
Extract entries marked 1 in mask from raw to buffer.
Definition: blob.cpp:946
int extractSome(const bitvector &, array_t< char > &, array_t< uint64_t > &, const array_t< char > &, const array_t< int64_t > &, const uint32_t) const
Extract entries marked 1 in mask from raw to buffer subject to a limit on the buffer size...
Definition: blob.cpp:981

Make It A Bit Faster
Contact us
Disclaimers
FastBit source code
FastBit mailing list archive