-
Notifications
You must be signed in to change notification settings - Fork 872
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: start to split the logic of fetch from index step
- Loading branch information
Showing
8 changed files
with
248 additions
and
93 deletions.
There are no files selected for viewing
171 changes: 78 additions & 93 deletions
171
core/src/main/java/com/orientechnologies/orient/core/sql/executor/FetchFromIndexStep.java
Large diffs are not rendered by default.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
core/src/main/java/com/orientechnologies/orient/core/sql/executor/OAllIndexStream.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,26 @@ | ||
package com.orientechnologies.orient.core.sql.executor; | ||
|
||
import com.orientechnologies.common.util.ORawPair; | ||
import com.orientechnologies.orient.core.command.OCommandContext; | ||
import com.orientechnologies.orient.core.id.ORID; | ||
import com.orientechnologies.orient.core.index.OIndexInternal; | ||
import java.util.stream.Stream; | ||
|
||
class OAllIndexStream implements OIndexStream { | ||
private OIndexInternal index; | ||
private boolean asc; | ||
|
||
public OAllIndexStream(OIndexInternal index, boolean asc) { | ||
super(); | ||
this.index = index; | ||
this.asc = asc; | ||
} | ||
|
||
public Stream<ORawPair<Object, ORID>> start(OCommandContext ctx) { | ||
if (asc) { | ||
return index.stream(); | ||
} else { | ||
return index.descStream(); | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
core/src/main/java/com/orientechnologies/orient/core/sql/executor/OBetweenIndexStream.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,36 @@ | ||
package com.orientechnologies.orient.core.sql.executor; | ||
|
||
import com.orientechnologies.common.util.ORawPair; | ||
import com.orientechnologies.orient.core.command.OCommandContext; | ||
import com.orientechnologies.orient.core.id.ORID; | ||
import com.orientechnologies.orient.core.index.OIndexInternal; | ||
import java.util.stream.Stream; | ||
|
||
public class OBetweenIndexStream implements OIndexStream { | ||
private OIndexInternal index; | ||
private Object startKey; | ||
private boolean includeStart; | ||
private Object endKey; | ||
private boolean includeEnd; | ||
private boolean asc; | ||
|
||
public OBetweenIndexStream( | ||
OIndexInternal index, | ||
Object startKey, | ||
boolean includeStart, | ||
Object endKey, | ||
boolean includeEnd, | ||
boolean asc) { | ||
super(); | ||
this.index = index; | ||
this.startKey = startKey; | ||
this.includeStart = includeStart; | ||
this.endKey = endKey; | ||
this.includeEnd = includeEnd; | ||
this.asc = asc; | ||
} | ||
|
||
public Stream<ORawPair<Object, ORID>> start(OCommandContext ctx) { | ||
return index.streamEntriesBetween(startKey, includeStart, endKey, includeEnd, asc); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
core/src/main/java/com/orientechnologies/orient/core/sql/executor/OExactIndexStream.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,25 @@ | ||
package com.orientechnologies.orient.core.sql.executor; | ||
|
||
import com.orientechnologies.common.util.ORawPair; | ||
import com.orientechnologies.orient.core.command.OCommandContext; | ||
import com.orientechnologies.orient.core.id.ORID; | ||
import com.orientechnologies.orient.core.index.OIndexInternal; | ||
import java.util.Collection; | ||
import java.util.stream.Stream; | ||
|
||
public class OExactIndexStream implements OIndexStream { | ||
private OIndexInternal index; | ||
private Collection<Object> startKey; | ||
private boolean asc; | ||
|
||
public OExactIndexStream(OIndexInternal index, Collection<Object> startKey, boolean asc) { | ||
super(); | ||
this.index = index; | ||
this.startKey = startKey; | ||
this.asc = asc; | ||
} | ||
|
||
public Stream<ORawPair<Object, ORID>> start(OCommandContext ctx) { | ||
return index.streamEntries(startKey, asc); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
core/src/main/java/com/orientechnologies/orient/core/sql/executor/OIndexStream.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,10 @@ | ||
package com.orientechnologies.orient.core.sql.executor; | ||
|
||
import com.orientechnologies.common.util.ORawPair; | ||
import com.orientechnologies.orient.core.command.OCommandContext; | ||
import com.orientechnologies.orient.core.id.ORID; | ||
import java.util.stream.Stream; | ||
|
||
public interface OIndexStream { | ||
public Stream<ORawPair<Object, ORID>> start(OCommandContext ctx); | ||
} |
26 changes: 26 additions & 0 deletions
26
core/src/main/java/com/orientechnologies/orient/core/sql/executor/OMajorIndexStream.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,26 @@ | ||
package com.orientechnologies.orient.core.sql.executor; | ||
|
||
import com.orientechnologies.common.util.ORawPair; | ||
import com.orientechnologies.orient.core.command.OCommandContext; | ||
import com.orientechnologies.orient.core.id.ORID; | ||
import com.orientechnologies.orient.core.index.OIndexInternal; | ||
import java.util.stream.Stream; | ||
|
||
public class OMajorIndexStream implements OIndexStream { | ||
private OIndexInternal index; | ||
private Object startKey; | ||
private boolean include; | ||
private boolean asc; | ||
|
||
public OMajorIndexStream(OIndexInternal index, Object startKey, boolean include, boolean asc) { | ||
super(); | ||
this.index = index; | ||
this.startKey = startKey; | ||
this.include = include; | ||
this.asc = asc; | ||
} | ||
|
||
public Stream<ORawPair<Object, ORID>> start(OCommandContext ctx) { | ||
return index.streamEntriesMajor(startKey, include, asc); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
core/src/main/java/com/orientechnologies/orient/core/sql/executor/OMinorIndexStream.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,26 @@ | ||
package com.orientechnologies.orient.core.sql.executor; | ||
|
||
import com.orientechnologies.common.util.ORawPair; | ||
import com.orientechnologies.orient.core.command.OCommandContext; | ||
import com.orientechnologies.orient.core.id.ORID; | ||
import com.orientechnologies.orient.core.index.OIndexInternal; | ||
import java.util.stream.Stream; | ||
|
||
public class OMinorIndexStream implements OIndexStream { | ||
private OIndexInternal index; | ||
private Object startKey; | ||
private boolean include; | ||
private boolean asc; | ||
|
||
public OMinorIndexStream(OIndexInternal index, Object startKey, boolean include, boolean asc) { | ||
super(); | ||
this.index = index; | ||
this.startKey = startKey; | ||
this.include = include; | ||
this.asc = asc; | ||
} | ||
|
||
public Stream<ORawPair<Object, ORID>> start(OCommandContext ctx) { | ||
return index.streamEntriesMinor(startKey, include, asc); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
core/src/main/java/com/orientechnologies/orient/core/sql/executor/ONullIndexStream.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,21 @@ | ||
package com.orientechnologies.orient.core.sql.executor; | ||
|
||
import com.orientechnologies.common.util.ORawPair; | ||
import com.orientechnologies.orient.core.command.OCommandContext; | ||
import com.orientechnologies.orient.core.id.ORID; | ||
import com.orientechnologies.orient.core.index.OIndexInternal; | ||
import java.util.stream.Stream; | ||
|
||
public class ONullIndexStream implements OIndexStream { | ||
private OIndexInternal index; | ||
|
||
public ONullIndexStream(OIndexInternal index) { | ||
super(); | ||
this.index = index; | ||
} | ||
|
||
public Stream<ORawPair<Object, ORID>> start(OCommandContext ctx) { | ||
final Stream<ORID> stream = index.getRids(null); | ||
return stream.map((rid) -> new ORawPair<>(null, rid)); | ||
} | ||
} |