PostgreSQL Source Code: src/backend/tsearch/ts_typanalyze.c Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

15

23

24

25

31

32

39

42 int samplerows,

49 void *arg);

51 void *arg);

52

53

54

55

56

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140static void

143 int samplerows,

145{

149

150

154

155

157

158

163

164

165

166

167

168

169

171

172

173

174

175

177

178

179

180

181

182

192

193

196

197

199 {

201 bool isnull;

205 int j;

206

208

210

211

212

213

214 if (isnull)

215 {

217 continue;

218 }

219

220

221

222

223

224

225

227

228

229

230

232

233

234

235

236

239 for (j = 0; j < vector->size; j++)

240 {

242 bool found;

243

244

245

246

247

248

249

252

253

257

258 if (found)

259 {

260

262 }

263 else

264 {

265

268

271 }

272

273

275

276

278 {

281 }

282

283

285 }

286

287

290 }

291

292

294 {

296 int i;

303

305

308

309

311

312

313

314

315

316

317

318

319

321

324

329 {

331 {

334 }

335 }

337

338

339 elog(DEBUG3, "tsvector_stats: target # mces = %d, bucket width = %d, "

340 "# lexemes = %d, hashtable size = %d, usable entries = %d",

342

343

344

345

346

347

348

349

350

351

352

353

354

355

356

357

358

359

361 {

364

366 }

367 else

368 {

370

372

375 }

376

377

379 {

383

384

385

386

387

388

389

390

391

392

393

394

395

396

397

400

401

403

404

405

406

407

408

409

410

411

412

413

414

417

418

419

420

421

423 {

425

428 titem->key.length));

430 }

434

439

443

445 stats->statyplen[0] = -1;

448 }

449 }

450 else

451 {

452

455 stats->stawidth = 0;

456 stats->stadistinct = 0.0;

457 }

458

459

460

461

462

463}

464

465

466

467

468

469static void

471{

474

477 {

479 {

481

484 elog(ERROR, "hash table corrupted");

486 }

487 }

488}

489

490

491

492

493

502

503

504

505

506static int

512

513

514

515

516static int

518{

521

522

524 return 1;

526 return -1;

527

529}

530

531

532

533

534static int

536{

539

540 return (*t2)->frequency - (*t1)->frequency;

541}

542

543

544

545

546static int

#define Assert(condition)

int default_statistics_target

static dshash_hash hash_key(dshash_table *hash_table, const void *key)

void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)

HTAB * hash_create(const char *tabname, int64 nelem, const HASHCTL *info, int flags)

void * hash_seq_search(HASH_SEQ_STATUS *status)

int64 hash_get_num_entries(HTAB *hashp)

void hash_seq_init(HASH_SEQ_STATUS *status, HTAB *hashp)

#define palloc_array(type, count)

#define PG_GETARG_POINTER(n)

#define PG_RETURN_BOOL(x)

static Datum hash_any(const unsigned char *k, int keylen)

void pfree(void *pointer)

MemoryContext CurrentMemoryContext

static MemoryContext MemoryContextSwitchTo(MemoryContext context)

void qsort_interruptible(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg)

static uint32 DatumGetUInt32(Datum X)

static Datum PointerGetDatum(const void *X)

static Pointer DatumGetPointer(Datum X)

int16 stakind[STATISTIC_NUM_SLOTS]

MemoryContext anl_context

Oid statypid[STATISTIC_NUM_SLOTS]

Oid staop[STATISTIC_NUM_SLOTS]

Oid stacoll[STATISTIC_NUM_SLOTS]

char statypalign[STATISTIC_NUM_SLOTS]

float4 * stanumbers[STATISTIC_NUM_SLOTS]

bool statypbyval[STATISTIC_NUM_SLOTS]

int16 statyplen[STATISTIC_NUM_SLOTS]

int numvalues[STATISTIC_NUM_SLOTS]

Datum * stavalues[STATISTIC_NUM_SLOTS]

int numnumbers[STATISTIC_NUM_SLOTS]

AnalyzeAttrComputeStatsFunc compute_stats

static int trackitem_compare_frequencies_desc(const void *e1, const void *e2, void *arg)

static void prune_lexemes_hashtable(HTAB *lexemes_tab, int b_current)

static int trackitem_compare_lexemes(const void *e1, const void *e2, void *arg)

static int lexeme_compare(const void *key1, const void *key2)

static int lexeme_match(const void *key1, const void *key2, Size keysize)

Datum ts_typanalyze(PG_FUNCTION_ARGS)

static void compute_tsvector_stats(VacAttrStats *stats, AnalyzeAttrFetchFunc fetchfunc, int samplerows, double totalrows)

static uint32 lexeme_hash(const void *key, Size keysize)

static TSVector DatumGetTSVector(Datum X)

static Datum TSVectorGetDatum(const TSVectorData *X)

void vacuum_delay_point(bool is_analyze)

Datum(* AnalyzeAttrFetchFunc)(VacAttrStatsP stats, int rownum, bool *isNull)

static Size VARSIZE_ANY(const void *PTR)

text * cstring_to_text_with_len(const char *s, int len)