Skip to content

Commit

Permalink
Merge pull request #75 from flightaware/nested_checks_2
Browse files Browse the repository at this point in the history
Don't re-use skiplists in nested searches.
  • Loading branch information
resuna authored Sep 21, 2017
2 parents 2293d03 + 1dcc92d commit b32f8bf
Show file tree
Hide file tree
Showing 27 changed files with 59 additions and 34 deletions.
2 changes: 1 addition & 1 deletion configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dnl to configure the system for the local environment.
# so you can encode the package version directly into the source files.
#-----------------------------------------------------------------------

AC_INIT([speedtables], [1.13.5])
AC_INIT([speedtables], [1.13.6])

#--------------------------------------------------------------------
# Call TEA_INIT as the first TEA_ macro to set up initial vars.
Expand Down
2 changes: 1 addition & 1 deletion ctable_server/configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dnl to configure the system for the local environment.
# so you can encode the package version directly into the source files.
#-----------------------------------------------------------------------

AC_INIT([ctable_server], [1.13.5])
AC_INIT([ctable_server], [1.13.6])

#--------------------------------------------------------------------
# Call TEA_INIT as the first TEA_ macro to set up initial vars.
Expand Down
2 changes: 1 addition & 1 deletion ctable_server/ctable_client.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,6 @@ proc maketable {cttpUrl sock} {
return [::sttp_buffer::table $cttpUrl]
}

package provide ctable_client 1.13.5
package provide ctable_client 1.13.6

# vim: set ts=8 sw=4 sts=4 noet :
2 changes: 1 addition & 1 deletion ctable_server/ctable_client_server.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,6 @@ namespace export split_ctable_url join_ctable_url

}

package provide ctable_net 1.13.5
package provide ctable_net 1.13.6

# vim: set ts=8 sw=4 sts=4 noet :
2 changes: 1 addition & 1 deletion ctable_server/ctable_server.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ proc serverdie {{message ""}} {

}

package provide ctable_server 1.13.5
package provide ctable_server 1.13.6

#get, set, array_get, array_get_with_nulls, exists, delete, count, foreach, sort, type, import, import_postgres_result, export, fields, fieldtype, needs_quoting, names, reset, destroy, statistics, write_tabsep, or read_tabsep

Expand Down
2 changes: 1 addition & 1 deletion ctable_server/sttp_buffer.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,6 @@ proc table {cttpUrl} {

}

package provide sttp_buffer 1.13.5
package provide sttp_buffer 1.13.6

# vim: set ts=8 sw=4 sts=4 noet :
2 changes: 1 addition & 1 deletion ctables/command-body.c-subst
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ int ${table}ObjCmd (ClientData cData, Tcl_Interp *interp, int objc, Tcl_Obj *CON
return TCL_ERROR;
}

