From 4b5d954866ce9dac8bb349ff8ad2e8bc5928b709 Mon Sep 17 00:00:00 2001
From: Dmitry Simonenko <pmwkaa@gmail.com>
Date: Fri, 11 Oct 2013 18:38:10 +0400
Subject: [PATCH] opentar-56: big files and Delete v1.3 support

---
 client/tarantar/cursor.c   |  9 ++++++---
 client/tarantar/indexate.c | 10 ++++++++--
 client/tarantar/key.h      |  4 ++--
 client/tarantar/snapshot.c |  8 +++++---
 client/tarantar/space.c    |  6 +++---
 client/tarantar/space.h    |  2 +-
 6 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/client/tarantar/cursor.c b/client/tarantar/cursor.c
index fd1e3e95ea..8abd26c6f1 100644
--- a/client/tarantar/cursor.c
+++ b/client/tarantar/cursor.c
@@ -44,12 +44,12 @@ ts_cursor_open(struct ts_cursor *c, struct ts_key *k)
 	}
 	rc = tnt_log_seek(&c->current, k->offset);
 	if (rc == -1) {
-		printf("failed to seek for: %s:%d\n", c->r->file, k->offset);
+		printf("failed to seek for: %s:%"PRIu64"\n", c->r->file, k->offset);
 		tnt_log_close(&c->current);
 		return -1;
 	}
 	if (tnt_log_next(&c->current) == NULL) {
-		printf("failed to read: %s:%d\n", c->r->file, k->offset);
+		printf("failed to read: %s:%"PRIu64"\n", c->r->file, k->offset);
 		tnt_log_close(&c->current);
 		return -1;
 	}
@@ -69,9 +69,12 @@ ts_cursor_tuple(struct ts_cursor *c)
 		case TNT_OP_INSERT:
 			t = &rp->r.insert.t;
 			break;
+		case TNT_OP_DELETE_1_3:
+			t = &rp->r.del_1_3.t;
+			return t;
 		case TNT_OP_DELETE:
 			t = &rp->r.del.t;
-			return 0;
+			return t;
 		case TNT_OP_UPDATE:
 			assert(0);
 			break;
diff --git a/client/tarantar/indexate.c b/client/tarantar/indexate.c
index 0e4033057c..0899cd8d66 100644
--- a/client/tarantar/indexate.c
+++ b/client/tarantar/indexate.c
@@ -57,7 +57,7 @@ search_equal(const struct ts_key *a,
 }
 
 static int
