Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable online updating for temporal values
- Loading branch information
1 parent
789832f
commit 1e705c8
Showing
6 changed files
with
188 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 121 additions & 0 deletions
121
community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/TemporalIndexUpdater.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
/* | ||
* Copyright (c) 2002-2018 "Neo Technology," | ||
* Network Engine for Objects in Lund AB [http://neotechnology.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Neo4j is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.neo4j.kernel.impl.index.schema; | ||
|
||
import java.io.IOException; | ||
|
||
import org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException; | ||
import org.neo4j.kernel.api.index.IndexEntryUpdate; | ||
import org.neo4j.kernel.api.index.IndexUpdater; | ||
import org.neo4j.kernel.impl.api.index.IndexUpdateMode; | ||
import org.neo4j.kernel.impl.index.schema.fusion.FusionIndexUtils; | ||
|
||
public class TemporalIndexUpdater extends TemporalIndexCache<NativeSchemaIndexUpdater<?, NativeSchemaValue>,IOException> implements IndexUpdater | ||
{ | ||
TemporalIndexUpdater( TemporalIndexAccessor accessor, IndexUpdateMode mode ) | ||
{ | ||
super( new PartFactory( accessor, mode ) ); | ||
} | ||
|
||
@Override | ||
public void process( IndexEntryUpdate<?> update ) throws IOException, IndexEntryConflictException | ||
{ | ||
IndexUpdater to = select( update.values()[0].valueGroup() ); | ||
switch ( update.updateMode() ) | ||
{ | ||
case ADDED: | ||
case REMOVED: | ||
to.process( update ); | ||
break; | ||
case CHANGED: | ||
IndexUpdater from = select( update.beforeValues()[0].valueGroup() ); | ||
// There are two cases: | ||
// - both before/after go into the same updater --> pass update into that updater | ||
if ( from == to ) | ||
{ | ||
from.process( update ); | ||
} | ||
// - before go into one and after into the other --> REMOVED from one and ADDED into the other | ||
else | ||
{ | ||
from.process( IndexEntryUpdate.remove( update.getEntityId(), update.indexKey(), update.beforeValues() ) ); | ||
to.process( IndexEntryUpdate.add( update.getEntityId(), update.indexKey(), update.values() ) ); | ||
} | ||
break; | ||
default: | ||
throw new IllegalArgumentException( "Unknown update mode" ); | ||
} | ||
} | ||
|
||
@Override | ||
public void close() throws IOException, IndexEntryConflictException | ||
{ | ||
FusionIndexUtils.forAll( NativeSchemaIndexUpdater::close, this ); | ||
} | ||
|
||
static class PartFactory implements TemporalIndexCache.Factory<NativeSchemaIndexUpdater<?, NativeSchemaValue>,IOException> | ||
{ | ||
|
||
private final TemporalIndexAccessor accessor; | ||
private final IndexUpdateMode mode; | ||
|
||
PartFactory( TemporalIndexAccessor accessor, IndexUpdateMode mode ) | ||
{ | ||
this.accessor = accessor; | ||
this.mode = mode; | ||
} | ||
|
||
@Override | ||
public NativeSchemaIndexUpdater<?, NativeSchemaValue> newDate() throws IOException | ||
{ | ||
return accessor.date().newUpdater( mode ); | ||
} | ||
|
||
@Override | ||
public NativeSchemaIndexUpdater<?, NativeSchemaValue> newDateTime() throws IOException | ||
{ | ||
throw new UnsupportedOperationException( "ma-a-da dayo" ); | ||
} | ||
|
||
@Override | ||
public NativeSchemaIndexUpdater<?, NativeSchemaValue> newDateTimeZoned() throws IOException | ||
{ | ||
throw new UnsupportedOperationException( "ma-a-da dayo" ); | ||
} | ||
|
||
@Override | ||
public NativeSchemaIndexUpdater<?, NativeSchemaValue> newTime() throws IOException | ||
{ | ||
throw new UnsupportedOperationException( "ma-a-da dayo" ); | ||
} | ||
|
||
@Override | ||
public NativeSchemaIndexUpdater<?, NativeSchemaValue> newTimeZoned() throws IOException | ||
{ | ||
throw new UnsupportedOperationException( "ma-a-da dayo" ); | ||
} | ||
|
||
@Override | ||
public NativeSchemaIndexUpdater<?, NativeSchemaValue> newDuration() throws IOException | ||
{ | ||
throw new UnsupportedOperationException( "ma-a-da dayo" ); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters