LOGGER.debug( "Remote command: " + command );
switch( command ) {
case GET_INDEX:
DataInputStream dis = new DataInputStream( socket.getInputStream() );
DataOutputStream dos = new DataOutputStream( socket.getOutputStream() );
boolean randomAccess = dis.readBoolean();
boolean documentSizes = dis.readBoolean();
if ( index instanceof BitStreamIndex && ! forceRemoteIndex ) {
BitStreamIndex localIndex = (BitStreamIndex)index;
if ( randomAccess && localIndex.offsets == null ) {
randomAccess = false;
LOGGER.warn( "Random access will not be available for index " + localIndex );
}
/** Note that in case of Golomb or interpolative position coding
* we are forced to serialise and transfer the entire size list,
* or decoding would be too slow. */
BinIO.storeObject( new RemoteBitStreamIndex( localSocketAddress,
index.numberOfDocuments, index.numberOfTerms,
index.numberOfPostings, index.numberOfOccurrences,
index.maxCount, localIndex.payload, localIndex.frequencyCoding, localIndex.pointerCoding,
localIndex.countCoding,
localIndex.positionCoding,
localIndex.quantum,
localIndex.height,
localIndex.bufferSize,
localIndex.termProcessor,
localIndex.field,
localIndex.properties,
localIndex.termMap != null ? new RemoteTermMap( localSocketAddress, index.numberOfTerms ) : null,
localIndex.prefixMap != null ? new RemotePrefixMap( localSocketAddress, index.numberOfTerms ) : null,
localIndex.positionCoding == Coding.GOLOMB || localIndex.positionCoding == Coding.INTERPOLATIVE ? localIndex.sizes :
( documentSizes ? new RemoteSizeList( localSocketAddress, localIndex.numberOfDocuments ) : null ),
randomAccess ? new RemoteOffsetList( localSocketAddress, localIndex.offsets.size() ) : null
), dos );
}
else
BinIO.storeObject( new RemoteIndex( localSocketAddress, index.numberOfDocuments, index.numberOfTerms, index.numberOfPostings, index.numberOfOccurrences, index.maxCount, index.payload, index.hasCounts,
index.hasPositions, index.termProcessor, index.field, ( documentSizes ? new RemoteSizeList( localSocketAddress, index.numberOfDocuments ) : null ), index.properties ), dos );
dos.flush();
break;
case GET_INDEX_READER:
threadPool.execute( new RemoteIndexReader.ServerThread( socket, index ) );
break;