-snapshot_process_row(struct ts_spaces *s, int fileid, int offset,
+snapshot_process_row(struct ts_spaces *s, int fileid, uint64_t offset,
                      struct tnt_iter_storage *is,
                      struct tnt_stream_snapshot *ss)
 {
@@ -163,7 +163,8 @@ snapdir_process(void)
 }
 
 static int
-xlog_process_row(struct ts_spaces *s, int fileid, int offset, struct tnt_request *r)
+xlog_process_row(struct ts_spaces *s, int fileid, uint64_t offset,
+                 struct tnt_request *r)
 {
 	/* validate operation */
 	uint32_t ns = 0;
@@ -178,6 +179,10 @@ xlog_process_row(struct ts_spaces *s, int fileid, int offset, struct tnt_request
 		ns = r->r.del.h.ns;
 		t = &r->r.del.t;
 		break;
+	case TNT_OP_DELETE_1_3:
+		ns = r->r.del_1_3.h.ns;
+		t = &r->r.del_1_3.t;
+		break;
 	case TNT_OP_UPDATE:
 		ns = r->r.update.h.ns;
 		t = &r->r.update.t;
@@ -214,6 +219,7 @@ xlog_process_row(struct ts_spaces *s, int fileid, int offset, struct tnt_request
 		}
 		ts_oomcheck();
 		break;
+	case TNT_OP_DELETE_1_3:
 	case TNT_OP_DELETE: {
 		pos = mh_pk_get(space->index, &node, space);
 		assert(pos != mh_end(space->index));
diff --git a/client/tarantar/key.h b/client/tarantar/key.h
index ebdca6c545..7660e3c9af 100644
--- a/client/tarantar/key.h
+++ b/client/tarantar/key.h
@@ -4,8 +4,8 @@
 #define TS_KEY_WITH_DATA 1
 
 struct ts_key {
-	uint32_t file;
-	uint32_t offset;
+	uint16_t file;
+	uint64_t offset;
 	uint8_t flags;
 	unsigned char key[];
 } __attribute__((packed));
diff --git a/client/tarantar/snapshot.c b/client/tarantar/snapshot.c
index 61958729a7..83ddc10b62 100644
--- a/client/tarantar/snapshot.c
+++ b/client/tarantar/snapshot.c
@@ -88,11 +88,11 @@ ts_snapshot_xfer(FILE *snapshot, struct tnt_log *current,
 {
 	int rc = tnt_log_seek(current, k->offset);
 	if (rc == -1) {
-		printf("failed to seek for: %s:%d\n", r->file, k->offset);
+		printf("failed to seek for: %s:%"PRIu64"\n", r->file, k->offset);
 		return -1;
 	}
 	if (tnt_log_next(current) == NULL) {
-		printf("failed to read: %s:%d\n", r->file, k->offset);
+		printf("failed to read: %s:%"PRIu64"\n", r->file, k->offset);
 		return -1;
 	}
 
@@ -106,8 +106,10 @@ ts_snapshot_xfer(FILE *snapshot, struct tnt_log *current,
 		case TNT_OP_INSERT:
 			t = &rp->r.insert.t;
 			break;
+		case TNT_OP_DELETE_1_3:
 		case TNT_OP_DELETE:
-			t = &rp->r.del.t;
+			/* skip */
+			//t = &rp->r.del.t;
 			return 0;
 		case TNT_OP_UPDATE:
 			assert(0);
diff --git a/client/tarantar/space.c b/client/tarantar/space.c
index 82ecbc9270..dc28d7c49b 100644
--- a/client/tarantar/space.c
+++ b/client/tarantar/space.c
@@ -252,7 +252,7 @@ int ts_space_fill(struct ts_spaces *s, struct ts_options *opts)
 
 static inline struct ts_key*
 ts_space_keyalloc_sha(struct ts_space *s, struct tnt_tuple *t, int fileid,
-                      int offset, int attach)
+                      uint64_t offset, int attach)
 {
 	int size = sizeof(struct ts_key) + s->key_size;
 	if (attach)
@@ -297,7 +297,7 @@ ts_space_keyalloc_sha(struct ts_space *s, struct tnt_tuple *t, int fileid,
 
 static inline struct ts_key*
 ts_space_keyalloc_sparse(struct ts_space *s, struct tnt_tuple *t, int fileid,
-                         int offset, int attach)
+                         uint64_t offset, int attach)
 {
 	int size = sizeof(struct ts_key) + s->key_size;
 	if (attach)
@@ -341,7 +341,7 @@ ts_space_keyalloc_sparse(struct ts_space *s, struct tnt_tuple *t, int fileid,
 
 struct ts_key*
 ts_space_keyalloc(struct ts_space *s, struct tnt_tuple *t, int fileid,
-                  int offset, int attach)
+                  uint64_t offset, int attach)
 {
 	struct ts_key *k = NULL;
 	switch (s->c) {
diff --git a/client/tarantar/space.h b/client/tarantar/space.h
index a338b9101c..44412ee246 100644
--- a/client/tarantar/space.h
+++ b/client/tarantar/space.h
@@ -48,7 +48,7 @@ int ts_space_fill(struct ts_spaces *s, struct ts_options *opts);
 
 struct ts_key*
 ts_space_keyalloc(struct ts_space *s, struct tnt_tuple *t, int fileid,
-                  int offset, int attach);
+                  uint64_t offset, int attach);
 
 void
 ts_space_keyfree(struct ts_space *s, struct ts_key *k);
-- 
GitLab