- else if (zh->registerState == -1)
- logf (LOG_LOG, "Reading register using state %d pid=%ld", state,
- (long) getpid());
- else
- logf (LOG_LOG, "Register has changed state from %d to %d",
- zh->registerState, state);
- zh->registerChange = lastChange;
- if (zh->records)
- {
- zebraExplain_close (zh->zei, 0, 0);
- dict_close (zh->dict);
- sortIdx_close (zh->sortIdx);
- if (zh->isam)
- is_close (zh->isam);
- if (zh->isamc)
- isc_close (zh->isamc);
- rec_close (&zh->records);
- }
- bf_cache (zh->bfs, state ? res_get (zh->res, "shadow") : NULL);
- zh->registerState = state;
- zh->records = rec_open (zh->bfs, 0);
- if (!(zh->dict = dict_open (zh->bfs, FNAME_DICT, 40, 0)))
- return -1;
- if (!(zh->sortIdx = sortIdx_open (zh->bfs, 0)))
- return -1;
- zh->isam = NULL;
- zh->isamc = NULL;
- if (!res_get_match (zh->res, "isam", "i", NULL))
+ if (useshadow)
+ bf_cache (reg->bfs, res_get (res, "shadow"));
+ data1_set_tabpath (reg->dh, res_get(res, "profilePath"));
+ data1_set_tabroot (reg->dh, reg_path);
+ reg->recTypes = recTypes_init (reg->dh);
+ recTypes_default_handlers (reg->recTypes);
+
+ reg->zebra_maps = zebra_maps_open (res, reg_path);
+ reg->rank_classes = NULL;
+
+ reg->key_buf = 0;
+
+ reg->keys.buf_max = 0;
+ reg->keys.buf = 0;
+
+ reg->records = 0;
+ reg->dict = 0;
+ reg->sortIdx = 0;
+ reg->isams = 0;
+ reg->matchDict = 0;
+ reg->isam = 0;
+ reg->isamc = 0;
+ reg->isamd = 0;
+ reg->isamb = 0;
+ reg->zei = 0;
+ reg->matchDict = 0;
+
+ zebraRankInstall (reg, rank1_class);
+
+ recordCompression = res_get_def (res, "recordCompression", "none");
+ if (!strcmp (recordCompression, "none"))
+ record_compression = REC_COMPRESS_NONE;
+ if (!strcmp (recordCompression, "bzip2"))
+ record_compression = REC_COMPRESS_BZIP2;
+
+ if (!(reg->records = rec_open (reg->bfs, rw, record_compression)))
+ {
+ logf (LOG_WARN, "rec_open");
+ return 0;
+ }
+ if (rw)
+ {
+ reg->matchDict = dict_open (reg->bfs, GMATCH_DICT, 20, 1, 0);
+ }
+ if (!(reg->dict = dict_open (reg->bfs, FNAME_DICT, 40, rw, 0)))
+ {
+ logf (LOG_WARN, "dict_open");
+ return 0;
+ }
+ if (!(reg->sortIdx = sortIdx_open (reg->bfs, rw)))
+ {
+ logf (LOG_WARN, "sortIdx_open");
+ return 0;
+ }
+ if (res_get_match (res, "isam", "s", ISAM_DEFAULT))
+ {
+ struct ISAMS_M_s isams_m;
+ if (!(reg->isams = isams_open (reg->bfs, FNAME_ISAMS, rw,
+ key_isams_m(res, &isams_m))))
+ {
+ logf (LOG_WARN, "isams_open");
+ return 0;
+ }
+ }
+ if (res_get_match (res, "isam", "i", ISAM_DEFAULT))
+ {
+ if (!(reg->isam = is_open (reg->bfs, FNAME_ISAM, key_compare, rw,
+ sizeof (struct it_key), res)))
+ {
+ logf (LOG_WARN, "is_open");
+ return 0;
+ }
+ }
+ if (res_get_match (res, "isam", "c", ISAM_DEFAULT))
+ {
+ struct ISAMC_M_s isamc_m;
+ if (!(reg->isamc = isc_open (reg->bfs, FNAME_ISAMC,
+ rw, key_isamc_m(res, &isamc_m))))
+ {
+ logf (LOG_WARN, "isc_open");
+ return 0;
+ }
+ }
+ if (res_get_match (res, "isam", "d", ISAM_DEFAULT))
+ {
+ struct ISAMD_M_s isamd_m;
+
+ if (!(reg->isamd = isamd_open (reg->bfs, FNAME_ISAMD,
+ rw, key_isamd_m(res, &isamd_m))))
+ {
+ logf (LOG_WARN, "isamd_open");
+ return 0;
+ }
+ }
+ if (res_get_match (res, "isam", "b", ISAM_DEFAULT))
+ {
+ struct ISAMC_M_s isamc_m;
+
+ if (!(reg->isamb = isamb_open (reg->bfs, "isamb",
+ rw, key_isamc_m(res, &isamc_m), 0)))
+ {
+ logf (LOG_WARN, "isamb_open");
+ return 0;
+ }
+ }
+ if (res_get_match (res, "isam", "bc", ISAM_DEFAULT))
+ {
+ struct ISAMC_M_s isamc_m;
+
+ if (!(reg->isamb = isamb_open (reg->bfs, "isamb",
+ rw, key_isamc_m(res, &isamc_m), 1)))
+ {
+ logf (LOG_WARN, "isamb_open");
+ return 0;
+ }
+ }
+ if (res_get_match (res, "isam", "null", ISAM_DEFAULT))
+ {
+ struct ISAMC_M_s isamc_m;
+
+ if (!(reg->isamb = isamb_open (reg->bfs, "isamb",
+ rw, key_isamc_m(res, &isamc_m), -1)))
+ {
+ logf (LOG_WARN, "isamb_open");
+ return 0;
+ }
+ }
+ reg->zei = zebraExplain_open (reg->records, reg->dh,
+ res, rw, reg,
+ explain_extract);
+ if (!reg->zei)