blob: e81a4f285b755d8c7054c3b270bba6d791ed415d [file] [log] [blame]
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
// This file contains a schema and some utility code for a simple
// "Key-Value" table, with int32 keys and nullable int32 values. This
// is used by a few tests.
#pragma once
#include <boost/optional.hpp>
#include <boost/optional/optional_io.hpp>
#include <iostream>
#include "kudu/common/schema.h"
namespace kudu {
// Struct for keeping track of what we think the contents of a row should be after
// our random mutations.
struct ExpectedKeyValueRow {
// Non-nullable key.
int32_t key;
// Nullable value.
boost::optional<int32_t> val;
bool operator==(const ExpectedKeyValueRow& other) const {
return key == other.key && val == other.val;
}
};
inline Schema CreateKeyValueTestSchema() {
return Schema({ColumnSchema("key", INT32),
ColumnSchema("val", INT32, true) }, 1);
}
inline std::ostream& operator<<(std::ostream& o, const ExpectedKeyValueRow& t) {
o << "{" << t.key << ", ";
if (t.val == boost::none) {
o << "NULL";
} else {
o << *t.val;
}
return o << "}";
}
} // namespace kudu