Skip to content

Commit

Permalink
refactored GraphExtension
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter committed Feb 26, 2015
1 parent 5490f64 commit f69b67c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 29 deletions.
38 changes: 10 additions & 28 deletions core/src/main/java/com/graphhopper/storage/GraphExtension.java
Expand Up @@ -21,7 +21,7 @@
* If you need custom storages, like turn cost tables, or osmid tables for your graph you implement * If you need custom storages, like turn cost tables, or osmid tables for your graph you implement
* this interface and put it in any graph storage you want. * this interface and put it in any graph storage you want.
*/ */
public interface GraphExtension public interface GraphExtension extends Storable<GraphExtension>
{ {
/** /**
* @return true, if and only if, if an additional field at the graphs node storage is required * @return true, if and only if, if an additional field at the graphs node storage is required
Expand All @@ -48,36 +48,11 @@ public interface GraphExtension
*/ */
void init( GraphStorage graph ); void init( GraphStorage graph );


/**
* creates all additional data storages
*/
void create( long initSize );

/**
* loads from existing data storages
*/
boolean loadExisting();

/** /**
* sets the segment size in all additional data storages * sets the segment size in all additional data storages
*/ */
void setSegmentSize( int bytes ); void setSegmentSize( int bytes );


/**
* flushes all additional data storages
*/
void flush();

/**
* closes all additional data storages
*/
void close();

/**
* returns the sum of all additional data storages capacity
*/
long getCapacity();

/** /**
* creates a copy of this extended storage * creates a copy of this extended storage
*/ */
Expand Down Expand Up @@ -121,9 +96,10 @@ public void init( GraphStorage grap )
} }


@Override @Override
public void create( long initSize ) public GraphExtension create( long byteCount )
{ {
// noop // noop
return this;
} }


@Override @Override
Expand Down Expand Up @@ -168,6 +144,12 @@ public GraphExtension copyTo( GraphExtension extStorage )
public String toString() public String toString()
{ {
return "NoExt"; return "NoExt";
} }

@Override
public boolean isClosed()
{
return false;
}
} }
} }
Expand Up @@ -81,9 +81,10 @@ public void setSegmentSize( int bytes )
} }


@Override @Override
public void create( long initBytes ) public TurnCostExtension create( long initBytes )
{ {
turnCosts.create((long) initBytes * turnCostsEntryBytes); turnCosts.create((long) initBytes * turnCostsEntryBytes);
return this;
} }


@Override @Override
Expand Down Expand Up @@ -249,6 +250,12 @@ public GraphExtension copyTo( GraphExtension clonedStorage )
return clonedStorage; return clonedStorage;
} }


@Override
public boolean isClosed()
{
return turnCosts.isClosed();
}

@Override @Override
public String toString() public String toString()
{ {
Expand Down

0 comments on commit f69b67c

Please sign in to comment.