You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ag...@apache.org on 2018/10/01 04:19:49 UTC
[arrow] 01/01: remove unused mempool
This is an automated email from the ASF dual-hosted git repository.
agrove pushed a commit to branch remove_mem_pool
in repository https://gitbox.apache.org/repos/asf/arrow.git
commit 1246ba3e0291273ad363294d71ee87c64d4e4b68
Author: Andy Grove <an...@gmail.com>
AuthorDate: Sun Sep 30 22:19:25 2018 -0600
remove unused mempool
---
rust/src/lib.rs | 1 -
rust/src/memory_pool.rs | 91 -------------------------------------------------
2 files changed, 92 deletions(-)
diff --git a/rust/src/lib.rs b/rust/src/lib.rs
index d498341..aea6952 100644
--- a/rust/src/lib.rs
+++ b/rust/src/lib.rs
@@ -31,6 +31,5 @@ pub mod builder;
pub mod datatypes;
pub mod error;
pub mod memory;
-pub mod memory_pool;
pub mod record_batch;
pub mod util;
diff --git a/rust/src/memory_pool.rs b/rust/src/memory_pool.rs
deleted file mode 100644
index 33f3a62..0000000
--- a/rust/src/memory_pool.rs
+++ /dev/null
@@ -1,91 +0,0 @@
-// 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.
-
-use error::Result;
-use memory::{allocate_aligned, free_aligned, reallocate};
-
-/// Memory pool for allocating memory. It's also responsible for tracking memory usage.
-pub trait MemoryPool {
- /// Allocate memory.
- /// The implementation should ensures that allocated memory is aligned.
- fn allocate(&self, size: usize) -> Result<*mut u8>;
-
- /// Reallocate memory.
- /// If the implementation doesn't support reallocating aligned memory, it allocates new memory
- /// and copied old memory to it.
- fn reallocate(&self, old_size: usize, new_size: usize, pointer: *const u8)
- -> Result<*const u8>;
-
- /// Free memory.
- fn free(&self, ptr: *const u8);
-}
-
-/// Implementation of memory pool using libc api.
-#[allow(dead_code)]
-struct LibcMemoryPool;
-
-impl MemoryPool for LibcMemoryPool {
- fn allocate(&self, size: usize) -> Result<*mut u8> {
- allocate_aligned(size as i64)
- }
-
- fn reallocate(
- &self,
- old_size: usize,
- new_size: usize,
- pointer: *const u8,
- ) -> Result<*const u8> {
- reallocate(old_size, new_size, pointer)
- }
-
- fn free(&self, ptr: *const u8) {
- free_aligned(ptr)
- }
-}
-
-#[cfg(test)]
-mod tests {
- use super::*;
-
- const ALIGNMENT: usize = 64;
-
- #[test]
- fn test_allocate() {
- let memory_pool = LibcMemoryPool {};
-
- for _ in 0..10 {
- let p = memory_pool.allocate(1024).unwrap();
- // make sure this is 64-byte aligned
- assert_eq!(0, (p as usize) % ALIGNMENT);
- memory_pool.free(p);
- }
- }
-
- #[test]
- fn test_reallocate() {
- let memory_pool = LibcMemoryPool {};
-
- for _ in 0..10 {
- let p1 = memory_pool.allocate(1024).unwrap();
- let p2 = memory_pool.reallocate(1024, 2048, p1).unwrap();
- // make sure this is 64-byte aligned
- assert_eq!(0, (p1 as usize) % ALIGNMENT);
- assert_eq!(0, (p2 as usize) % ALIGNMENT);
- memory_pool.free(p2);
- }
- }
-}