0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
CreateScanner.cc
Go to the documentation of this file.
1 /* -*- c++ -*-
2  * Copyright (C) 2007-2015 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
6  * Hypertable is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; version 3 of the
9  * License, or any later version.
10  *
11  * Hypertable is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
22 #include <Common/Compat.h>
23 
24 #include "CreateScanner.h"
25 
28 
30 
32 
33 #include <Common/Error.h>
34 #include <Common/Logger.h>
35 #include <Common/Serialization.h>
36 #include <Common/md5.h>
37 
38 using namespace Hypertable;
40 
43 
44  try {
45  const uint8_t *ptr = m_event->payload;
46  size_t remain = m_event->payload_len;
47  QueryCache::Key key;
49 
50  const uint8_t *base = ptr;
51  params.decode(&ptr, &remain);
52 
53  if (params.scan_spec().cacheable()) {
54  md5_csum((unsigned char *)base, ptr-base,
55  reinterpret_cast<unsigned char *>(key.digest));
56  m_range_server->create_scanner(&cb, params.table(), params.range_spec(),
57  params.scan_spec(), &key);
58  }
59  else
60  m_range_server->create_scanner(&cb, params.table(), params.range_spec(),
61  params.scan_spec(), 0);
62  }
63  catch (Exception &e) {
64  HT_ERROR_OUT << e << HT_END;
65  cb.error(e.code(), e.what());
66  }
67 }
const RangeSpec & range_spec()
Gets range specification.
Definition: CreateScanner.h:72
Declarations for RangeServer.
const ScanSpec & scan_spec()
Gets scan specification.
Definition: CreateScanner.h:76
Hash key to query cache.
Definition: QueryCache.h:54
Request parameters for create scanner function.
Definition: CreateScanner.h:50
void md5_csum(const unsigned char *input, int ilen, unsigned char output[16])
Convenience function to calculate the MD5 sum of an input buffer.
Definition: md5.cc:312
Logging routines and macros.
Compatibility Macros for C/C++.
#define HT_END
Definition: Logger.h:220
Functions to serialize/deserialize primitives to/from a memory buffer.
#define HT_ERROR_OUT
Definition: Logger.h:301
virtual void decode(const uint8_t **bufp, size_t *remainp)
Reads serialized representation of object from a buffer.
Definition: Serializable.cc:70
Hypertable definitions
Declarations for CreateScanner request parameters.
virtual int error(int error, const String &msg)
Sends a standard error response back to the client.
const TableIdentifier & table()
Gets table identifier.
Definition: CreateScanner.h:68
virtual void run()
Carries out the request.
bool cacheable() const
Definition: ScanSpec.h:123
This is a generic exception class for Hypertable.
Definition: Error.h:314
EventPtr m_event
MESSAGE Event from which handler was initialized.
Declarations for ResponseCallback.
Error codes, Exception handling, error logging.
md5 digest routines.
void create_scanner(Response::Callback::CreateScanner *, const TableIdentifier &, const RangeSpec &, const ScanSpec &, QueryCache::Key *)
uint64_t digest[2]
Hash digest.
Definition: QueryCache.h:63
int code() const
Returns the error code.
Definition: Error.h:391