if(ctable->searching) {
if(ctable->searches) {
Tcl_AppendResult(interp, "Can not delete from inside search.", NULL);
Tcl_SetErrorCode (interp, "speedtables", "no_delete_inside_search", NULL);
return TCL_ERROR;
Expand Down
2 changes: 1 addition & 1 deletion ctables/configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dnl to configure the system for the local environment.
# so you can encode the package version directly into the source files.
#-----------------------------------------------------------------------

AC_INIT([ctable], [1.13.5])
AC_INIT([ctable], [1.13.6])

#--------------------------------------------------------------------
# Call TEA_INIT as the first TEA_ macro to set up initial vars.
Expand Down
6 changes: 5 additions & 1 deletion ctables/ctable.h
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ struct CTableSearchFilter {
// ctable search struct - this controls everything about a search
struct CTableSearch {
struct CTable *ctable;
struct CTableSearch *previousSearch;
CTableSearchComponent *components;
CTableSearchFilter *filters;
char *pattern;
Expand Down Expand Up @@ -430,6 +431,9 @@ struct CTableSearch {
// cursor ID and structure
char *cursorName;
struct cursor *cursor;

// what index is this searching?
int searchField;
};

struct ctable_FieldInfo {
Expand Down Expand Up @@ -512,7 +516,7 @@ struct CTable {

int autoRowNumber;
int destroying;
int searching;
CTableSearch *searches;
char *nullKeyValue;
#ifdef WITH_SHARED_TABLES
int was_locked;
Expand Down
37 changes: 29 additions & 8 deletions ctables/ctable_search.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ ctable_ParseFieldList (Tcl_Interp *interp, Tcl_Obj *fieldListObj, CONST char **f
// and store the field number in the corresponding field number array.
//
// If the dash was present set the corresponding direction in the direction
// array to 0 else set it to 1.
// array to -1 else set it to 1.
//
// It is up to the caller to free the memory pointed to through the
// fieldList argument.
Expand Down Expand Up @@ -1331,6 +1331,8 @@ ctable_PerformSearch (Tcl_Interp *interp, CTable *ctable, CTableSearch *search)

int canUseHash = 1;

CTableSearch *s;

#ifdef WITH_SHARED_TABLES
int firstTime = 1;
int locked_cycle = LOST_HORIZON;
Expand Down Expand Up @@ -1532,6 +1534,17 @@ ctable_PerformSearch (Tcl_Interp *interp, CTable *ctable, CTableSearch *search)
}
}

// If we have previous searches, walk back through the previous searches to see if we're already using
// this field
for(s = search->previousSearch; s; s = s->previousSearch) {
if(s->searchField == field) {
break;
}
}
if(s) {
continue;
}

score = skipTypes[comparisonType].score;

// Prefer to avoid sort
Expand All @@ -1543,6 +1556,7 @@ ctable_PerformSearch (Tcl_Interp *interp, CTable *ctable, CTableSearch *search)

// Got a new best candidate, save the world.
skipField = field;
search->searchField = field;

skipNext = skipTypes[comparisonType].skipNext;
skipStart = skipTypes[comparisonType].skipStart;
Expand Down Expand Up @@ -1594,6 +1608,7 @@ ctable_PerformSearch (Tcl_Interp *interp, CTable *ctable, CTableSearch *search)
}
}


// if we're sorting on the field we're searching, AND we can eliminate
// the sort because we know we're walking in order, then eliminate the
// sort step
Expand Down Expand Up @@ -1936,6 +1951,10 @@ if(num_restarts == 0) fprintf(stderr, "%d: loop restart: loop_cycle=%ld; row->_r
// We only jump to this on success, so we got to the end of the loop
// or we broke out of it early
search_complete:

// We're no longer walking a skiplist, so make a note of that so it can be re-used.
search->searchField = -1;

switch (ctable_PostSearchCommonActions (interp, ctable, search)) {
case TCL_ERROR: {
finalResult = TCL_ERROR;
Expand Down Expand Up @@ -1992,7 +2011,7 @@ if(num_restarts) fprintf(stderr, "%d: Restarted search %d times\n", getpid(), nu
//
//
static int
ctable_SetupSearch (Tcl_Interp *interp, CTable *ctable, Tcl_Obj *CONST objv[], int objc, CTableSearch *search, int indexField, int nested_search) {
ctable_SetupSearch (Tcl_Interp *interp, CTable *ctable, Tcl_Obj *CONST objv[], int objc, CTableSearch *search, int indexField, CTableSearch *previous_search) {
int i;
int searchTerm = 0;
CONST char **fieldNames = ctable->creator->fieldNames;
Expand Down Expand Up @@ -2035,6 +2054,7 @@ ctable_SetupSearch (Tcl_Interp *interp, CTable *ctable, Tcl_Obj *CONST objv[], i

// initialize search control structure
search->ctable = ctable;
search->previousSearch = previous_search;
search->action = CTABLE_SEARCH_ACTION_NONE;
search->nComponents = 0;
search->components = NULL;
Expand Down Expand Up @@ -2070,6 +2090,7 @@ ctable_SetupSearch (Tcl_Interp *interp, CTable *ctable, Tcl_Obj *CONST objv[], i
search->offsetLimit = search->offset + search->limit;
search->cursorName = NULL;
search->cursor = NULL;
search->searchField = -1;

// Give each search a unique non-zero sequence number
if(++staticSequence == 0) ++staticSequence;
Expand Down Expand Up @@ -2277,7 +2298,7 @@ ctable_SetupSearch (Tcl_Interp *interp, CTable *ctable, Tcl_Obj *CONST objv[], i
Tcl_SetErrorCode (interp, "speedtables", "no_delete_with_cursors", NULL);
return TCL_ERROR;
}
if(nested_search) {
if(previous_search) {
Tcl_AppendResult(interp, "Can not delete in nested search.", NULL);
Tcl_SetErrorCode (interp, "speedtables", "no_delete_inside_search", NULL);
return TCL_ERROR;
Expand Down Expand Up @@ -2637,12 +2658,12 @@ ctable_SetupAndPerformSearch (Tcl_Interp *interp, Tcl_Obj *CONST objv[], int obj
#endif

// flag this search in progress
int nested_search = ctable->searching;
ctable->searching = 1;
CTableSearch *previous_search = ctable->searches;
ctable->searches = &search;

result = ctable_SetupSearch (interp, ctable, objv, objc, &search, indexField, nested_search);
result = ctable_SetupSearch (interp, ctable, objv, objc, &search, indexField, previous_search);
if (result == TCL_ERROR) {
ctable->searching = nested_search;
ctable->searches = previous_search;
return TCL_ERROR;
}

Expand All @@ -2661,7 +2682,7 @@ ctable_SetupAndPerformSearch (Tcl_Interp *interp, Tcl_Obj *CONST objv[], int obj

ctable_TeardownSearch (&search);

ctable->searching = nested_search;
ctable->searches = previous_search;

#ifdef CTABLES_CLOCK
if (ctable->performanceCallbackEnable) {
Expand Down
2 changes: 1 addition & 1 deletion ctables/template.c-subst
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ ${table}MetaObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj
ctable->count = 0;
ctable->autoRowNumber = 0;
ctable->destroying = 0;
ctable->searching = 0;
ctable->searches = NULL;
ctable->nullKeyValue = NULL;
ctable->cursors = NULL;
#ifdef WITH_SHARED_TABLES
Expand Down
2 changes: 1 addition & 1 deletion stapi/client/cass.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -1236,6 +1236,6 @@ namespace eval ::stapi {
}
}

package provide st_client_cassandra 1.13.5
package provide st_client_cassandra 1.13.6

# vim: set ts=8 sw=4 sts=4 noet :
2 changes: 1 addition & 1 deletion stapi/client/client.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,6 @@ namespace eval ::stapi {
register package connect_package
}

package provide st_client 1.13.5
package provide st_client 1.13.6

# vim: set ts=8 sw=4 sts=4 noet :
2 changes: 1 addition & 1 deletion stapi/client/extend.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ namespace eval ::stapi {
namespace import ::stapi::extend::*
}

package provide stapi_extend 1.13.5
package provide stapi_extend 1.13.6


# vim: set ts=8 sw=4 sts=4 noet :
2 changes: 1 addition & 1 deletion stapi/client/pgsql.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,6 @@ namespace eval ::stapi {
}
}

package provide st_client_postgres 1.13.5
package provide st_client_postgres 1.13.6

# vim: set ts=8 sw=4 sts=4 noet :
2 changes: 1 addition & 1 deletion stapi/client/shared.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,6 @@ namespace eval ::stapi {
}
}

package provide st_shared 1.13.5
package provide st_shared 1.13.6

# vim: set ts=8 sw=4 sts=4 noet :
2 changes: 1 addition & 1 deletion stapi/client/uri.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ namespace eval stapi {

}

package provide st_client_uri 1.13.5
package provide st_client_uri 1.13.6

# vim: set ts=8 sw=4 sts=4 noet :
2 changes: 1 addition & 1 deletion stapi/configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dnl to configure the system for the local environment.
# so you can encode the package version directly into the source files.
#-----------------------------------------------------------------------

AC_INIT([stapi], [1.13.5])
AC_INIT([stapi], [1.13.6])

#--------------------------------------------------------------------
# Call TEA_INIT as the first TEA_ macro to set up initial vars.
Expand Down
2 changes: 1 addition & 1 deletion stapi/copy.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -167,5 +167,5 @@ namespace eval ::stapi {
}
}

package provide st_postgres 1.13.5
package provide st_postgres 1.13.6

2 changes: 1 addition & 1 deletion stapi/debug.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ namespace eval ::stapi {
}
}

package provide st_debug 1.13.5
package provide st_debug 1.13.6
2 changes: 1 addition & 1 deletion stapi/display/display.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -2576,5 +2576,5 @@ catch { ::itcl::delete class ::STDisplayField_boolean }
} ; ## ::itcl::class ::STDisplayField_boolean
package provide st_display 1.13.5
package provide st_display 1.13.6
2 changes: 1 addition & 1 deletion stapi/display/test.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ proc stapi_display_test {} {
}
}

package provide st_display_test 1.13.5
package provide st_display_test 1.13.6
2 changes: 1 addition & 1 deletion stapi/pgsql.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -379,4 +379,4 @@ namespace eval ::stapi {
}
}

package provide st_postgres 1.13.5
package provide st_postgres 1.13.6
2 changes: 1 addition & 1 deletion stapi/server/lock.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,4 @@ namespace eval ::stapi {
}
}

package provide st_locks 1.13.5
package provide st_locks 1.13.6
2 changes: 1 addition & 1 deletion stapi/server/server.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -1279,4 +1279,4 @@ namespace eval ::stapi {
}
}
package provide st_server 1.13.5
package provide st_server 1.13.6
2 changes: 1 addition & 1 deletion stapi/stapi.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

package require st_client

package provide stapi 1.13.5
package provide stapi 1.13.6

2 changes: 1 addition & 1 deletion update_ver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# This script simplifies the process of incrementing all version numbers for a new release.

NEWVER="1.13.5"
NEWVER="1.13.6"

perl -p -i -e "s/^(AC_INIT\\(\\[[a-z_]+\\],) \\[[0-9.]+\\]/\\1 \\[$NEWVER\\]/" configure.in ctables/configure.in stapi/configure.in ctable_server/configure.in

Expand Down

0 comments on commit b32f8bf

Please sign in to comment.