mirror of
https://github.com/apache/activemq.git
synced 2025-02-16 23:16:52 +00:00
removed System.out.println statements
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@546559 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b19f17c96b
commit
acc3ca79f8
@ -1,299 +1,312 @@
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE
|
||||
* file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file
|
||||
* to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
|
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.activemq.kaha.impl.index.hash;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Bin in a HashIndex
|
||||
*
|
||||
*
|
||||
* @version $Revision: 1.1.1.1 $
|
||||
*/
|
||||
class HashBin{
|
||||
|
||||
class HashBin {
|
||||
private static final transient Log log = LogFactory.getLog(HashBin.class);
|
||||
private HashIndex hashIndex;
|
||||
private int id;
|
||||
private int maximumEntries;
|
||||
private int size=0;
|
||||
private List<HashPageInfo> hashPages=new ArrayList<HashPageInfo>();
|
||||
private int size = 0;
|
||||
private List<HashPageInfo> hashPages = new ArrayList<HashPageInfo>();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
*
|
||||
* @param hashIndex
|
||||
* @param id
|
||||
* @param maximumEntries
|
||||
*/
|
||||
HashBin(HashIndex hashIndex,int id,int maximumEntries){
|
||||
this.hashIndex=hashIndex;
|
||||
this.id=id;
|
||||
this.maximumEntries=maximumEntries;
|
||||
HashBin(HashIndex hashIndex, int id, int maximumEntries) {
|
||||
this.hashIndex = hashIndex;
|
||||
this.id = id;
|
||||
this.maximumEntries = maximumEntries;
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
return "HashBin["+getId()+"]";
|
||||
public String toString() {
|
||||
return "HashBin[" + getId() + "]";
|
||||
}
|
||||
|
||||
public boolean equals(Object o){
|
||||
boolean result=false;
|
||||
if(o instanceof HashBin){
|
||||
HashBin other=(HashBin)o;
|
||||
result=other.id==id;
|
||||
public boolean equals(Object o) {
|
||||
boolean result = false;
|
||||
if (o instanceof HashBin) {
|
||||
HashBin other = (HashBin) o;
|
||||
result = other.id == id;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public int hashCode(){
|
||||
return (int)id;
|
||||
public int hashCode() {
|
||||
return (int) id;
|
||||
}
|
||||
|
||||
int getId(){
|
||||
int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
void setId(int id){
|
||||
this.id=id;
|
||||
void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
boolean isEmpty(){
|
||||
boolean isEmpty() {
|
||||
return true;
|
||||
}
|
||||
|
||||
int getMaximumEntries(){
|
||||
int getMaximumEntries() {
|
||||
return this.maximumEntries;
|
||||
}
|
||||
|
||||
void setMaximumEntries(int maximumEntries){
|
||||
this.maximumEntries=maximumEntries;
|
||||
void setMaximumEntries(int maximumEntries) {
|
||||
this.maximumEntries = maximumEntries;
|
||||
}
|
||||
|
||||
int size(){
|
||||
int size() {
|
||||
return size;
|
||||
}
|
||||
|
||||
HashPageInfo addHashPageInfo(long id,int size){
|
||||
HashPageInfo info=new HashPageInfo(hashIndex);
|
||||
HashPageInfo addHashPageInfo(long id, int size) {
|
||||
HashPageInfo info = new HashPageInfo(hashIndex);
|
||||
info.setId(id);
|
||||
info.setSize(size);
|
||||
hashPages.add(info);
|
||||
this.size+=size;
|
||||
this.size += size;
|
||||
return info;
|
||||
}
|
||||
|
||||
public HashEntry find(HashEntry key) throws IOException{
|
||||
HashEntry result=null;
|
||||
try{
|
||||
int low=0;
|
||||
int high=size()-1;
|
||||
while(low<=high){
|
||||
int mid=(low+high)>>1;
|
||||
HashEntry te=getHashEntry(mid);
|
||||
int cmp=te.compareTo(key);
|
||||
if(cmp==0){
|
||||
result=te;
|
||||
public HashEntry find(HashEntry key) throws IOException {
|
||||
HashEntry result = null;
|
||||
try {
|
||||
int low = 0;
|
||||
int high = size() - 1;
|
||||
while (low <= high) {
|
||||
int mid = (low + high) >> 1;
|
||||
HashEntry te = getHashEntry(mid);
|
||||
int cmp = te.compareTo(key);
|
||||
if (cmp == 0) {
|
||||
result = te;
|
||||
break;
|
||||
}else if(cmp<0){
|
||||
low=mid+1;
|
||||
}else{
|
||||
high=mid-1;
|
||||
}
|
||||
else if (cmp < 0) {
|
||||
low = mid + 1;
|
||||
}
|
||||
else {
|
||||
high = mid - 1;
|
||||
}
|
||||
}
|
||||
}finally{
|
||||
}
|
||||
finally {
|
||||
end();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void put(HashEntry newEntry) throws IOException{
|
||||
try{
|
||||
boolean replace=false;
|
||||
int low=0;
|
||||
int high=size()-1;
|
||||
while(low<=high){
|
||||
int mid=(low+high)>>1;
|
||||
HashEntry midVal=getHashEntry(mid);
|
||||
int cmp=midVal.compareTo(newEntry);
|
||||
if(cmp<0){
|
||||
low=mid+1;
|
||||
}else if(cmp>0){
|
||||
high=mid-1;
|
||||
}else{
|
||||
replace=true;
|
||||
void put(HashEntry newEntry) throws IOException {
|
||||
try {
|
||||
boolean replace = false;
|
||||
int low = 0;
|
||||
int high = size() - 1;
|
||||
while (low <= high) {
|
||||
int mid = (low + high) >> 1;
|
||||
HashEntry midVal = getHashEntry(mid);
|
||||
int cmp = midVal.compareTo(newEntry);
|
||||
if (cmp < 0) {
|
||||
low = mid + 1;
|
||||
}
|
||||
else if (cmp > 0) {
|
||||
high = mid - 1;
|
||||
}
|
||||
else {
|
||||
replace = true;
|
||||
midVal.setIndexOffset(newEntry.getIndexOffset());
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!replace){
|
||||
if (!replace) {
|
||||
if (low > size()) {
|
||||
System.out.println("SIZE() " + size() + " low = " + low);
|
||||
log.info("SIZE() " + size() + " low = " + low);
|
||||
}
|
||||
addHashEntry(low,newEntry);
|
||||
addHashEntry(low, newEntry);
|
||||
size++;
|
||||
}
|
||||
}finally{
|
||||
}
|
||||
finally {
|
||||
end();
|
||||
}
|
||||
}
|
||||
|
||||
HashEntry remove(HashEntry entry) throws IOException{
|
||||
HashEntry remove(HashEntry entry) throws IOException {
|
||||
HashEntry result = null;
|
||||
try{
|
||||
int low=0;
|
||||
int high=size()-1;
|
||||
while(low<=high){
|
||||
int mid=(low+high)>>1;
|
||||
HashEntry te=getHashEntry(mid);
|
||||
int cmp=te.compareTo(entry);
|
||||
if(cmp==0){
|
||||
result =te;
|
||||
try {
|
||||
int low = 0;
|
||||
int high = size() - 1;
|
||||
while (low <= high) {
|
||||
int mid = (low + high) >> 1;
|
||||
HashEntry te = getHashEntry(mid);
|
||||
int cmp = te.compareTo(entry);
|
||||
if (cmp == 0) {
|
||||
result = te;
|
||||
removeHashEntry(mid);
|
||||
size--;
|
||||
break;
|
||||
}else if(cmp<0){
|
||||
low=mid+1;
|
||||
}else{
|
||||
high=mid-1;
|
||||
}
|
||||
else if (cmp < 0) {
|
||||
low = mid + 1;
|
||||
}
|
||||
else {
|
||||
high = mid - 1;
|
||||
}
|
||||
}
|
||||
}finally{
|
||||
}
|
||||
finally {
|
||||
end();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void addHashEntry(int index,HashEntry entry) throws IOException{
|
||||
HashPageInfo page=getInsertPage(index);
|
||||
int offset=index%maximumEntries;
|
||||
page.addHashEntry(offset,entry);
|
||||
private void addHashEntry(int index, HashEntry entry) throws IOException {
|
||||
HashPageInfo page = getInsertPage(index);
|
||||
int offset = index % maximumEntries;
|
||||
page.addHashEntry(offset, entry);
|
||||
doOverFlow(index);
|
||||
}
|
||||
|
||||
private HashEntry removeHashEntry(int index) throws IOException{
|
||||
HashPageInfo page=getRetrievePage(index);
|
||||
int offset=getRetrieveOffset(index);
|
||||
HashEntry result=page.removeHashEntry(offset);
|
||||
private HashEntry removeHashEntry(int index) throws IOException {
|
||||
HashPageInfo page = getRetrievePage(index);
|
||||
int offset = getRetrieveOffset(index);
|
||||
HashEntry result = page.removeHashEntry(offset);
|
||||
doUnderFlow(index);
|
||||
return result;
|
||||
}
|
||||
|
||||
private HashEntry getHashEntry(int index) throws IOException{
|
||||
HashPageInfo page=getRetrievePage(index);
|
||||
private HashEntry getHashEntry(int index) throws IOException {
|
||||
HashPageInfo page = getRetrievePage(index);
|
||||
page.begin();
|
||||
int offset=getRetrieveOffset(index);
|
||||
HashEntry result=page.getHashEntry(offset);
|
||||
int offset = getRetrieveOffset(index);
|
||||
HashEntry result = page.getHashEntry(offset);
|
||||
return result;
|
||||
}
|
||||
|
||||
private int maximumBinSize(){
|
||||
return maximumEntries*hashPages.size();
|
||||
private int maximumBinSize() {
|
||||
return maximumEntries * hashPages.size();
|
||||
}
|
||||
|
||||
private HashPageInfo getInsertPage(int index) throws IOException{
|
||||
HashPageInfo result=null;
|
||||
if(index>=maximumBinSize()){
|
||||
HashPage page=hashIndex.createPage(id);
|
||||
result=addHashPageInfo(page.getId(),0);
|
||||
private HashPageInfo getInsertPage(int index) throws IOException {
|
||||
HashPageInfo result = null;
|
||||
if (index >= maximumBinSize()) {
|
||||
HashPage page = hashIndex.createPage(id);
|
||||
result = addHashPageInfo(page.getId(), 0);
|
||||
result.setPage(page);
|
||||
}else{
|
||||
int offset=index/maximumEntries;
|
||||
result=hashPages.get(offset);
|
||||
}
|
||||
else {
|
||||
int offset = index / maximumEntries;
|
||||
result = hashPages.get(offset);
|
||||
}
|
||||
result.begin();
|
||||
return result;
|
||||
}
|
||||
|
||||
private HashPageInfo getRetrievePage(int index) throws IOException{
|
||||
HashPageInfo result=null;
|
||||
int count=0;
|
||||
int pageNo=0;
|
||||
for(HashPageInfo page:hashPages){
|
||||
count+=page.size();
|
||||
if(index<count){
|
||||
private HashPageInfo getRetrievePage(int index) throws IOException {
|
||||
HashPageInfo result = null;
|
||||
int count = 0;
|
||||
int pageNo = 0;
|
||||
for (HashPageInfo page : hashPages) {
|
||||
count += page.size();
|
||||
if (index < count) {
|
||||
break;
|
||||
}
|
||||
pageNo++;
|
||||
}
|
||||
result=hashPages.get(pageNo);
|
||||
result = hashPages.get(pageNo);
|
||||
result.begin();
|
||||
return result;
|
||||
}
|
||||
|
||||
private int getRetrieveOffset(int index) throws IOException{
|
||||
int result=0;
|
||||
int count=0;
|
||||
for(HashPageInfo page:hashPages){
|
||||
if((index+1)<=(count+page.size())){
|
||||
private int getRetrieveOffset(int index) throws IOException {
|
||||
int result = 0;
|
||||
int count = 0;
|
||||
for (HashPageInfo page : hashPages) {
|
||||
if ((index + 1) <= (count + page.size())) {
|
||||
// count=count==0?count:count+1;
|
||||
result=index-count;
|
||||
result = index - count;
|
||||
break;
|
||||
}
|
||||
count+=page.size();
|
||||
count += page.size();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private int getInsertPageNo(int index){
|
||||
int result=index/maximumEntries;
|
||||
private int getInsertPageNo(int index) {
|
||||
int result = index / maximumEntries;
|
||||
return result;
|
||||
}
|
||||
|
||||
private int getOffset(int index){
|
||||
int result=index%maximumEntries;
|
||||
private int getOffset(int index) {
|
||||
int result = index % maximumEntries;
|
||||
return result;
|
||||
}
|
||||
|
||||
private void doOverFlow(int index) throws IOException{
|
||||
int pageNo=index/maximumEntries;
|
||||
HashPageInfo info=hashPages.get(pageNo);
|
||||
if(info.size()>maximumEntries){
|
||||
private void doOverFlow(int index) throws IOException {
|
||||
int pageNo = index / maximumEntries;
|
||||
HashPageInfo info = hashPages.get(pageNo);
|
||||
if (info.size() > maximumEntries) {
|
||||
// overflowed
|
||||
HashEntry entry=info.removeHashEntry(info.size()-1);
|
||||
doOverFlow(pageNo+1,entry);
|
||||
HashEntry entry = info.removeHashEntry(info.size() - 1);
|
||||
doOverFlow(pageNo + 1, entry);
|
||||
}
|
||||
}
|
||||
|
||||
private void doOverFlow(int pageNo,HashEntry entry) throws IOException{
|
||||
HashPageInfo info=null;
|
||||
if(pageNo>=hashPages.size()){
|
||||
HashPage page=hashIndex.createPage(id);
|
||||
info=addHashPageInfo(page.getId(),0);
|
||||
private void doOverFlow(int pageNo, HashEntry entry) throws IOException {
|
||||
HashPageInfo info = null;
|
||||
if (pageNo >= hashPages.size()) {
|
||||
HashPage page = hashIndex.createPage(id);
|
||||
info = addHashPageInfo(page.getId(), 0);
|
||||
info.setPage(page);
|
||||
}else{
|
||||
info=hashPages.get(pageNo);
|
||||
}
|
||||
else {
|
||||
info = hashPages.get(pageNo);
|
||||
}
|
||||
info.begin();
|
||||
info.addHashEntry(0,entry);
|
||||
if(info.size()>maximumEntries){
|
||||
info.addHashEntry(0, entry);
|
||||
if (info.size() > maximumEntries) {
|
||||
// overflowed
|
||||
HashEntry overflowed=info.removeHashEntry(info.size()-1);
|
||||
doOverFlow(pageNo+1,overflowed);
|
||||
HashEntry overflowed = info.removeHashEntry(info.size() - 1);
|
||||
doOverFlow(pageNo + 1, overflowed);
|
||||
}
|
||||
}
|
||||
|
||||
private void doUnderFlow(int index){
|
||||
int pageNo=index/maximumEntries;
|
||||
int nextPageNo=pageNo+1;
|
||||
if(nextPageNo<hashPages.size()){
|
||||
private void doUnderFlow(int index) {
|
||||
int pageNo = index / maximumEntries;
|
||||
int nextPageNo = pageNo + 1;
|
||||
if (nextPageNo < hashPages.size()) {
|
||||
}
|
||||
HashPageInfo info=hashPages.get(pageNo);
|
||||
HashPageInfo info = hashPages.get(pageNo);
|
||||
}
|
||||
|
||||
private void end() throws IOException{
|
||||
for(HashPageInfo info:hashPages){
|
||||
private void end() throws IOException {
|
||||
for (HashPageInfo info : hashPages) {
|
||||
info.end();
|
||||
}
|
||||
}
|
||||
|
@ -1,39 +1,36 @@
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE
|
||||
* file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file
|
||||
* to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
|
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.activemq.kaha.impl.index.hash;
|
||||
|
||||
import org.apache.activemq.kaha.Marshaller;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import org.apache.activemq.kaha.Marshaller;
|
||||
|
||||
/**
|
||||
* A Page within a HashPage
|
||||
*
|
||||
*
|
||||
* @version $Revision: 1.1.1.1 $
|
||||
*/
|
||||
class HashPage{
|
||||
|
||||
static final int PAGE_HEADER_SIZE=17;
|
||||
|
||||
|
||||
|
||||
class HashPage {
|
||||
private static final transient Log log = LogFactory.getLog(HashPage.class);
|
||||
static final int PAGE_HEADER_SIZE = 17;
|
||||
private int maximumEntries;
|
||||
private long id;
|
||||
private int binId;
|
||||
@ -42,206 +39,196 @@ class HashPage{
|
||||
/*
|
||||
* for persistence only
|
||||
*/
|
||||
private long nextFreePageId=HashEntry.NOT_SET;
|
||||
private boolean active=true;
|
||||
private long nextFreePageId = HashEntry.NOT_SET;
|
||||
private boolean active = true;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
*
|
||||
* @param hashIndex
|
||||
* @param id
|
||||
* @param parentId
|
||||
* @param maximumEntries
|
||||
*/
|
||||
HashPage(long id,int maximumEntries){
|
||||
HashPage(long id, int maximumEntries) {
|
||||
this(maximumEntries);
|
||||
|
||||
this.id=id;
|
||||
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
*
|
||||
* @param maximumEntries
|
||||
*/
|
||||
public HashPage(int maximumEntries){
|
||||
this.maximumEntries=maximumEntries;
|
||||
this.hashIndexEntries=new ArrayList<HashEntry>(maximumEntries);
|
||||
public HashPage(int maximumEntries) {
|
||||
this.maximumEntries = maximumEntries;
|
||||
this.hashIndexEntries = new ArrayList<HashEntry>(maximumEntries);
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
return "HashPage["+getId()+":" + binId + "]";
|
||||
public String toString() {
|
||||
return "HashPage[" + getId() + ":" + binId + "]";
|
||||
}
|
||||
|
||||
public boolean equals(Object o){
|
||||
boolean result=false;
|
||||
if(o instanceof HashPage){
|
||||
HashPage other=(HashPage)o;
|
||||
result=other.id==id;
|
||||
public boolean equals(Object o) {
|
||||
boolean result = false;
|
||||
if (o instanceof HashPage) {
|
||||
HashPage other = (HashPage) o;
|
||||
result = other.id == id;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public int hashCode(){
|
||||
return (int)id;
|
||||
public int hashCode() {
|
||||
return (int) id;
|
||||
}
|
||||
|
||||
boolean isActive(){
|
||||
boolean isActive() {
|
||||
return this.active;
|
||||
}
|
||||
|
||||
void setActive(boolean active){
|
||||
this.active=active;
|
||||
void setActive(boolean active) {
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
long getNextFreePageId(){
|
||||
long getNextFreePageId() {
|
||||
return this.nextFreePageId;
|
||||
}
|
||||
|
||||
void setNextFreePageId(long nextPageId){
|
||||
this.nextFreePageId=nextPageId;
|
||||
void setNextFreePageId(long nextPageId) {
|
||||
this.nextFreePageId = nextPageId;
|
||||
}
|
||||
|
||||
long getId(){
|
||||
long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
void setId(long id){
|
||||
this.id=id;
|
||||
void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
int getPersistedSize() {
|
||||
return persistedSize;
|
||||
}
|
||||
|
||||
void write(Marshaller keyMarshaller,DataOutput dataOut) throws IOException{
|
||||
void write(Marshaller keyMarshaller, DataOutput dataOut) throws IOException {
|
||||
writeHeader(dataOut);
|
||||
dataOut.writeInt(hashIndexEntries.size());
|
||||
for(HashEntry entry:hashIndexEntries){
|
||||
entry.write(keyMarshaller,dataOut);
|
||||
for (HashEntry entry : hashIndexEntries) {
|
||||
entry.write(keyMarshaller, dataOut);
|
||||
}
|
||||
}
|
||||
|
||||
void read(Marshaller keyMarshaller,DataInput dataIn) throws IOException{
|
||||
void read(Marshaller keyMarshaller, DataInput dataIn) throws IOException {
|
||||
readHeader(dataIn);
|
||||
int size=dataIn.readInt();
|
||||
int size = dataIn.readInt();
|
||||
hashIndexEntries.clear();
|
||||
for(int i=0;i<size;i++){
|
||||
HashEntry entry=new HashEntry();
|
||||
entry.read(keyMarshaller,dataIn);
|
||||
for (int i = 0; i < size; i++) {
|
||||
HashEntry entry = new HashEntry();
|
||||
entry.read(keyMarshaller, dataIn);
|
||||
hashIndexEntries.add(entry);
|
||||
}
|
||||
}
|
||||
|
||||
void readHeader(DataInput dataIn) throws IOException{
|
||||
active=dataIn.readBoolean();
|
||||
nextFreePageId=dataIn.readLong();
|
||||
binId=dataIn.readInt();
|
||||
persistedSize=dataIn.readInt();
|
||||
void readHeader(DataInput dataIn) throws IOException {
|
||||
active = dataIn.readBoolean();
|
||||
nextFreePageId = dataIn.readLong();
|
||||
binId = dataIn.readInt();
|
||||
persistedSize = dataIn.readInt();
|
||||
}
|
||||
|
||||
void writeHeader(DataOutput dataOut) throws IOException{
|
||||
void writeHeader(DataOutput dataOut) throws IOException {
|
||||
dataOut.writeBoolean(isActive());
|
||||
dataOut.writeLong(nextFreePageId);
|
||||
dataOut.writeInt(binId);
|
||||
dataOut.writeInt(size());
|
||||
}
|
||||
|
||||
boolean isEmpty(){
|
||||
boolean isEmpty() {
|
||||
return hashIndexEntries.isEmpty();
|
||||
}
|
||||
|
||||
boolean isFull(){
|
||||
return(hashIndexEntries.size()>=maximumEntries);
|
||||
boolean isFull() {
|
||||
return (hashIndexEntries.size() >= maximumEntries);
|
||||
}
|
||||
|
||||
boolean isUnderflowed(){
|
||||
return hashIndexEntries.size()<(maximumEntries/2);
|
||||
boolean isUnderflowed() {
|
||||
return hashIndexEntries.size() < (maximumEntries / 2);
|
||||
}
|
||||
|
||||
boolean isOverflowed(){
|
||||
return hashIndexEntries.size()>maximumEntries;
|
||||
boolean isOverflowed() {
|
||||
return hashIndexEntries.size() > maximumEntries;
|
||||
}
|
||||
|
||||
List<HashEntry> getEntries(){
|
||||
List<HashEntry> getEntries() {
|
||||
return hashIndexEntries;
|
||||
}
|
||||
|
||||
void setEntries(List<HashEntry> newEntries){
|
||||
this.hashIndexEntries=newEntries;
|
||||
void setEntries(List<HashEntry> newEntries) {
|
||||
this.hashIndexEntries = newEntries;
|
||||
}
|
||||
|
||||
int getMaximumEntries(){
|
||||
int getMaximumEntries() {
|
||||
return this.maximumEntries;
|
||||
}
|
||||
|
||||
void setMaximumEntries(int maximumEntries){
|
||||
this.maximumEntries=maximumEntries;
|
||||
void setMaximumEntries(int maximumEntries) {
|
||||
this.maximumEntries = maximumEntries;
|
||||
}
|
||||
|
||||
int size(){
|
||||
int size() {
|
||||
return hashIndexEntries.size();
|
||||
}
|
||||
|
||||
|
||||
void reset() throws IOException{
|
||||
void reset() throws IOException {
|
||||
hashIndexEntries.clear();
|
||||
setNextFreePageId(HashEntry.NOT_SET);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void addHashEntry(int index,HashEntry entry) throws IOException{
|
||||
void addHashEntry(int index, HashEntry entry) throws IOException {
|
||||
//index = index >= 0 ? index : 0;
|
||||
//index = (index == 0 || index< size()) ? index : size()-1;
|
||||
hashIndexEntries.add(index,entry);
|
||||
hashIndexEntries.add(index, entry);
|
||||
}
|
||||
|
||||
|
||||
HashEntry getHashEntry(int index){
|
||||
HashEntry result=hashIndexEntries.get(index);
|
||||
HashEntry getHashEntry(int index) {
|
||||
HashEntry result = hashIndexEntries.get(index);
|
||||
return result;
|
||||
}
|
||||
|
||||
HashEntry removeHashEntry(int index) throws IOException{
|
||||
HashEntry result=hashIndexEntries.remove(index);
|
||||
HashEntry removeHashEntry(int index) throws IOException {
|
||||
HashEntry result = hashIndexEntries.remove(index);
|
||||
return result;
|
||||
}
|
||||
|
||||
void removeAllTreeEntries(List<HashEntry> c){
|
||||
void removeAllTreeEntries(List<HashEntry> c) {
|
||||
hashIndexEntries.removeAll(c);
|
||||
}
|
||||
|
||||
List<HashEntry> getSubList(int from,int to){
|
||||
return new ArrayList<HashEntry>(hashIndexEntries.subList(from,to));
|
||||
List<HashEntry> getSubList(int from, int to) {
|
||||
return new ArrayList<HashEntry>(hashIndexEntries.subList(from, to));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return the binId
|
||||
*/
|
||||
int getBinId(){
|
||||
int getBinId() {
|
||||
return this.binId;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param binId the binId to set
|
||||
*/
|
||||
void setBinId(int binId){
|
||||
this.binId=binId;
|
||||
}
|
||||
|
||||
|
||||
void dump() {
|
||||
|
||||
String str = this + ": ";
|
||||
for(HashEntry entry: hashIndexEntries) {
|
||||
str += entry + ",";
|
||||
}
|
||||
System.out.println(str);
|
||||
void setBinId(int binId) {
|
||||
this.binId = binId;
|
||||
}
|
||||
|
||||
|
||||
void dump() {
|
||||
|
||||
String str = this + ": ";
|
||||
for (HashEntry entry : hashIndexEntries) {
|
||||
str += entry + ",";
|
||||
}
|
||||
log.info(str);
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -143,7 +143,7 @@ public class ProxyConnector implements Service {
|
||||
// Add a transport filter so that can track the transport life cycle
|
||||
transport = new TransportFilter(transport) {
|
||||
public void stop() throws Exception {
|
||||
System.out.println("Stopping proxy.");
|
||||
log.info("Stopping proxy.");
|
||||
super.stop();
|
||||
connections.remove(this);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user