]> git-server-git.apps.pok.os.sepia.ceph.com Git - rocksdb.git/commitdiff
Changes to support unity build:
authormiguelportilla <miguelportilla@pobros.com>
Thu, 7 Aug 2014 17:05:04 +0000 (13:05 -0400)
committermiguelportilla <miguelportilla@pobros.com>
Mon, 11 Aug 2014 17:22:47 +0000 (13:22 -0400)
* Script for building the unity.cc file via Makefile
* Unity executable Makefile target for testing builds
* Source code changes to fix compilation of unity build

19 files changed:
.gitignore
Makefile
build_tools/unity [new file with mode: 0755]
db/column_family.cc
db/compaction.cc
db/compaction.h
db/compaction_picker.cc
db/compaction_picker.h
db/db_impl.cc
db/db_impl.h
db/version_set.cc
table/block_based_table_builder.cc
table/block_prefix_index.cc
table/merger.cc
util/bloom.cc
util/dynamic_bloom.cc
util/hash.h
util/options_builder.cc
utilities/geodb/geodb_impl.cc

index cc5116ec76ccf24bb7c15acda41ec342d67f9de3..99a7d61d61971625fd94941c2c14f1166e785558 100644 (file)
@@ -32,3 +32,4 @@ coverage/COVERAGE_REPORT
 tags
 java/*.log
 java/include/org_rocksdb_*.h
+unity.cc
index 01f524a7400ff690e5430043ad3712a086b309a0..0ada6b12e129deb8cadb21fe3fa41d8752e16b90 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -234,8 +234,14 @@ valgrind_check: all $(PROGRAMS) $(TESTS)
                echo $$t $$((etime - stime)) >> $(VALGRIND_DIR)/valgrind_tests_times; \
        done
 
+unity.cc:      
+       $(shell (export ROCKSDB_ROOT="$(CURDIR)"; "$(CURDIR)/build_tools/unity" "$(CURDIR)/unity.cc"))
+
+unity: unity.cc unity.o
+       $(CXX) unity.o $(EXEC_LDFLAGS) -o $@ $(LDFLAGS) $(COVERAGEFLAGS)
+
 clean:
-       -rm -f $(PROGRAMS) $(TESTS) $(LIBRARY) $(SHARED) $(MEMENVLIBRARY) build_config.mk
+       -rm -f $(PROGRAMS) $(TESTS) $(LIBRARY) $(SHARED) $(MEMENVLIBRARY) build_config.mk unity.cc
        -rm -rf ios-x86/* ios-arm/*
        -find . -name "*.[od]" -exec rm {} \;
        -find . -type f -regex ".*\.\(\(gcda\)\|\(gcno\)\)" -exec rm {} \;
diff --git a/build_tools/unity b/build_tools/unity
new file mode 100755 (executable)
index 0000000..477b8f7
--- /dev/null
@@ -0,0 +1,78 @@
+#!/bin/sh
+#
+# Create the unity file
+#
+
+OUTPUT=$1
+if test -z "$OUTPUT"; then
+  echo "usage: $0 <output-filename>" >&2
+  exit 1
+fi
+
+# Delete existing file, if it exists
+rm -f "$OUTPUT"
+touch "$OUTPUT"
+
+# Detect OS
+if test -z "$TARGET_OS"; then
+    TARGET_OS=`uname -s`
+fi
+
+# generic port files (working on all platform by #ifdef) go directly in /port
+GENERIC_PORT_FILES=`cd "$ROCKSDB_ROOT"; find port -name '*.cc' | tr "\n" " "`
+
+# On GCC, we pick libc's memcmp over GCC's memcmp via -fno-builtin-memcmp
+case "$TARGET_OS" in
+    Darwin)
+        # PORT_FILES=port/darwin/darwin_specific.cc
+        ;;
+    IOS)
+        ;;
+    Linux)
+        # PORT_FILES=port/linux/linux_specific.cc
+        ;;
+    SunOS)
+        # PORT_FILES=port/sunos/sunos_specific.cc
+        ;;
+    FreeBSD)
+        # PORT_FILES=port/freebsd/freebsd_specific.cc
+        ;;
+    NetBSD)
+        # PORT_FILES=port/netbsd/netbsd_specific.cc
+        ;;
+    OpenBSD)
+        # PORT_FILES=port/openbsd/openbsd_specific.cc
+        ;;
+    DragonFly)
+        # PORT_FILES=port/dragonfly/dragonfly_specific.cc
+        ;;
+    OS_ANDROID_CROSSCOMPILE)
+        # PORT_FILES=port/android/android.cc
+        ;;
+    *)
+        echo "Unknown platform!" >&2
+        exit 1
+esac
+
+# We want to make a list of all cc files within util, db, table, and helpers
+# except for the test and benchmark files. By default, find will output a list
+# of all files matching either rule, so we need to append -print to make the
+# prune take effect.
+DIRS="util db table utilities"
+
+set -f # temporarily disable globbing so that our patterns arent expanded
+PRUNE_TEST="-name *test*.cc -prune"
+PRUNE_BENCH="-name *bench*.cc -prune"
+PORTABLE_FILES=`cd "$ROCKSDB_ROOT"; find $DIRS $PRUNE_TEST -o $PRUNE_BENCH -o -name '*.cc' -print | sort`
+PORTABLE_CPP=`cd "$ROCKSDB_ROOT"; find $DIRS $PRUNE_TEST -o $PRUNE_BENCH -o -name '*.cpp' -print | sort`
+set +f # re-enable globbing
+
+# The sources consist of the portable files, plus the platform-specific port
+# file.
+for SOURCE_FILE in $PORTABLE_FILES $GENERIC_PORT_FILES $PORT_FILES $PORTABLE_CPP
+do
+       echo "#include <$SOURCE_FILE>" >> "$OUTPUT"
+done
+
+echo "int main(int argc, char** argv){ return 0; }" >> "$OUTPUT"
+
index 9d1783236346002cd2254a7d189676250f12d653..d4467eea08882ed9a613b4f8f5eeeeb06068cd15 100644 (file)
@@ -49,15 +49,6 @@ ColumnFamilyHandleImpl::~ColumnFamilyHandleImpl() {
 
 uint32_t ColumnFamilyHandleImpl::GetID() const { return cfd()->GetID(); }
 
-namespace {
-// Fix user-supplied options to be reasonable
-template <class T, class V>
-static void ClipToRange(T* ptr, V minvalue, V maxvalue) {
-  if (static_cast<V>(*ptr) > maxvalue) *ptr = maxvalue;
-  if (static_cast<V>(*ptr) < minvalue) *ptr = minvalue;
-}
-}  // anonymous namespace
-
 ColumnFamilyOptions SanitizeOptions(const InternalKeyComparator* icmp,
                                     const InternalFilterPolicy* ipolicy,
                                     const ColumnFamilyOptions& src) {
index 40941a98dbe8f71618aadc9ce247865cdcd3e6d6..0bffa0162fa142cfe205e327131b49479ae99251 100644 (file)
@@ -18,7 +18,7 @@
 
 namespace rocksdb {
 
-static uint64_t TotalFileSize(const std::vector<FileMetaData*>& files) {
+uint64_t TotalFileSize(const std::vector<FileMetaData*>& files) {
   uint64_t sum = 0;
   for (size_t i = 0; i < files.size() && files[i]; i++) {
     sum += files[i]->fd.GetFileSize();
index 6f1f96e49ca83bb8d236223b4dc57827aa2deeb5..6000f636be4ff222f932ee8f42f00322cb79f2b4 100644 (file)
@@ -231,4 +231,7 @@ class Compaction {
   void ResetNextCompactionIndex();
 };
 
+// Utility function
+extern uint64_t TotalFileSize(const std::vector<FileMetaData*>& files);
+
 }  // namespace rocksdb
index 4c2ccb7e071b25940d2318418466552a7232b8fc..170a48efee484c41ea9c6307f87964caec1d28e0 100644 (file)
 
 namespace rocksdb {
 
+uint64_t TotalCompensatedFileSize(const std::vector<FileMetaData*>& files) {
+  uint64_t sum = 0;
+  for (size_t i = 0; i < files.size() && files[i]; i++) {
+    sum += files[i]->compensated_file_size;
+  }
+  return sum;
+}
+
 namespace {
 // Determine compression type, based on user options, level of the output
 // file and whether compression is disabled.
@@ -45,14 +53,6 @@ CompressionType GetCompressionType(const Options& options, int level,
   }
 }
 
-uint64_t TotalCompensatedFileSize(const std::vector<FileMetaData*>& files) {
-  uint64_t sum = 0;
-  for (size_t i = 0; i < files.size() && files[i]; i++) {
-    sum += files[i]->compensated_file_size;
-  }
-  return sum;
-}
-
 // Multiple two operands. If they overflow, return op1.
 uint64_t MultiplyCheckOverflow(uint64_t op1, int op2) {
   if (op1 == 0) {
index 6edd3404d444b149cd06c7a54431d51d361e8440..c1e27c4718c83261919be7255311bf9c88ff0bb3 100644 (file)
@@ -204,4 +204,7 @@ class FIFOCompactionPicker : public CompactionPicker {
   }
 };
 
+// Utility function
+extern uint64_t TotalCompensatedFileSize(const std::vector<FileMetaData*>& files);
+
 }  // namespace rocksdb
index f0b86951488473fe437937e86aac47fe7b8be041..95c77ff52cbb0e149b558a647de75dababb76085 100644 (file)
@@ -231,15 +231,6 @@ struct DBImpl::CompactionState {
   }
 };
 
-namespace {
-// Fix user-supplied options to be reasonable
-template <class T, class V>
-static void ClipToRange(T* ptr, V minvalue, V maxvalue) {
-  if (static_cast<V>(*ptr) > maxvalue) *ptr = maxvalue;
-  if (static_cast<V>(*ptr) < minvalue) *ptr = minvalue;
-}
-}  // anonymous namespace
-
 Options SanitizeOptions(const std::string& dbname,
                         const InternalKeyComparator* icmp,
                         const InternalFilterPolicy* ipolicy,
index 82c4ffc76bfe2d0b6b484f95a3cb0af29468003d..fe0f42dfcd2e0d4c9e0b5398701b5ac5073ec90c 100644 (file)
@@ -647,4 +647,11 @@ extern Options SanitizeOptions(const std::string& db,
                                const Options& src);
 extern DBOptions SanitizeOptions(const std::string& db, const DBOptions& src);
 
+// Fix user-supplied options to be reasonable
+template <class T, class V>
+static void ClipToRange(T* ptr, V minvalue, V maxvalue) {
+  if (static_cast<V>(*ptr) > maxvalue) *ptr = maxvalue;
+  if (static_cast<V>(*ptr) < minvalue) *ptr = minvalue;
+}
+
 }  // namespace rocksdb
index cd27a46e4fc28db076283248f3db1778d57385fe..7c75db0d015b1797d98790c8b63cf5e8c5cc23db 100644 (file)
@@ -301,23 +301,6 @@ class FilePicker {
 };
 }  // anonymous namespace
 
-static uint64_t TotalFileSize(const std::vector<FileMetaData*>& files) {
-  uint64_t sum = 0;
-  for (size_t i = 0; i < files.size() && files[i]; i++) {
-    sum += files[i]->fd.GetFileSize();
-  }
-  return sum;
-}
-
-static uint64_t TotalCompensatedFileSize(
-    const std::vector<FileMetaData*>& files) {
-  uint64_t sum = 0;
-  for (size_t i = 0; i < files.size() && files[i]; i++) {
-    sum += files[i]->compensated_file_size;
-  }
-  return sum;
-}
-
 Version::~Version() {
   assert(refs_ == 0);
 
@@ -666,7 +649,6 @@ void Version::AddIterators(const ReadOptions& read_options,
 }
 
 // Callback from TableCache::Get()
-namespace {
 enum SaverState {
   kNotFound,
   kFound,
@@ -674,6 +656,8 @@ enum SaverState {
   kCorrupt,
   kMerge // saver contains the current merge result (the operands)
 };
+
+namespace version_set {
 struct Saver {
   SaverState state;
   const Comparator* ucmp;
@@ -686,7 +670,7 @@ struct Saver {
   Logger* logger;
   Statistics* statistics;
 };
-}
+} // namespace version_set
 
 // Called from TableCache::Get and Table::Get when file/block in which
 // key may  exist are not there in TableCache/BlockCache respectively. In this
@@ -694,7 +678,7 @@ struct Saver {
 // IO to be  certain.Set the status=kFound and value_found=false to let the
 // caller know that key may exist but is not there in memory
 static void MarkKeyMayExist(void* arg) {
-  Saver* s = reinterpret_cast<Saver*>(arg);
+  version_set::Saver* s = reinterpret_cast<version_set::Saver*>(arg);
   s->state = kFound;
   if (s->value_found != nullptr) {
     *(s->value_found) = false;
@@ -703,7 +687,7 @@ static void MarkKeyMayExist(void* arg) {
 
 static bool SaveValue(void* arg, const ParsedInternalKey& parsed_key,
                       const Slice& v) {
-  Saver* s = reinterpret_cast<Saver*>(arg);
+  version_set::Saver* s = reinterpret_cast<version_set::Saver*>(arg);
   MergeContext* merge_contex = s->merge_context;
   std::string merge_result;  // temporary area for merge results later
 
@@ -817,7 +801,7 @@ void Version::Get(const ReadOptions& options,
   Slice user_key = k.user_key();
 
   assert(status->ok() || status->IsMergeInProgress());
-  Saver saver;
+  version_set::Saver saver;
   saver.state = status->ok()? kNotFound : kMerge;
   saver.ucmp = user_comparator_;
   saver.user_key = user_key;
index fdaa9d3410916df9a5605f4fac5bfb84eba9417b..c239bf458bbd8d81db8105c479c756a62119d2c1 100644 (file)
@@ -45,7 +45,6 @@ namespace rocksdb {
 
 extern const std::string kHashIndexPrefixesBlock;
 extern const std::string kHashIndexPrefixesMetadataBlock;
-namespace {
 
 typedef BlockBasedTableOptions::IndexType IndexType;
 
@@ -335,8 +334,6 @@ Slice CompressBlock(const Slice& raw,
   return raw;
 }
 
-}  // anonymous namespace
-
 // kBlockBasedTableMagicNumber was picked by running
 //    echo rocksdb.table.block_based | sha1sum
 // and taking the leading 64 bits.
index 4ed3b015cd3b4fae1c01a0116c5df563c00c0a49..f06dcd9fe76ecc93f7479d9c742ab9c96d0b55b2 100644 (file)
@@ -16,8 +16,6 @@
 
 namespace rocksdb {
 
-namespace {
-
 inline uint32_t Hash(const Slice& s) {
   return rocksdb::Hash(s.data(), s.size(), 0);
 }
@@ -26,8 +24,6 @@ inline uint32_t PrefixToBucket(const Slice& prefix, uint32_t num_buckets) {
   return Hash(prefix) % num_buckets;
 }
 
-
-
 // The prefix block index is simply a bucket array, with each entry pointing to
 // the blocks that span the prefixes hashed to this bucket.
 //
@@ -64,7 +60,6 @@ inline uint32_t EncodeIndex(uint32_t index) {
   return index | kBlockArrayMask;
 }
 
-
 // temporary storage for prefix information during index building
 struct PrefixRecord {
   Slice prefix;
@@ -74,8 +69,6 @@ struct PrefixRecord {
   PrefixRecord* next;
 };
 
-}  // anonymous namespace
-
 class BlockPrefixIndex::Builder {
  public:
   explicit Builder(const SliceTransform* internal_prefix_extractor)
index 9aab33ed36bfe10fdfbcdfc4ce2400d634f69ecf..611480cec025c45c65effb34902552776e296a78 100644 (file)
@@ -23,7 +23,7 @@
 #include "util/autovector.h"
 
 namespace rocksdb {
-namespace {
+namespace merger {
 typedef std::priority_queue<
           IteratorWrapper*,
           std::vector<IteratorWrapper*>,
@@ -43,7 +43,7 @@ MaxIterHeap NewMaxIterHeap(const Comparator* comparator) {
 MinIterHeap NewMinIterHeap(const Comparator* comparator) {
   return MinIterHeap(MinIteratorComparator(comparator));
 }
-}  // namespace
+}  // namespace merger
 
 const size_t kNumIterReserve = 4;
 
@@ -56,8 +56,8 @@ class MergingIterator : public Iterator {
         current_(nullptr),
         use_heap_(true),
         direction_(kForward),
-        maxHeap_(NewMaxIterHeap(comparator_)),
-        minHeap_(NewMinIterHeap(comparator_)) {
+        maxHeap_(merger::NewMaxIterHeap(comparator_)),
+        minHeap_(merger::NewMinIterHeap(comparator_)) {
     children_.resize(n);
     for (int i = 0; i < n; i++) {
       children_[i].Set(children[i]);
@@ -274,8 +274,8 @@ class MergingIterator : public Iterator {
     kReverse
   };
   Direction direction_;
-  MaxIterHeap maxHeap_;
-  MinIterHeap minHeap_;
+  merger::MaxIterHeap maxHeap_;
+  merger::MinIterHeap minHeap_;
 };
 
 void MergingIterator::FindSmallest() {
@@ -302,8 +302,8 @@ void MergingIterator::FindLargest() {
 
 void MergingIterator::ClearHeaps() {
   use_heap_ = true;
-  maxHeap_ = NewMaxIterHeap(comparator_);
-  minHeap_ = NewMinIterHeap(comparator_);
+  maxHeap_ = merger::NewMaxIterHeap(comparator_);
+  minHeap_ = merger::NewMinIterHeap(comparator_);
 }
 
 Iterator* NewMergingIterator(const Comparator* cmp, Iterator** list, int n,
index 78ae04a266abe40fd3b1390d616673eb9a075558..723adf843c2360418bb5a212108d696ea951de8d 100644 (file)
@@ -15,9 +15,6 @@
 namespace rocksdb {
 
 namespace {
-static uint32_t BloomHash(const Slice& key) {
-  return Hash(key.data(), key.size(), 0xbc9f1d34);
-}
 
 class BloomFilterPolicy : public FilterPolicy {
  private:
index 4463faf51dfdf9b44d9bbdc70bc5f7c0ac612a8f..73c2c9436269f775073b5eef953614b812806fa5 100644 (file)
@@ -14,9 +14,6 @@
 namespace rocksdb {
 
 namespace {
-static uint32_t BloomHash(const Slice& key) {
-  return Hash(key.data(), key.size(), 0xbc9f1d34);
-}
 
 uint32_t GetTotalBitsForLocality(uint32_t total_bits) {
   uint32_t num_blocks =
index 2e7d302712afff9b631c2eb5282abfa373fe1d9f..6d9bebaf821a0bba452ef0c0999e1306c1dc8982 100644 (file)
@@ -17,6 +17,10 @@ namespace rocksdb {
 
 extern uint32_t Hash(const char* data, size_t n, uint32_t seed);
 
+inline uint32_t BloomHash(const Slice& key) {
+  return Hash(key.data(), key.size(), 0xbc9f1d34);
+}
+
 inline uint32_t GetSliceHash(const Slice& s) {
   return Hash(s.data(), s.size(), 397);
 }
index 4035b2e6580cdbb0bed66451503ecb92faf0e712..06ce670f05e3ad82d6c3c812b6a78aba43741958 100644 (file)
@@ -25,7 +25,7 @@ CompactionStyle PickCompactionStyle(size_t write_buffer_size,
   // Otherwise, calculate a score based on threshold and expected value of
   // two styles, weighing reads 4X important than writes.
   int expected_levels = static_cast<int>(ceil(
-      log(target_db_size / write_buffer_size) / log(kBytesForLevelMultiplier)));
+      ::log(target_db_size / write_buffer_size) / ::log(kBytesForLevelMultiplier)));
 
   int expected_max_files_universal =
       static_cast<int>(ceil(log2(target_db_size / write_buffer_size)));
@@ -111,8 +111,8 @@ void OptimizeForLevel(int read_amplification_threshold,
                       int write_amplification_threshold,
                       uint64_t target_db_size, Options* options) {
   int expected_levels_one_level0_file =
-      static_cast<int>(ceil(log(target_db_size / options->write_buffer_size) /
-                            log(kBytesForLevelMultiplier)));
+      static_cast<int>(ceil(::log(target_db_size / options->write_buffer_size) /
+                            ::log(kBytesForLevelMultiplier)));
 
   int level0_stop_writes_trigger =
       read_amplification_threshold - expected_levels_one_level0_file;
index 065e5ca35e5bc7fd8f8585441b2a5fc40b80555c..f63c91c3e59e4370d093a588017bfb2ae89b6a36 100644 (file)
@@ -307,7 +307,7 @@ Status GeoDBImpl::searchQuadIds(const GeoPosition& position,
 
   // how many level of details to look for
   int numberOfTilesAtMaxDepth = floor((bottomRight.x - topLeft.x) / 256);
-  int zoomLevelsToRise = floor(log(numberOfTilesAtMaxDepth) / log(2));
+  int zoomLevelsToRise = floor(::log(numberOfTilesAtMaxDepth) / ::log(2));
   zoomLevelsToRise++;
   int levels = std::max(0, Detail - zoomLevelsToRise);
 
@@ -344,7 +344,7 @@ GeoDBImpl::Pixel GeoDBImpl::PositionToPixel(const GeoPosition& pos,
   double latitude = clip(pos.latitude, MinLatitude, MaxLatitude);
   double x = (pos.longitude + 180) / 360;
   double sinLatitude = sin(latitude * PI / 180);
-  double y = 0.5 - log((1 + sinLatitude) / (1 - sinLatitude)) / (4 * PI);
+  double y = 0.5 - ::log((1 + sinLatitude) / (1 - sinLatitude)) / (4 * PI);
   double mapSize = MapSize(levelOfDetail);
   double X = floor(clip(x * mapSize + 0.5, 0, mapSize - 1));
   double Y = floor(clip(y * mapSize + 0.5, 0, mapSize - 1));