Skip to content

Commit

Permalink
Comments, extraction, modifiers comments addressed.
Browse files Browse the repository at this point in the history
  • Loading branch information
MishaDemianenko committed Jul 22, 2016
1 parent 6eba7e9 commit e09d44d
Show file tree
Hide file tree
Showing 9 changed files with 206 additions and 329 deletions.
Expand Up @@ -31,7 +31,7 @@ public class SimpleKernelContext implements KernelContext
{ {
private final FileSystemAbstraction fileSystem; private final FileSystemAbstraction fileSystem;
private final File storeDir; private final File storeDir;
UsageDataKeys.OperationalMode operationalMode; private final UsageDataKeys.OperationalMode operationalMode;


public SimpleKernelContext( FileSystemAbstraction fileSystem, File storeDir, UsageDataKeys.OperationalMode operationalMode ) public SimpleKernelContext( FileSystemAbstraction fileSystem, File storeDir, UsageDataKeys.OperationalMode operationalMode )
{ {
Expand Down
Expand Up @@ -132,16 +132,8 @@ public void close() throws IOException
this.dir = dirFactory.open( indexFolder ); this.dir = dirFactory.open( indexFolder );
if ( readOnly ) if ( readOnly )
{ {
try this.writer = null;
{ searcherManager = createReadOnlySearchManager();
this.writer = null;
searcherManager =
new LuceneReferenceManager.Wrap<>( new SearcherManager( dir, new SearcherFactory() ) );
}
catch ( IndexNotFoundException e )
{
throw new IllegalStateException( "Index creation is not supported in read only mode.", e );
}
} }
else else
{ {
Expand All @@ -150,6 +142,18 @@ public void close() throws IOException
} }
} }


private LuceneReferenceManager.Wrap<IndexSearcher> createReadOnlySearchManager() throws IOException
{
try
{
return new LuceneReferenceManager.Wrap<>( new SearcherManager( dir, new SearcherFactory() ) );
}
catch ( IndexNotFoundException e )
{
throw new IllegalStateException( "Index creation is not supported in read only mode.", e );
}
}

// test only // test only
LuceneIndexAccessor( LuceneDocumentStructure documentStructure, boolean readOnly, ReservingLuceneIndexWriter writer, LuceneIndexAccessor( LuceneDocumentStructure documentStructure, boolean readOnly, ReservingLuceneIndexWriter writer,
LuceneReferenceManager<IndexSearcher> searcherManager, LuceneReferenceManager<IndexSearcher> searcherManager,
Expand Down
Expand Up @@ -263,6 +263,12 @@ public void init() throws IOException
{ {
searcherManager = new SearcherManager( directory, new SearcherFactory() ); searcherManager = new SearcherManager( directory, new SearcherFactory() );
} }
catch ( IndexNotFoundException inf )
{
monitor.noIndex();
throw new IOException( "Label scan store not found while database was started in read only mode. " +
"To trigger a rebuild please restart database in writable mode.", inf );
}
catch ( IOException e ) catch ( IOException e )
{ {
monitor.corruptIndex( e ); monitor.corruptIndex( e );
Expand Down
@@ -0,0 +1,177 @@
/*
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Neo4j is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.index.impl.lucene;

import org.apache.lucene.document.Document;
import org.apache.lucene.document.FieldSelector;
import org.apache.lucene.index.CorruptIndexException;
import org.apache.lucene.index.FieldInfos;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.TermDocs;
import org.apache.lucene.index.TermEnum;
import org.apache.lucene.index.TermFreqVector;
import org.apache.lucene.index.TermPositions;
import org.apache.lucene.index.TermVectorMapper;

import java.io.IOException;
import java.util.Map;

class CloseTrackingIndexReader extends IndexReader
{
private boolean closed = false;

@Override
public TermFreqVector[] getTermFreqVectors( int docNumber ) throws IOException
{
return new TermFreqVector[0];
}

@Override
public TermFreqVector getTermFreqVector( int docNumber, String field ) throws IOException
{
return null;
}

@Override
public void getTermFreqVector( int docNumber, String field, TermVectorMapper mapper ) throws IOException
{

}

@Override
public void getTermFreqVector( int docNumber, TermVectorMapper mapper ) throws IOException
{

}

@Override
public int numDocs()
{
return 0;
}

@Override
public int maxDoc()
{
return 0;
}

@Override
public Document document( int n, FieldSelector fieldSelector ) throws CorruptIndexException, IOException
{
return null;
}

@Override
public boolean isDeleted( int n )
{
return false;
}

@Override
public boolean hasDeletions()
{
return false;
}

@Override
public byte[] norms( String field ) throws IOException
{
return new byte[0];
}

@Override
public void norms( String field, byte[] bytes, int offset ) throws IOException
{

}

@Override
protected void doSetNorm( int doc, String field, byte value ) throws CorruptIndexException, IOException
{

}

@Override
public TermEnum terms() throws IOException
{
return null;
}

@Override
public TermEnum terms( Term t ) throws IOException
{
return null;
}

@Override
public int docFreq( Term t ) throws IOException
{
return 0;
}

@Override
public TermDocs termDocs() throws IOException
{
return null;
}

@Override
public TermPositions termPositions() throws IOException
{
return null;
}

@Override
protected void doDelete( int docNum ) throws CorruptIndexException, IOException
{

}

@Override
protected void doUndeleteAll() throws CorruptIndexException, IOException
{

}

@Override
protected void doCommit( Map<String,String> commitUserData ) throws IOException
{

}

@Override
protected void doClose() throws IOException
{
closed = true;
}

@Override
public FieldInfos getFieldInfos()
{
return null;
}

public boolean isClosed()
{
return closed;
}
}

0 comments on commit e09d44d

Please sign in to comment.