01: /*
02: * Copyright 2004-2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.compass.gps.device.support.parallel;
18:
19: import org.compass.core.CompassCallbackWithoutResult;
20: import org.compass.core.CompassException;
21: import org.compass.core.CompassSession;
22: import org.compass.core.spi.InternalCompassSession;
23: import org.compass.gps.spi.CompassGpsInterfaceDevice;
24:
25: /**
26: * Executes the indexing process on the same thread (and naturally using a single
27: * thread).
28: *
29: * @author kimchy
30: */
31: public class SameThreadParallelIndexExecutor implements
32: ParallelIndexExecutor {
33:
34: /**
35: * Performs the indexing process using the same thread (and naturally using a single
36: * thread).
37: *
38: * @param entities The index entities to index
39: * @param indexEntitiesIndexer The entities indexer to use
40: * @param compassGps Compass gps interface for meta information
41: */
42: public void performIndex(final IndexEntity[][] entities,
43: final IndexEntitiesIndexer indexEntitiesIndexer,
44: CompassGpsInterfaceDevice compassGps) {
45: compassGps.executeForIndex(new CompassCallbackWithoutResult() {
46: protected void doInCompassWithoutResult(
47: CompassSession session) throws CompassException {
48: for (int i = 0; i < entities.length; i++) {
49: indexEntitiesIndexer.performIndex(session,
50: entities[i]);
51: }
52: ((InternalCompassSession) session).flush();
53: }
54: });
55: }
56: }
|