3 abstract class PhabricatorSearchNgrams
4 extends PhabricatorSearchDAO
{
12 abstract public function getNgramKey();
13 abstract public function getColumnName();
15 final public function setValue($value) {
16 $this->value
= $value;
20 final public function getValue() {
24 protected function getConfiguration() {
26 self
::CONFIG_TIMESTAMPS
=> false,
27 self
::CONFIG_COLUMN_SCHEMA
=> array(
28 'objectID' => 'uint32',
31 self
::CONFIG_KEY_SCHEMA
=> array(
33 'columns' => array('ngram', 'objectID'),
35 'key_object' => array(
36 'columns' => array('objectID'),
39 ) + parent
::getConfiguration();
42 public function getTableName() {
43 $application = $this->getApplicationName();
44 $key = $this->getNgramKey();
45 return "{$application}_{$key}_ngrams";
48 final public function writeNgram($object_id) {
49 $ngram_engine = $this->getNgramEngine();
50 $ngrams = $ngram_engine->getTermNgramsFromString($this->getValue());
52 $conn_w = $this->establishConnection('w');
55 foreach ($ngrams as $ngram) {
65 'DELETE FROM %T WHERE objectID = %d',
66 $this->getTableName(),
72 'INSERT INTO %T (objectID, ngram) VALUES %LQ',
73 $this->getTableName(),
80 private function getNgramEngine() {
81 if (!$this->ngramEngine
) {
82 $this->ngramEngine
= new PhabricatorSearchNgramEngine();
85 return $this->ngramEngine
;