Permalink
Browse files

Use BDELTA_GLOBAL as a flag, instead of BDELTA_LOCAL. Also, fix BDelt…

…a's Python wrapper for flag handling.
  • Loading branch information...
1 parent fed7950 commit 09444d6766214f98807a18f3411d1cc3327b1ede @jjwhitney committed Jan 13, 2012
Showing with 26 additions and 18 deletions.
  1. +10 −10 src/bdelta.cpp
  2. +1 −1 src/bdelta.h
  3. +11 −4 src/bdelta.pyx
  4. +4 −3 src/libbdelta.cpp
View
@@ -62,16 +62,16 @@ int main(int argc, char **argv) {
// 161-180 947 953 967 971 977 983 991 997
int seq[] = {503, 127, 31, 7, 5, 3, -31, 31, 7, 5, 3, -7, 2};
- my_pass(b, 997, 1994, BDELTA_LOCAL);
- my_pass(b, 503, 1006, BDELTA_LOCAL);
- my_pass(b, 127, 254, BDELTA_LOCAL);
- my_pass(b, 31, 62, BDELTA_LOCAL);
- my_pass(b, 7, 14, BDELTA_LOCAL);
- my_pass(b, 5, 10, BDELTA_LOCAL);
- my_pass(b, 3, 6, BDELTA_LOCAL);
- my_pass(b, 13, 26, 0);
- my_pass(b, 7, 14, BDELTA_LOCAL);
- my_pass(b, 5, 10, BDELTA_LOCAL);
+ my_pass(b, 997, 1994, 0);
+ my_pass(b, 503, 1006, 0);
+ my_pass(b, 127, 254, 0);
+ my_pass(b, 31, 62, 0);
+ my_pass(b, 7, 14, 0);
+ my_pass(b, 5, 10, 0);
+ my_pass(b, 3, 6, 0);
+ my_pass(b, 13, 26, BDELTA_GLOBAL);
+ my_pass(b, 7, 14, 0);
+ my_pass(b, 5, 10, 0);
nummatches = bdelta_numMatches(b);
View
@@ -43,7 +43,7 @@ int bdelta_getError(BDelta_Instance *b);
void bdelta_showMatches(BDelta_Instance *b);
// Flags for bdelta_pass()
-#define BDELTA_LOCAL 1
+#define BDELTA_GLOBAL 1
#define BDELTA_SIDES_ORDERED 2
// Flags for bdelta_clean_matches()
View
@@ -8,10 +8,10 @@ cdef extern from "bdelta.h":
unsigned tokenSize)
void bdelta_done_alg(BDelta_Instance *b)
- void bdelta_pass(BDelta_Instance *b, unsigned blockSize, unsigned minMatchSize, bint local)
+ void bdelta_pass(BDelta_Instance *b, unsigned blockSize, unsigned minMatchSize, unsigned maxHoleSize, unsigned flags)
void bdelta_swap_inputs(BDelta_Instance *b)
- void bdelta_clean_matches(BDelta_Instance *b, int removeOverlap)
+ void bdelta_clean_matches(BDelta_Instance *b, unsigned flags)
unsigned bdelta_numMatches(BDelta_Instance *b)
@@ -21,6 +21,12 @@ cdef extern from "bdelta.h":
int bdelta_getError(BDelta_Instance *b)
void bdelta_showMatches(BDelta_Instance *b)
+ cdef enum PassFlags:
+ BDELTA_GLOBAL,
+ BDELTA_SIDES_ORDERED
+ cdef enum CleanFlags:
+ BDELTA_REMOVE_OVERLAP
+
cdef void *readCallback(void *handle, void *buf, unsigned place, unsigned num):
cdef char *str = <bytes>handle
return str + ((place + 1) * 2);
@@ -39,8 +45,9 @@ cdef class BDelta:
self.str2 = None
bdelta_done_alg(self._b)
- def b_pass(self, blockSize, minMatchSize, local):
- bdelta_pass(self._b, blockSize, minMatchSize, local)
+ def b_pass(self, blockSize, minMatchSize, maxHoleSize, globalScope = False, sidesOrdered = False):
+ bdelta_pass(self._b, blockSize, minMatchSize, maxHoleSize,
+ (BDELTA_GLOBAL if globalScope else 0) | (BDELTA_SIDES_ORDERED if sidesOrdered else 0))
def matches(self):
cdef unsigned p1, p2, num
View
@@ -410,7 +410,9 @@ void bdelta_pass(BDelta_Instance *b, unsigned blocksize, unsigned minMatchSize,
get_unused_blocks(unused2, &numunused2);
//std::sort(unused2, unused2 + numunused2, comparemrp2);
- if (flags & BDELTA_LOCAL) {
+ if (flags & BDELTA_GLOBAL)
+ bdelta_pass_2(b, blocksize, minMatchSize, unused, numunused, unused2, numunused2);
+ else {
std::sort(unused, unused + numunused, comparemrp2);
for (unsigned i = 0; i < numunused; ++i) {
UnusedRange u1 = unused[i], u2 = unused2[i];
@@ -419,8 +421,7 @@ void bdelta_pass(BDelta_Instance *b, unsigned blocksize, unsigned minMatchSize,
if (! (flags & BDELTA_SIDES_ORDERED) || (next(u1.ml) == u1.mr))
bdelta_pass_2(b, blocksize, minMatchSize, &u1, 1, &u2, 1);
}
- } else
- bdelta_pass_2(b, blocksize, minMatchSize, unused, numunused, unused2, numunused2);
+ }
if (verbose) printf("pass (blocksize: %d, matches: %zu)\n", blocksize, b->matches.size());

0 comments on commit 09444d6

Please sign in to comment.