private void CreateReduceKeysStatusTable(Session session, JET_DBID dbid) { JET_TABLEID tableid; Api.JetCreateTable(session, dbid, "reduce_keys_status", 1, 80, out tableid); JET_COLUMNID columnid; Api.JetAddColumn(session, tableid, "id", new JET_COLUMNDEF { coltyp = JET_coltyp.Long, grbit = ColumndefGrbit.ColumnFixed | ColumndefGrbit.ColumnAutoincrement | ColumndefGrbit.ColumnNotNULL }, null, 0, out columnid); Api.JetAddColumn(session, tableid, "view", new JET_COLUMNDEF { cbMax = 2048, coltyp = JET_coltyp.LongText, cp = JET_CP.Unicode, grbit = SchemaCreator.ColumnNotNullIfOnHigherThanWindowsXp() }, null, 0, out columnid); Api.JetAddColumn(session, tableid, "reduce_key", new JET_COLUMNDEF { coltyp = JET_coltyp.LongText, cp = JET_CP.Unicode, grbit = SchemaCreator.ColumnNotNullIfOnHigherThanWindowsXp() }, null, 0, out columnid); Api.JetAddColumn(session, tableid, "hashed_reduce_key", new JET_COLUMNDEF { coltyp = JET_coltyp.Binary, cbMax = 20, grbit = SchemaCreator.ColumnNotNullIfOnHigherThanWindowsXp() | ColumndefGrbit.ColumnFixed }, null, 0, out columnid); Api.JetAddColumn(session, tableid, "reduce_type", new JET_COLUMNDEF { coltyp = JET_coltyp.Long, grbit = ColumndefGrbit.ColumnFixed | ColumndefGrbit.ColumnNotNULL }, null, 0, out columnid); SchemaCreator.CreateIndexes(session, tableid, new JET_INDEXCREATE { szIndexName = "by_id", szKey = "+id\0\0", grbit = CreateIndexGrbit.IndexPrimary }, new JET_INDEXCREATE { szIndexName = "by_view", szKey = "+view\0\0", grbit = CreateIndexGrbit.IndexDisallowNull }, new JET_INDEXCREATE { szIndexName = "by_view_and_hashed_reduce_key", szKey = "+view\0+hashed_reduce_key\0+reduce_key\0\0", grbit = CreateIndexGrbit.IndexUnique }); }
private void CreateIndexedDocumentsReferencesTable(Session session, JET_DBID dbid) { JET_TABLEID tableid; Api.JetCreateTable(session, dbid, "indexed_documents_references", 1, 80, out tableid); JET_COLUMNID columnid; Api.JetAddColumn(session, tableid, "id", new JET_COLUMNDEF { coltyp = JET_coltyp.Long, grbit = ColumndefGrbit.ColumnFixed | ColumndefGrbit.ColumnAutoincrement | ColumndefGrbit.ColumnNotNULL }, null, 0, out columnid); Api.JetAddColumn(session, tableid, "view", new JET_COLUMNDEF { cbMax = 2048, coltyp = JET_coltyp.LongText, cp = JET_CP.Unicode, grbit = SchemaCreator.ColumnNotNullIfOnHigherThanWindowsXp() }, null, 0, out columnid); Api.JetAddColumn(session, tableid, "key", new JET_COLUMNDEF { cbMax = 2048, coltyp = JET_coltyp.LongText, cp = JET_CP.Unicode, grbit = SchemaCreator.ColumnNotNullIfOnHigherThanWindowsXp() }, null, 0, out columnid); Api.JetAddColumn(session, tableid, "ref", new JET_COLUMNDEF { cbMax = 2048, coltyp = JET_coltyp.LongText, cp = JET_CP.Unicode, grbit = SchemaCreator.ColumnNotNullIfOnHigherThanWindowsXp() }, null, 0, out columnid); SchemaCreator.CreateIndexes(session, tableid, new JET_INDEXCREATE { szIndexName = "by_id", szKey = "+id\0\0", grbit = CreateIndexGrbit.IndexPrimary }, new JET_INDEXCREATE { szIndexName = "by_key", szKey = "+key\0\0", grbit = CreateIndexGrbit.IndexDisallowNull }, new JET_INDEXCREATE { szIndexName = "by_view", szKey = "+key\0\0", grbit = CreateIndexGrbit.IndexDisallowNull }, new JET_INDEXCREATE { szIndexName = "by_view_and_key", szKey = "+view\0+key\0\0", grbit = CreateIndexGrbit.IndexDisallowNull }, new JET_INDEXCREATE { szIndexName = "by_ref", szKey = "+ref\0\0", grbit = CreateIndexGrbit.IndexDisallowNull }); }
private void CreateReduceKeysCountsTable(Session session, JET_DBID dbid) { JET_TABLEID tableid; Api.JetCreateTable(session, dbid, "reduce_keys_counts", 1, 80, out tableid); JET_COLUMNID columnid; try { Api.JetAddColumn(session, tableid, "id", new JET_COLUMNDEF { coltyp = JET_coltyp.Long, grbit = ColumndefGrbit.ColumnFixed | ColumndefGrbit.ColumnAutoincrement | ColumndefGrbit.ColumnNotNULL }, null, 0, out columnid); Api.JetAddColumn(session, tableid, "view", new JET_COLUMNDEF { cbMax = 2048, coltyp = JET_coltyp.LongText, cp = JET_CP.Unicode, grbit = SchemaCreator.ColumnNotNullIfOnHigherThanWindowsXp() }, null, 0, out columnid); Api.JetAddColumn(session, tableid, "reduce_key", new JET_COLUMNDEF { coltyp = JET_coltyp.LongText, cp = JET_CP.Unicode, grbit = SchemaCreator.ColumnNotNullIfOnHigherThanWindowsXp() }, null, 0, out columnid); Api.JetAddColumn(session, tableid, "hashed_reduce_key", new JET_COLUMNDEF { coltyp = JET_coltyp.Binary, cbMax = 20, grbit = SchemaCreator.ColumnNotNullIfOnHigherThanWindowsXp() | ColumndefGrbit.ColumnFixed }, null, 0, out columnid); var defaultValue = BitConverter.GetBytes(0); Api.JetAddColumn(session, tableid, "mapped_items_count", new JET_COLUMNDEF { coltyp = JET_coltyp.Long, grbit = ColumndefGrbit.ColumnFixed | ColumndefGrbit.ColumnNotNULL | ColumndefGrbit.ColumnEscrowUpdate }, defaultValue, defaultValue.Length, out columnid); SchemaCreator.CreateIndexes(session, tableid, new JET_INDEXCREATE { szIndexName = "by_id", szKey = "+id\0\0", grbit = CreateIndexGrbit.IndexPrimary }, new JET_INDEXCREATE { szIndexName = "by_view", szKey = "+view\0\0", grbit = CreateIndexGrbit.IndexDisallowNull }, new JET_INDEXCREATE { szIndexName = "by_view_and_hashed_reduce_key", szKey = "+view\0+hashed_reduce_key\0+reduce_key\0\0", grbit = CreateIndexGrbit.IndexUnique }); } finally { Api.JetCloseTable(session, tableid); } }
public void CreateListsTable(Session session, JET_DBID dbid) { JET_TABLEID tableid; Api.JetCreateTable(session, dbid, "lists", 1, 80, out tableid); JET_COLUMNID columnid; Api.JetAddColumn(session, tableid, "id", new JET_COLUMNDEF { coltyp = JET_coltyp.Long, grbit = ColumndefGrbit.ColumnFixed | ColumndefGrbit.ColumnAutoincrement | ColumndefGrbit.ColumnNotNULL }, null, 0, out columnid); Api.JetAddColumn(session, tableid, "name", new JET_COLUMNDEF { cbMax = 2048, coltyp = JET_coltyp.LongText, cp = JET_CP.Unicode, grbit = SchemaCreator.ColumnNotNullIfOnHigherThanWindowsXp() }, null, 0, out columnid); Api.JetAddColumn(session, tableid, "key", new JET_COLUMNDEF { cbMax = 2048, coltyp = JET_coltyp.LongText, cp = JET_CP.Unicode, grbit = SchemaCreator.ColumnNotNullIfOnHigherThanWindowsXp() }, null, 0, out columnid); Api.JetAddColumn(session, tableid, "data", new JET_COLUMNDEF { coltyp = JET_coltyp.LongBinary, grbit = ColumndefGrbit.ColumnTagged }, null, 0, out columnid); Api.JetAddColumn(session, tableid, "etag", new JET_COLUMNDEF { cbMax = 16, coltyp = JET_coltyp.Binary, grbit = ColumndefGrbit.ColumnFixed | ColumndefGrbit.ColumnNotNULL, }, null, 0, out columnid); SchemaCreator.CreateIndexes(session, tableid, new JET_INDEXCREATE { szIndexName = "by_id", szKey = "+id\0\0", grbit = CreateIndexGrbit.IndexPrimary }, new JET_INDEXCREATE { szIndexName = "by_name_and_etag", szKey = "+name\0+etag\0\0", grbit = CreateIndexGrbit.IndexDisallowNull }, new JET_INDEXCREATE { szIndexName = "by_name_and_key", szKey = "+name\0+key\0\0", grbit = CreateIndexGrbit.IndexDisallowNull | CreateIndexGrbit.IndexUnique }); }
private void CreateScheduledReductionsTable(Session session, JET_DBID dbid) { JET_TABLEID tableid; Api.JetCreateTable(session, dbid, "scheduled_reductions", 1, 80, out tableid); JET_COLUMNID columnid; Api.JetAddColumn(session, tableid, "id", new JET_COLUMNDEF { coltyp = JET_coltyp.Long, grbit = ColumndefGrbit.ColumnFixed | ColumndefGrbit.ColumnAutoincrement | ColumndefGrbit.ColumnNotNULL }, null, 0, out columnid); Api.JetAddColumn(session, tableid, "view", new JET_COLUMNDEF { cbMax = 2048, coltyp = JET_coltyp.LongText, cp = JET_CP.Unicode, grbit = SchemaCreator.ColumnNotNullIfOnHigherThanWindowsXp() }, null, 0, out columnid); Api.JetAddColumn(session, tableid, "reduce_key", new JET_COLUMNDEF { coltyp = JET_coltyp.LongText, cp = JET_CP.Unicode, grbit = SchemaCreator.ColumnNotNullIfOnHigherThanWindowsXp() }, null, 0, out columnid); Api.JetAddColumn(session, tableid, "etag", new JET_COLUMNDEF { cbMax = 16, coltyp = JET_coltyp.Binary, grbit = ColumndefGrbit.ColumnNotNULL | ColumndefGrbit.ColumnFixed }, null, 0, out columnid); Api.JetAddColumn(session, tableid, "timestamp", new JET_COLUMNDEF { coltyp = JET_coltyp.DateTime, grbit = ColumndefGrbit.ColumnNotNULL | ColumndefGrbit.ColumnFixed }, null, 0, out columnid); Api.JetAddColumn(session, tableid, "bucket", new JET_COLUMNDEF { coltyp = JET_coltyp.Long, grbit = ColumndefGrbit.ColumnFixed | ColumndefGrbit.ColumnNotNULL }, null, 0, out columnid); Api.JetAddColumn(session, tableid, "level", new JET_COLUMNDEF { coltyp = JET_coltyp.Long, grbit = ColumndefGrbit.ColumnFixed | ColumndefGrbit.ColumnNotNULL }, null, 0, out columnid); SchemaCreator.CreateIndexes(session, tableid, new JET_INDEXCREATE { szIndexName = "by_id", szKey = "+id\0\0", grbit = CreateIndexGrbit.IndexPrimary }, new JET_INDEXCREATE { szIndexName = "by_view", szKey = "+view\0\0", grbit = CreateIndexGrbit.IndexDisallowNull }, new JET_INDEXCREATE { szIndexName = "by_view_level_reduce_key_and_bucket", szKey = "+view\0+level\0+reduce_key\0+bucket\0\0", }); }