//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void mustCombineSamples() public virtual void MustCombineSamples() { // given int sumIndexSize = 0; int sumUniqueValues = 0; int sumSampleSize = 0; IndexSample[] samples = new IndexSample[_providers.Count]; for (int i = 0; i < samples.Length; i++) { int indexSize = Random.Next(0, 1_000_000); int uniqueValues = Random.Next(0, 1_000_000); int sampleSize = Random.Next(0, 1_000_000); samples[i] = new IndexSample(indexSize, uniqueValues, sampleSize); sumIndexSize += indexSize; sumUniqueValues += uniqueValues; sumSampleSize += sampleSize; } // when IndexSample fusionSample = FusionIndexSampler.CombineSamples(Arrays.asList(samples)); // then assertEquals(sumIndexSize, fusionSample.IndexSize()); assertEquals(sumUniqueValues, fusionSample.UniqueValues()); assertEquals(sumSampleSize, fusionSample.SampleSize()); }
public async Task SetLockModeForStaticIndex() { using (var store = GetDocumentStore()) { // create static-index var staticIndex = new IndexSample { Conventions = new DocumentConventions() }; staticIndex.Execute(store); var indexes = await store.Maintenance.SendAsync(new GetIndexesOperation(0, 128)); Assert.Equal(1, indexes.Length); var index = indexes[0]; var stats = await store.Maintenance.SendAsync(new GetIndexStatisticsOperation(index.Name)); Assert.Equal(IndexLockMode.Unlock, stats.LockMode); store.Maintenance.Send(new SetIndexesLockOperation(index.Name, IndexLockMode.LockedIgnore)); stats = await store.Maintenance.SendAsync(new GetIndexStatisticsOperation(index.Name)); Assert.Equal(IndexLockMode.LockedIgnore, stats.LockMode); store.Maintenance.Send(new SetIndexesLockOperation(index.Name, IndexLockMode.LockedError)); stats = await store.Maintenance.SendAsync(new GetIndexStatisticsOperation(index.Name)); Assert.Equal(IndexLockMode.LockedError, stats.LockMode); } }
private static void VerifySamplingResult(UniqueIndexSampler sampler, long expectedValue) { IndexSample sample = sampler.Result(); assertEquals(expectedValue, sample.IndexSize()); assertEquals(expectedValue, sample.UniqueValues()); assertEquals(expectedValue, sample.SampleSize()); }
public virtual IndexSample Combine(IndexSample sample1, IndexSample sample2) { long indexSize = Math.addExact(sample1.IndexSize(), sample2.IndexSize()); long uniqueValues = Math.addExact(sample1.UniqueValues(), sample2.UniqueValues()); long sampleSize = Math.addExact(sample1.SampleSize(), sample2.SampleSize()); return(new IndexSample(indexSize, uniqueValues, sampleSize)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void sampleEmptyIndex() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void SampleEmptyIndex() { _populator = NewPopulator(); IndexSample sample = _populator.sampleResult(); assertEquals(new IndexSample(), sample); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void samplePartitionedIndex() internal virtual void SamplePartitionedIndex() { IList <IndexSampler> samplers = Arrays.asList(CreateSampler(1), CreateSampler(2)); AggregatingIndexSampler partitionedSampler = new AggregatingIndexSampler(samplers); IndexSample sample = partitionedSampler.SampleIndex(); assertEquals(new IndexSample(3, 3, 6), sample); }
public async Task SetLockModeForStaticAndAutoIndexes() { using (var store = GetDocumentStore()) { using (var session = store.OpenSession()) { session.Store(new Person() { Name = "Danielle" }); session.SaveChanges(); } QueryStatistics statistics; // create auto-index using (var session = store.OpenSession()) { var results = session.Query <Person>().Customize(x => x.WaitForNonStaleResults()).Statistics(out statistics).Where(x => x.Name == "Danielle").ToList(); } // create static-index var index = new IndexSample { Conventions = new DocumentConventions() }; index.Execute(store); var indexes = await store.Maintenance.SendAsync(new GetIndexesOperation(0, 128)); Assert.Equal(2, indexes.Length); var autoIndex = indexes[0]; var staticIndex = indexes[1]; Assert.Equal(IndexLockMode.Unlock, autoIndex.LockMode); Assert.Equal(IndexLockMode.Unlock, staticIndex.LockMode); SetIndexesLockOperation.Parameters indexesParams = new SetIndexesLockOperation.Parameters(); indexesParams.Mode = IndexLockMode.LockedIgnore; indexesParams.IndexNames = new string[] { autoIndex.Name, staticIndex.Name }; var exception = Assert.Throws <InvalidOperationException>(() => store.Maintenance.Send(new SetIndexesLockOperation(indexesParams))); Assert.Equal("'Indexes list contains Auto-Indexes. Lock Mode' is not set for Auto-Indexes.", exception.Message); indexes = await store.Maintenance.SendAsync(new GetIndexesOperation(0, 128)); autoIndex = indexes[0]; staticIndex = indexes[1]; Assert.Equal(IndexLockMode.Unlock, autoIndex.LockMode); Assert.Equal(IndexLockMode.Unlock, staticIndex.LockMode); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void sampleIncludedUpdatesWithDuplicates() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void SampleIncludedUpdatesWithDuplicates() { _populator = NewPopulator(); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.List<org.neo4j.kernel.api.index.IndexEntryUpdate<?>> updates = java.util.Arrays.asList(add(1, labelSchemaDescriptor, "foo"), add(2, labelSchemaDescriptor, "bar"), add(3, labelSchemaDescriptor, "foo")); IList <IndexEntryUpdate <object> > updates = Arrays.asList(add(1, _labelSchemaDescriptor, "foo"), add(2, _labelSchemaDescriptor, "bar"), add(3, _labelSchemaDescriptor, "foo")); updates.ForEach(_populator.includeSample); IndexSample sample = _populator.sampleResult(); assertEquals(new IndexSample(3, 2, 3), sample); }
public override bool Equals(object o) { if (this == o) { return(true); } if (o == null || this.GetType() != o.GetType()) { return(false); } IndexSample that = ( IndexSample )o; return(_indexSize == that._indexSize && _uniqueValues == that._uniqueValues && _sampleSize == that._sampleSize); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void sampleIncludedUpdates() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void SampleIncludedUpdates() { LabelSchemaDescriptor schemaDescriptor = SchemaDescriptorFactory.forLabel(1, 1); _populator = NewPopulator(); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.List<org.neo4j.kernel.api.index.IndexEntryUpdate<?>> updates = java.util.Arrays.asList(add(1, schemaDescriptor, "foo"), add(2, schemaDescriptor, "bar"), add(3, schemaDescriptor, "baz"), add(4, schemaDescriptor, "qux")); IList <IndexEntryUpdate <object> > updates = Arrays.asList(add(1, schemaDescriptor, "foo"), add(2, schemaDescriptor, "bar"), add(3, schemaDescriptor, "baz"), add(4, schemaDescriptor, "qux")); updates.ForEach(_populator.includeSample); IndexSample sample = _populator.sampleResult(); assertEquals(new IndexSample(4, 4, 4), sample); }
/// <summary> /// Removes all indices from the underlying descriptor and adds them to this reference literal. /// </summary> /// <returns>a possibly modified, but semantically equivalent signal reference literal</returns> public SignalRef AssimilateIndices() { if (!IsStaticIndex) { return(this); } IndexSpec rootIndex; var udesc = Desc.GetUnindexedContainer(out rootIndex); var myIndex = IndexSample.Project(rootIndex); return(new SignalRef( udesc, Prop, myIndex.AsExpressions(), myIndex, true)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldSampleUpdatesIfConfiguredForOnlineSampling() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldSampleUpdatesIfConfiguredForOnlineSampling() { // GIVEN try { outerInstance.populator.create(); IndexEntryUpdate <IndexDescriptor>[] scanUpdates = valueCreatorUtil.someUpdates(random); outerInstance.populator.add(Arrays.asList(scanUpdates)); IEnumerator <IndexEntryUpdate <IndexDescriptor> > generator = valueCreatorUtil.randomUpdateGenerator(random); Value[] updates = new Value[5]; //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: updates[0] = generator.next().values()[0]; //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: updates[1] = generator.next().values()[0]; updates[2] = updates[1]; //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: updates[3] = generator.next().values()[0]; updates[4] = updates[3]; using (IndexUpdater updater = outerInstance.populator.newPopulatingUpdater(NullPropertyAccessor)) { long nodeId = 1000; foreach (Value value in updates) { IndexEntryUpdate <IndexDescriptor> update = valueCreatorUtil.add(nodeId++, value); updater.Process(update); } } // WHEN outerInstance.populator.scanCompleted(nullInstance); IndexSample sample = outerInstance.populator.sampleResult(); // THEN Value[] allValues = Arrays.copyOf(updates, updates.Length + scanUpdates.Length); Array.Copy(AsValues(scanUpdates), 0, allValues, updates.Length, scanUpdates.Length); assertEquals(updates.Length + scanUpdates.Length, sample.SampleSize()); assertEquals(countUniqueValues(allValues), sample.UniqueValues()); assertEquals(updates.Length + scanUpdates.Length, sample.IndexSize()); } finally { outerInstance.populator.close(true); } }
static void Main(string[] args) { //ElasticSearchが立っているところを指定してください var sample = new IndexSample(new Uri("http://192.168.xxx.xxx:9200")); sample.CreateMapping() .PutPipeline() .AddAttachment(1, new Uri(@"https://file.wikileaks.org/file/cia-afghanistan.pdf")) .AddAttachment(2, new Uri(@"http://www.kyoiku.metro.tokyo.jp/press/2016/pr161110b/besshi2.pdf")) .AddAttachment(3, new Uri(@"http://www.mext.go.jp/b_menu/toukei/data/syogaikoku/__icsFiles/afieldfile/2015/07/17/1352615_01_1.xlsx")) ; //Documentの取得 var result = sample.GetDocument(2); //ファイルの情報を表示してみる Console.WriteLine($"Author = {result.Attachment.Author} / Content = {result.Attachment.Content}"); Console.WriteLine("finish"); }
public async Task LockingIndexesInMemoryWillNotFail() { using (var store = GetDocumentStore()) { var index = new IndexSample { Conventions = new DocumentConventions() }; index.Execute(store); var indexDefinition = store.Maintenance.Send(new GetIndexOperation("IndexSample")); Assert.Equal(indexDefinition.LockMode, IndexLockMode.Unlock); var database = await GetDatabase(store.Database); database.IndexStore.GetIndex("IndexSample").SetLock(IndexLockMode.LockedIgnore); indexDefinition = store.Maintenance.Send(new GetIndexOperation("IndexSample")); Assert.Equal(indexDefinition.LockMode, IndexLockMode.LockedIgnore); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldSampleUpdates() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldSampleUpdates() { // GIVEN outerInstance.populator.create(); IndexEntryUpdate <IndexDescriptor>[] updates = valueCreatorUtil.someUpdates(random); // WHEN outerInstance.populator.add(asList(updates)); foreach (IndexEntryUpdate <IndexDescriptor> update in updates) { outerInstance.populator.includeSample(update); } outerInstance.populator.scanCompleted(nullInstance); IndexSample sample = outerInstance.populator.sampleResult(); // THEN assertEquals(updates.Length, sample.SampleSize()); assertEquals(updates.Length, sample.UniqueValues()); assertEquals(updates.Length, sample.IndexSize()); outerInstance.populator.close(true); }
/* ** If the Index.aSample variable is not NULL, delete the aSample[] array ** and its contents. */ static void sqlite3DeleteIndexSamples(sqlite3 db, Index pIdx) { #if SQLITE_ENABLE_STAT2 if (pIdx.aSample != null) { int j; for (j = 0; j < SQLITE_INDEX_SAMPLES; j++) { IndexSample p = pIdx.aSample[j]; if (p.eType == SQLITE_TEXT || p.eType == SQLITE_BLOB) { p.u.z = null;//sqlite3DbFree(db, p.u.z); p.u.zBLOB = null; } } sqlite3DbFree(db, ref pIdx.aSample); } #else UNUSED_PARAMETER(db); UNUSED_PARAMETER(pIdx); #endif }
public static void DeleteIndexSamples(Context ctx, Index idx) { #if ENABLE_STAT3 if (idx.Samples != null) { for (int j = 0; j < idx.Samples.length; j++) { IndexSample p = idx.Samples[j]; if (p.Type == TYPE.TEXT || p.Type == TYPE.BLOB) { C._tagfree(ctx, ref p.u.Z); } } C._tagfree(ctx, ref idx.Samples); } if (ctx && ctx.BytesFreed == 0) { idx.Samples.length = 0; idx.Samples.data = null; } #endif }
/* ** If the Index.aSample variable is not NULL, delete the aSample[] array ** and its contents. */ private static void sqlite3DeleteIndexSamples(Index pIdx) { #if SQLITE_ENABLE_STAT2 if (pIdx.aSample != null) { int j; sqlite3 dbMem = pIdx.pTable.dbMem; for (j = 0; j < SQLITE_INDEX_SAMPLES; j++) { IndexSample p = pIdx.aSample[j]; if (p.eType == SQLITE_TEXT || p.eType == SQLITE_BLOB) { p.u.z = null; sqlite3DbFree(pIdx.pTable.dbMem, p.u.z); p.u.zBLOB = null; } } sqlite3DbFree(dbMem, pIdx.aSample); pIdx.aSample = null; } #else UNUSED_PARAMETER(pIdx); #endif }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: void flip(boolean verifyBeforeFlipping) throws org.neo4j.kernel.api.exceptions.index.FlipFailedKernelException internal virtual void Flip(bool verifyBeforeFlipping) { outerInstance.phaseTracker.EnterPhase(PhaseTracker_Phase.Flip); Flipper.flip(() => { PopulatorLock.@lock(); try { if (PopulationOngoing) { Populator.add(TakeCurrentBatch()); outerInstance.PopulateFromQueue(0, long.MaxValue); if (outerInstance.Populations.Contains(IndexPopulation.this)) { if (verifyBeforeFlipping) { Populator.verifyDeferredConstraints(outerInstance.storeView); } IndexSample sample = Populator.sampleResult(); outerInstance.storeView.ReplaceIndexCounts(IndexId, sample.uniqueValues(), sample.sampleSize(), sample.indexSize()); Populator.close(true); outerInstance.schemaState.Clear(); return(true); } } return(false); } finally { PopulationOngoing = false; PopulatorLock.unlock(); } }, FailedIndexProxyFactory); outerInstance.removeFromOngoingPopulations(this); LogCompletionMessage(); }
/* ** Load the content of the sqlite_stat1 and sqlite_stat2 tables. The ** contents of sqlite_stat1 are used to populate the Index.aiRowEst[] ** arrays. The contents of sqlite_stat2 are used to populate the ** Index.aSample[] arrays. ** ** If the sqlite_stat1 table is not present in the database, SQLITE_ERROR ** is returned. In this case, even if SQLITE_ENABLE_STAT2 was defined ** during compilation and the sqlite_stat2 table is present, no data is ** read from it. ** ** If SQLITE_ENABLE_STAT2 was defined during compilation and the ** sqlite_stat2 table is not present in the database, SQLITE_ERROR is ** returned. However, in this case, data is read from the sqlite_stat1 ** table (if it is present) before returning. ** ** If an OOM error occurs, this function always sets db.mallocFailed. ** This means if the caller does not care about other errors, the return ** code may be ignored. */ static int sqlite3AnalysisLoad(sqlite3 db, int iDb) { analysisInfo sInfo; HashElem i; string zSql; int rc; Debug.Assert(iDb >= 0 && iDb < db.nDb); Debug.Assert(db.aDb[iDb].pBt != null); Debug.Assert(sqlite3BtreeHoldsMutex(db.aDb[iDb].pBt)); /* Clear any prior statistics */ //for(i=sqliteHashFirst(&db.aDb[iDb].pSchema.idxHash);i;i=sqliteHashNext(i)){ for (i = db.aDb[iDb].pSchema.idxHash.first; i != null; i = i.next) { Index pIdx = (Index)i.data;// sqliteHashData( i ); sqlite3DefaultRowEst(pIdx); sqlite3DeleteIndexSamples(pIdx); } /* Check to make sure the sqlite_stat1 table exists */ sInfo.db = db; sInfo.zDatabase = db.aDb[iDb].zName; if (sqlite3FindTable(db, "sqlite_stat1", sInfo.zDatabase) == null) { return(SQLITE_ERROR); } /* Load new statistics out of the sqlite_stat1 table */ zSql = sqlite3MPrintf(db, "SELECT idx, stat FROM %Q.sqlite_stat1", sInfo.zDatabase); if (zSql == null) { rc = SQLITE_NOMEM; } else { rc = sqlite3_exec(db, zSql, (dxCallback)analysisLoader, sInfo, 0); sqlite3DbFree(db, ref zSql); } /* Load the statistics from the sqlite_stat2 table. */ #if SQLITE_ENABLE_STAT2 if (rc == SQLITE_OK && null == sqlite3FindTable(db, "sqlite_stat2", sInfo.zDatabase)) { rc = SQLITE_ERROR; } if (rc == SQLITE_OK) { sqlite3_stmt pStmt = null; zSql = sqlite3MPrintf(db, "SELECT idx,sampleno,sample FROM %Q.sqlite_stat2", sInfo.zDatabase); //if( !zSql ){ //rc = SQLITE_NOMEM; //}else{ string sDummy = ""; rc = sqlite3_prepare(db, zSql, -1, ref pStmt, ref sDummy); sqlite3DbFree(db, ref zSql); //} if (rc == SQLITE_OK) { while (sqlite3_step(pStmt) == SQLITE_ROW) { string zIndex = sqlite3_column_text(pStmt, 0); Index pIdx = sqlite3FindIndex(db, zIndex, sInfo.zDatabase); if (pIdx != null) { int iSample = sqlite3_column_int(pStmt, 1); sqlite3 dbMem = pIdx.pTable.dbMem; Debug.Assert(dbMem == db || dbMem == null); if (iSample < SQLITE_INDEX_SAMPLES && iSample >= 0) { int eType = sqlite3_column_type(pStmt, 2); if (pIdx.aSample == null) { //static const int sz = sizeof(IndexSample)*SQLITE_INDEX_SAMPLES; pIdx.aSample = new IndexSample[SQLITE_INDEX_SAMPLES];//(IndexSample *)sqlite3DbMallocZero(dbMem, sz); //if( pIdx.aSample==0 ){ //db.mallocFailed = 1; //break; //} } Debug.Assert(pIdx.aSample != null); IndexSample pSample = pIdx.aSample[iSample]; { pSample.eType = (u8)eType; if (eType == SQLITE_INTEGER || eType == SQLITE_FLOAT) { pSample.u.r = sqlite3_column_double(pStmt, 2); } else if (eType == SQLITE_TEXT || eType == SQLITE_BLOB) { string z = null; byte[] zBLOB = null; //string z = (const char *)( //(eType==SQLITE_BLOB) ? //sqlite3_column_blob(pStmt, 2): //sqlite3_column_text(pStmt, 2) //); if (eType == SQLITE_BLOB) { zBLOB = sqlite3_column_blob(pStmt, 2); } else { z = sqlite3_column_text(pStmt, 2); } int n = sqlite3_column_bytes(pStmt, 2); if (n > 24) { n = 24; } pSample.nByte = (u8)n; pSample.u.z = z; pSample.u.zBLOB = zBLOB; //pSample.u.z = sqlite3DbMallocRaw(dbMem, n); //if( pSample.u.z ){ //memcpy(pSample.u.z, z, n); //}else{ //db.mallocFailed = 1; //break; //} } } } } } rc = sqlite3_finalize(ref pStmt); } } #endif //if( rc==SQLITE_NOMEM ){ // db.mallocFailed = 1; //} return(rc); }
static RC LoadStat3(Context ctx, string dbName) { Debug.Assert(!ctx.Lookaside.Enabled); if (sqlite3FindTable(ctx, "sqlite_stat3", dbName) == null) { return(RC.OK); } string sql = SysEx.Mprintf(ctx, "SELECT idx,count(*) FROM %Q.sqlite_stat3 GROUP BY idx", dbName); // Text of the SQL statement if (!sql) { return(RC_NOMEM); } Vdbe stmt = null; // An SQL statement being run RC rc = Vdbe.Prepare(ctx, sql, -1, stmt, 0); // Result codes from subroutines C._tagfree(ctx, sql); if (rc) { return(rc); } while (stmt.Step() == RC.ROW) { string indexName = (string)Vdbe.Column_Text(stmt, 0); // Index name if (!indexName) { continue; } int samplesLength = Vdbe.Column_Int(stmt, 1); // Number of samples Index idx = sqlite3FindIndex(ctx, indexName, dbName); // Pointer to the index object if (!idx) { continue; } _assert(idx->Samples.length == 0); idx.Samples.length = samplesLength; idx.Samples.data = new IndexSample[samplesLength]; idx.AvgEq = idx.RowEsts[1]; if (!idx->Samples.data) { ctx->MallocFailed = true; Vdbe.Finalize(stmt); return(RC.NOMEM); } } rc = Vdbe.Finalize(stmt); if (rc) { return(rc); } sql = C._mtagprintf(ctx, "SELECT idx,neq,nlt,ndlt,sample FROM %Q.sqlite_stat3", dbName); if (!sql) { return(RC.NOMEM); } rc = Vdbe.Prepare(ctx, sql, -1, &stmt, 0); C._tagfree(ctx, sql); if (rc) { return(rc); } Index prevIdx = null; // Previous index in the loop int idxId = 0; // slot in pIdx->aSample[] for next sample while (stmt.Step() == RC.ROW) { string indexName = (string)Vdbe.Column_Text(stmt, 0); // Index name if (indexName == null) { continue; } Index idx = sqlite3FindIndex(ctx, indexName, dbName); // Pointer to the index object if (idx == null) { continue; } if (idx == prevIdx) { idxId++; } else { prevIdx = idx; idxId = 0; } Debug.Assert(idxId < idx.Samples.length); IndexSample sample = idx.Samples[idxId]; // A slot in pIdx->aSample[] sample.Eq = (tRowcnt)Vdbe.Column_Int64(stmt, 1); sample.Lt = (tRowcnt)Vdbe.Column_Int64(stmt, 2); sample.DLt = (tRowcnt)Vdbe.Column_Int64(stmt, 3); if (idxId == idx.Samples.length - 1) { tRowcnt sumEq; // Sum of the nEq values if (sample.DLt > 0) { for (int i = 0, sumEq = 0; i <= idxId - 1; i++) { sumEq += idx.Samples[i].Eq; } idx.AvgEq = (sample.Lt - sumEq) / sample.DLt; } if (idx.AvgEq <= 0) { idx.AvgEq = 1; } } TYPE type = Vdbe.Column_Type(stmt, 4); // Datatype of a sample sample.Type = type; switch (type) { case TYPE.INTEGER: { sample.u.I = Vdbe.Column_Int64(stmt, 4); break; } case TYPE.FLOAT: { sample.u.R = Vdbe.Column_Double(stmt, 4); break; } case TYPE.NULL: { break; } default: Debug.Assert(type == TYPE.TEXT || type == TYPE.BLOB); { string z = (string)(type == TYPE_BLOB ? Vdbe.Column_Blob(stmt, 4) : Vdbe.Column_Text(stmt, 4)); int n = (z ? Vdbe.Column_Bytes(stmt, 4) : 0); sample.Bytes = n; if (n < 1) { sample.u.Z = null; } else { sample.u.Z = C._tagalloc(ctx, n); if (sample->u.Z == null) { ctx.MallocFailed = true; Vdbe.Finalize(stmt); return(RC.NOMEM); } Buffer.BlockCopy(sample.u.Z, z, n); } } } } return(Vdbe.Finalize(stmt)); }