1<?php
2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project
3//
4// All Rights Reserved. See copyright.txt for details and a complete list of authors.
5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
6// $Id$
7
8class Search_Index_Memory implements Search_Index_Interface
9{
10	private $data = [];
11	private $lastQuery;
12	private $lastOrder;
13	private $lastStart;
14	private $lastCount;
15
16	function addDocument(array $data)
17	{
18		$this->data[] = $data;
19	}
20
21	function endUpdate()
22	{
23	}
24
25	function invalidateMultiple(array $objectList)
26	{
27	}
28
29	function find(Search_Query_Interface $query, $resultStart, $resultCount)
30	{
31		$this->lastQuery = $query->getExpr();
32		$this->lastOrder = $query->getSortOrder();
33		$this->lastStart = $resultStart;
34		$this->lastCount = $resultCount;
35		return new Search_ResultSet([], 0, $resultStart, $resultCount);
36	}
37
38	function getTypeFactory()
39	{
40		return new Search_Lucene_TypeFactory;
41	}
42
43	function optimize()
44	{
45	}
46
47	function destroy()
48	{
49		$this->data = [];
50		return true;
51	}
52
53	function exists()
54	{
55		return count($this->data) > 0;
56	}
57
58	/**
59	 * For test purposes.
60	 */
61	function size()
62	{
63		return count($this->data);
64	}
65
66	/**
67	 * For test purposes.
68	 */
69	function getDocument($index)
70	{
71		return $this->data[$index];
72	}
73
74	/**
75	 * For test purposes.
76	 */
77	function getLastQuery()
78	{
79		return $this->lastQuery;
80	}
81
82	/**
83	 * For test purposes.
84	 */
85	function getLastOrder()
86	{
87		return $this->lastOrder;
88	}
89
90	/**
91	 * For test purposes.
92	 */
93	function getLastStart()
94	{
95		return $this->lastStart;
96	}
97
98	/**
99	 * For test purposes.
100	 */
101	function getLastCount()
102	{
103		return $this->lastCount;
104	}
105}
106