Skip to content

Commit

Permalink
WIP start of true composite support
Browse files Browse the repository at this point in the history
  • Loading branch information
tinwelint authored and burqen committed Jul 27, 2018
1 parent ddea2af commit 33af284
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 11 deletions.
Expand Up @@ -56,4 +56,10 @@ public boolean supportsTemporal()
{
return true;
}

@Override
public boolean supportsGranularCompositeQueries()
{
return true;
}
}
Expand Up @@ -68,6 +68,11 @@ public abstract class IndexProviderCompatibilityTestSuite

public abstract boolean supportsTemporal();

public boolean supportsGranularCompositeQueries()
{
return false;
}

public abstract static class Compatibility
{
@Rule
Expand Down
Expand Up @@ -79,7 +79,7 @@ class GenericKeyState extends TemporalValueWriterAdapter<RuntimeException>
private long long2;
private long long3;
private byte[] byteArray;
private NativeIndexKey.Inclusion inclusion;
NativeIndexKey.Inclusion inclusion;

void clear()
{
Expand Down Expand Up @@ -554,6 +554,11 @@ void copyFrom( GenericKeyState key )
}

int size()
{
return valueSize() + TYPE_ID_SIZE;
}

private int valueSize()
{
// TODO copy-pasted from individual keys
// TODO also put this in Type enum
Expand Down
Expand Up @@ -30,8 +30,8 @@

class GenericLayout extends IndexLayout<CompositeGenericKey>
{
private static final int KEY_HEADER_SIZE = Byte.BYTES;
static final Comparator<Type> TYPE_COMPARATOR = comparing( t -> t.valueGroup );
private final int numberOfSlots;

enum Type
{
Expand Down Expand Up @@ -72,16 +72,16 @@ enum Type
}
}

GenericLayout()
GenericLayout( int numberOfSlots )
{
super( "NSIL", 0, 1 );
this.numberOfSlots = numberOfSlots;
}

@Override
public CompositeGenericKey newKey()
{
// TODO for now it's not composite
return new CompositeGenericKey( 1 );
return new CompositeGenericKey( numberOfSlots );
}

@Override
Expand All @@ -95,11 +95,6 @@ public CompositeGenericKey copyKey( CompositeGenericKey key, CompositeGenericKey

@Override
public int keySize( CompositeGenericKey key )
{
return KEY_HEADER_SIZE + actualKeySize( key );
}

private int actualKeySize( CompositeGenericKey key )
{
return key.size();
}
Expand Down
Expand Up @@ -70,7 +70,8 @@ public GenericNativeIndexProvider( int priority, IndexDirectoryStructure.Factory
@Override
Layout<CompositeGenericKey,NativeIndexValue> layout( StoreIndexDescriptor descriptor )
{
return new GenericLayout();
int numberOfSlots = descriptor.properties().length;
return new GenericLayout( numberOfSlots );
}

@Override
Expand Down

0 comments on commit 33af284

Please sign in to comment.