Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
T
titan
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fangzongwu
titan
Commits
f3954335
Commit
f3954335
authored
May 02, 2019
by
Yi Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove titan_c.h
Signed-off-by:
Yi Wu
<
yiwu@pingcap.com
>
parent
0d9b1f79
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
0 additions
and
234 deletions
+0
-234
CMakeLists.txt
CMakeLists.txt
+0
-1
titan_c.h
include/titan/titan_c.h
+0
-115
titan_c.cc
src/titan_c.cc
+0
-118
No files found.
CMakeLists.txt
View file @
f3954335
...
...
@@ -70,7 +70,6 @@ set(SOURCES
src/options.cc
src/table_builder.cc
src/table_factory.cc
src/titan_c.cc
src/util.cc
src/version.cc
src/version_edit.cc
...
...
include/titan/titan_c.h
deleted
100644 → 0
View file @
0d9b1f79
/*
C bindings for TitanDB. May be useful as a stable ABI that can be
used by programs that keep rocksdb in a shared library, or for
a JNI api.
Does not support:
. getters for the option types
. custom comparators that implement key shortening
. capturing post-write-snapshot
. custom iter, db, env, cache implementations using just the C bindings
Some conventions:
(1) We expose just opaque struct pointers and functions to clients.
This allows us to change internal representations without having to
recompile clients.
(2) For simplicity, there is no equivalent to the Slice type. Instead,
the caller has to pass the pointer and length as separate
arguments.
(3) Errors are represented by a null-terminated c string. NULL
means no error. All operations that can raise an error are passed
a "char** errptr" as the last argument. One of the following must
be true on entry:
*errptr == NULL
*errptr points to a malloc()ed null-terminated error message
On success, a leveldb routine leaves *errptr unchanged.
On failure, leveldb frees the old value of *errptr and
set *errptr to a malloc()ed error message.
(4) Bools have the type unsigned char (0 == false; rest == true)
(5) All of the pointer arguments must be non-NULL.
*/
#ifndef ROCKSDB_TITAN_C_H
#define ROCKSDB_TITAN_C_H
#pragma once
#ifdef _WIN32
#ifdef ROCKSDB_DLL
#ifdef ROCKSDB_LIBRARY_EXPORTS
#define ROCKSDB_LIBRARY_API __declspec(dllexport)
#else
#define ROCKSDB_LIBRARY_API __declspec(dllimport)
#endif
#else
#define ROCKSDB_LIBRARY_API
#endif
#else
#define ROCKSDB_LIBRARY_API
#endif
#ifdef __cplusplus
extern
"C"
{
#endif
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
#include "rocksdb/c.h"
/* Exported types */
// TitanDB
typedef
struct
titandb_options_t
titandb_options_t
;
extern
ROCKSDB_LIBRARY_API
rocksdb_t
*
titandb_open
(
const
titandb_options_t
*
options
,
const
char
*
name
,
char
**
errptr
);
extern
ROCKSDB_LIBRARY_API
titandb_options_t
*
titandb_options_create
();
extern
ROCKSDB_LIBRARY_API
void
titandb_options_destroy
(
titandb_options_t
*
);
extern
ROCKSDB_LIBRARY_API
void
titandb_options_set_rocksdb
(
titandb_options_t
*
options
,
rocksdb_options_t
*
rocksdb
);
extern
ROCKSDB_LIBRARY_API
void
titandb_options_set_dirname
(
titandb_options_t
*
options
,
const
char
*
name
);
extern
ROCKSDB_LIBRARY_API
void
titandb_options_set_min_blob_size
(
titandb_options_t
*
options
,
uint64_t
size
);
extern
ROCKSDB_LIBRARY_API
void
titandb_options_set_blob_file_compression
(
titandb_options_t
*
options
,
int
compression
);
extern
ROCKSDB_LIBRARY_API
void
titandb_options_set_blob_cache
(
titandb_options_t
*
options
,
rocksdb_cache_t
*
blob_cache
);
extern
ROCKSDB_LIBRARY_API
void
titandb_options_set_disable_background_gc
(
titandb_options_t
*
options
,
unsigned
char
disable
);
extern
ROCKSDB_LIBRARY_API
void
titandb_options_set_max_gc_batch_size
(
titandb_options_t
*
options
,
uint64_t
size
);
extern
ROCKSDB_LIBRARY_API
void
titandb_options_set_min_gc_batch_size
(
titandb_options_t
*
options
,
uint64_t
size
);
extern
ROCKSDB_LIBRARY_API
void
titandb_options_set_blob_file_discardable_ratio
(
titandb_options_t
*
options
,
float
ratio
);
extern
ROCKSDB_LIBRARY_API
void
titandb_options_set_sample_file_size_ratio
(
titandb_options_t
*
options
,
float
ratio
);
extern
ROCKSDB_LIBRARY_API
void
titandb_options_set_merge_small_file_threshold
(
titandb_options_t
*
options
,
uint64_t
size
);
#ifdef __cplusplus
}
/* end extern "C" */
#endif
#endif // ROCKSDB_TITAN_C_H
src/titan_c.cc
deleted
100644 → 0
View file @
0d9b1f79
#include "rocksdb/utilities/titan_c.h"
#include "rocksdb/db.h"
#include "titan/db.h"
using
rocksdb
::
Cache
;
using
rocksdb
::
CompressionType
;
using
rocksdb
::
DB
;
using
rocksdb
::
Options
;
using
rocksdb
::
Status
;
using
rocksdb
::
titandb
::
TitanDB
;
using
rocksdb
::
titandb
::
TitanOptions
;
extern
"C"
{
struct
rocksdb_t
{
DB
*
rep
;
};
struct
rocksdb_options_t
{
Options
rep
;
};
struct
rocksdb_cache_t
{
std
::
shared_ptr
<
Cache
>
rep
;
};
struct
titandb_options_t
{
TitanOptions
rep
;
};
static
bool
SaveError
(
char
**
errptr
,
const
Status
&
s
)
{
assert
(
errptr
!=
nullptr
);
if
(
s
.
ok
())
{
return
false
;
}
else
if
(
*
errptr
==
nullptr
)
{
*
errptr
=
strdup
(
s
.
ToString
().
c_str
());
}
else
{
// TODO(sanjay): Merge with existing error?
// This is a bug if *errptr is not created by malloc()
free
(
*
errptr
);
*
errptr
=
strdup
(
s
.
ToString
().
c_str
());
}
return
true
;
}
rocksdb_t
*
titandb_open
(
const
titandb_options_t
*
options
,
const
char
*
name
,
char
**
errptr
)
{
TitanDB
*
db
;
if
(
SaveError
(
errptr
,
TitanDB
::
Open
(
options
->
rep
,
name
,
&
db
)))
{
return
nullptr
;
}
rocksdb_t
*
result
=
new
rocksdb_t
;
result
->
rep
=
db
;
return
result
;
}
titandb_options_t
*
titandb_options_create
()
{
return
new
titandb_options_t
;
}
void
titandb_options_destroy
(
titandb_options_t
*
options
)
{
delete
options
;
}
void
titandb_options_set_rocksdb
(
titandb_options_t
*
options
,
rocksdb_options_t
*
rocksdb
)
{
options
->
rep
=
TitanOptions
(
rocksdb
->
rep
);
}
void
titandb_options_set_dirname
(
titandb_options_t
*
options
,
const
char
*
name
)
{
options
->
rep
.
dirname
=
name
;
}
void
titandb_options_set_min_blob_size
(
titandb_options_t
*
options
,
uint64_t
size
)
{
options
->
rep
.
min_blob_size
=
size
;
}
void
titandb_options_set_blob_file_compression
(
titandb_options_t
*
options
,
int
compression
)
{
options
->
rep
.
blob_file_compression
=
static_cast
<
CompressionType
>
(
compression
);
}
void
titandb_options_set_blob_cache
(
titandb_options_t
*
options
,
rocksdb_cache_t
*
blob_cache
)
{
if
(
blob_cache
)
{
options
->
rep
.
blob_cache
=
blob_cache
->
rep
;
}
else
{
options
->
rep
.
blob_cache
.
reset
();
}
}
void
titandb_options_set_disable_background_gc
(
titandb_options_t
*
options
,
unsigned
char
disable
)
{
options
->
rep
.
disable_background_gc
=
disable
;
}
void
titandb_options_set_max_gc_batch_size
(
titandb_options_t
*
options
,
uint64_t
size
)
{
options
->
rep
.
max_gc_batch_size
=
size
;
}
void
titandb_options_set_min_gc_batch_size
(
titandb_options_t
*
options
,
uint64_t
size
)
{
options
->
rep
.
min_gc_batch_size
=
size
;
}
void
titandb_options_set_blob_file_discardable_ratio
(
titandb_options_t
*
options
,
float
ratio
)
{
options
->
rep
.
blob_file_discardable_ratio
=
ratio
;
}
void
titandb_options_set_sample_file_size_ratio
(
titandb_options_t
*
options
,
float
ratio
)
{
options
->
rep
.
sample_file_size_ratio
=
ratio
;
}
void
titandb_options_set_merge_small_file_threshold
(
titandb_options_t
*
options
,
uint64_t
size
)
{
options
->
rep
.
merge_small_file_threshold
=
size
;
}
}
// end extern "C"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment