contrabase.api
Class ContrabaseResults

java.lang.Object
  extended by contrabase.api.ContrabaseResults

public class ContrabaseResults
extends java.lang.Object

API에서 Select 를 요청했을때 리포지토리에 데이터를 가지고 오는데 한꺼번에 가져오는것이 아니라 API의 캐쉬에 일정량을 담아서 가져오고 검색된 모든 결 데이터가 나올때 까지 반복하는 클래스

Author:
Jong10

Nested Class Summary
private static class ContrabaseResults.RepositoryCache
          Repository 에서 조건이나 key 값에 일치하는 결과를 리포지토리의 cache에 담아놓고 API가 요청하면 반환해주는 클래스
 
Field Summary
private  java.util.HashMap<java.lang.String,ContrabaseResults.RepositoryCache> caches
           
private  contrabase.network.MapReduce mapReduce
           
private  int maxCacheSize
           
private  java.util.List<contrabase.api.RepositoryInfo> repositories
           
 
Constructor Summary
ContrabaseResults(java.util.List<contrabase.api.RepositoryInfo> repositories)
          생성자 (최대 캐쉬 사이즈는 기본 값으로 설정된다.)
ContrabaseResults(java.util.List<contrabase.api.RepositoryInfo> repositories, int maxCacheSize)
          생성자 (최대 캐쉬 사이즈를 지정한다.)
 
Method Summary
private  boolean[] generateRequestable(int size)
          전송 요청을 할 대상들을 true로 표시한다.
private  contrabase.ObjectContainer getOneObject()
          외부 정렬을 해서, 객체 하나를 가져온다.
private  boolean hasEmptyCache()
          캐쉬중에 비어있는 리스트가 하나라도 있는지 체크한다.
 boolean hasNext()
          다음 노드가 있는지 확인한다.
private  void initialize(java.util.List<contrabase.api.RepositoryInfo> repositories)
          초기화 함수.
private  boolean isEnd()
          끝났는지 확인한다.
 java.lang.Object next()
          다음 노드를 객체로 가져온다.
 contrabase.ObjectContainer nextObjectContainer()
          다음 노드를 ObjectContainer 에 담아서 가져온다.
private  boolean refillCache()
          캐쉬를 리필한다.
private  contrabase.network.Message[] sendRequestsToRepositories(contrabase.network.Message request, boolean[] requestable)
          리포지토리들에 요청을 보낸다.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mapReduce

private contrabase.network.MapReduce mapReduce

caches

private java.util.HashMap<java.lang.String,ContrabaseResults.RepositoryCache> caches

maxCacheSize

private int maxCacheSize

repositories

private java.util.List<contrabase.api.RepositoryInfo> repositories
Constructor Detail

ContrabaseResults

public ContrabaseResults(java.util.List<contrabase.api.RepositoryInfo> repositories)
                  throws contrabase.network.ContrabaseNetworkException
생성자 (최대 캐쉬 사이즈는 기본 값으로 설정된다.)

Throws:
contrabase.network.ContrabaseNetworkException

ContrabaseResults

public ContrabaseResults(java.util.List<contrabase.api.RepositoryInfo> repositories,
                         int maxCacheSize)
                  throws contrabase.network.ContrabaseNetworkException
생성자 (최대 캐쉬 사이즈를 지정한다.) 최대 캐쉬 사이즈가 0보다 작거나 같으면, 기본값으로 된다.

Throws:
contrabase.network.ContrabaseNetworkException
Method Detail

initialize

private final void initialize(java.util.List<contrabase.api.RepositoryInfo> repositories)
                       throws contrabase.network.ContrabaseNetworkException
초기화 함수. (생성자에서 사용된다.)

Parameters:
messengers -
Throws:
contrabase.network.ContrabaseNetworkException
java.lang.InterruptedException

refillCache

private boolean refillCache()
캐쉬를 리필한다.

Returns:
한 개 이상 리필 되었는지?

generateRequestable

private boolean[] generateRequestable(int size)
전송 요청을 할 대상들을 true로 표시한다.

Parameters:
size -
Returns:

sendRequestsToRepositories

private contrabase.network.Message[] sendRequestsToRepositories(contrabase.network.Message request,
                                                                boolean[] requestable)
리포지토리들에 요청을 보낸다.

Parameters:
request -
responses -
requestable -
size -
Returns:

isEnd

private boolean isEnd()
끝났는지 확인한다.

Returns:

hasNext

public boolean hasNext()
다음 노드가 있는지 확인한다.

Returns:
다음 노드가 있으면 true, 없으면 false

hasEmptyCache

private boolean hasEmptyCache()
캐쉬중에 비어있는 리스트가 하나라도 있는지 체크한다.

Returns:
빈 거 있는가?

nextObjectContainer

public contrabase.ObjectContainer nextObjectContainer()
                                               throws java.lang.ClassNotFoundException
다음 노드를 ObjectContainer 에 담아서 가져온다.

Returns:
Throws:
java.lang.ClassNotFoundException
java.io.IOException

next

public java.lang.Object next()
                      throws java.lang.ClassNotFoundException,
                             java.io.IOException
다음 노드를 객체로 가져온다.

Returns:
Throws:
java.lang.ClassNotFoundException
java.io.IOException

getOneObject

private contrabase.ObjectContainer getOneObject()
외부 정렬을 해서, 객체 하나를 가져온다.

Returns: