aa973757572023a6df9e84bddd65ff0a98c82375
kent
  Tue Feb 26 11:34:17 2013 -0800
Adding bptKeyAtPos and bptStringKeyAtPos methods so can go from a chromosome index back to a chromosome name quickly without loading all the chromosomes.
diff --git src/inc/bPlusTree.h src/inc/bPlusTree.h
index cb59fb1..a177aa5 100644
--- src/inc/bPlusTree.h
+++ src/inc/bPlusTree.h
@@ -77,30 +77,39 @@
 boolean bptFileFind(struct bptFile *bpt, void *key, int keySize, void *val, int valSize);
 /* Find value associated with key.  Return TRUE if it's found. 
 *  Parameters:
 *     bpt - file handle returned by bptFileOpen
 *     key - pointer to key string
 *     keySize - size of key.  Normally just strlen(key)
 *     val - pointer to where to put retrieved value
 *     valSize - size of memory buffer that will hold val.  Should match bpt->valSize.
 */
 
 void bptFileTraverse(struct bptFile *bpt, void *context,
     void (*callback)(void *context, void *key, int keySize, void *val, int valSize) );
 /* Traverse bPlusTree on file, calling supplied callback function at each
  * leaf item. */
 
+void bptKeyAtPos(struct bptFile *bpt, bits64 itemPos, void *result);
+/* Fill in result with the key at given itemPos.  For first piece of data itemPos is 0 
+ * and for last piece is bpt->itemCount - 1.  Result must be at least bpt->keySize.  
+ * If result is a string it won't be zero terminated
+ * by this routine.  Use bptStringKeyAtPos instead. */
+
+void bptStringKeyAtPos(struct bptFile *bpt, bits64 itemPos, char *result, int maxResultSize);
+/* Fill in result with the key at given itemPos.  The maxResultSize should be 1+bpt->keySize
+ * to accommodate zero termination of string. */
 
 void bptFileCreate(
 	void *itemArray, 	/* Sorted array of things to index. */
 	int itemSize, 		/* Size of each element in array. */
 	bits64 itemCount, 	/* Number of elements in array. */
 	bits32 blockSize,	/* B+ tree block size - # of children for each node. */
 	void (*fetchKey)(const void *va, char *keyBuf),  /* Given item, copy key to keyBuf */ 
 	bits32 keySize,					 /* Size of key */
 	void* (*fetchVal)(const void *va), 		 /* Given item, return pointer to value */
 	bits32 valSize, 				 /* Size of value */
 	char *fileName);                                 /* Name of output file. */
 /* Create a b+ tree index file from a sorted array. */
 
 void bptFileBulkIndexToOpenFile(void *itemArray, int itemSize, bits64 itemCount, bits32 blockSize,
 	void (*fetchKey)(const void *va, char *keyBuf), bits32 keySize,