/** Construct a column map - the elements are the * mappings of a tuple originally in the order 0,1,2,... * so SPO->POS is 2,0,1 (SPO->POS so S->2, P->0, O->1) * and not 1,2,0 (which is the extraction mapping). * The label is just a label and is not interpreted. */ public ColumnMap(String label, int...elements) { this.label = label ; this.insertOrder = new int[elements.length] ; System.arraycopy(elements, 0, elements, 0, elements.length) ; Arrays.fill(insertOrder, -1) ; this.fetchOrder = new int[elements.length] ; Arrays.fill(fetchOrder, -1) ; for ( int i = 0 ; i < elements.length ; i++ ) { int x = elements[i] ; if ( x < 0 || x >= elements.length) throw new IllegalArgumentException("Out of range: "+x) ; // Checking if ( insertOrder[i] != -1 || fetchOrder[x] != -1 ) throw new IllegalArgumentException("Inconsistent: "+ListUtils.str(elements)) ; insertOrder[i] = x ; fetchOrder[x] = i ; } }
/** * Construct a mapping - the elements are the mappings of a tuple * originally in the order 0,1,2,... so SPO{@literal ->}POS is 2,0,1 (SPO{@literal ->}POS so S{@literal ->}2, * P{@literal ->}0, O{@literal ->}1) and not 1,2,0 (which is the extraction mapping). The label is * just a label and is not interpreted here. */ private TupleMap(String label, int... elements) { this.len = elements.length ; this.label = label; this.putTransform = new int[elements.length]; Arrays.fill(putTransform, -1); this.getTransform = new int[elements.length]; Arrays.fill(getTransform, -1); for ( int i = 0 ; i < elements.length ; i++ ) { int x = elements[i]; if ( x < 0 || x >= elements.length ) throw new IllegalArgumentException("Out of range: " + x); // Checking if ( putTransform[i] != -1 || getTransform[x] != -1 ) throw new IllegalArgumentException("Inconsistent: " + ListUtils.str(elements)); putTransform[i] = x; // The elements are the putTransform. getTransform[x] = i; } }
/** * Construct a mapping - the elements are the mappings of a tuple * originally in the order 0,1,2,... so SPO{@literal ->}POS is 2,0,1 (SPO{@literal ->}POS so S{@literal ->}2, * P{@literal ->}0, O{@literal ->}1) and not 1,2,0 (which is the extraction mapping). The label is * just a label and is not interpreted here. */ private TupleMap(String label, int... elements) { this.len = elements.length ; this.label = label; this.putTransform = new int[elements.length]; Arrays.fill(putTransform, -1); this.getTransform = new int[elements.length]; Arrays.fill(getTransform, -1); for ( int i = 0 ; i < elements.length ; i++ ) { int x = elements[i]; if ( x < 0 || x >= elements.length ) throw new IllegalArgumentException("Out of range: " + x); // Checking if ( putTransform[i] != -1 || getTransform[x] != -1 ) throw new IllegalArgumentException("Inconsistent: " + ListUtils.str(elements)); putTransform[i] = x; // The elements are the putTransform. getTransform[x] = i; } }
/** Construct a column map - the elements are the * mappings of a tuple originally in the order 0,1,2,... * so SPO->POS is 2,0,1 (SPO->POS so S->2, P->0, O->1) * and not 1,2,0 (which is the extraction mapping). * The label is just a lable and is not interpretted. */ public ColumnMap(String label, int...elements) { this.label = label ; this.insertOrder = new int[elements.length] ; System.arraycopy(elements, 0, elements, 0, elements.length) ; Arrays.fill(insertOrder, -1) ; this.fetchOrder = new int[elements.length] ; Arrays.fill(fetchOrder, -1) ; for ( int i = 0 ; i < elements.length ; i++ ) { int x = elements[i] ; if ( x < 0 || x >= elements.length) throw new IllegalArgumentException("Out of range: "+x) ; // Checking if ( insertOrder[i] != -1 || fetchOrder[x] != -1 ) throw new IllegalArgumentException("Inconsistent: "+ListUtils.str(elements)) ; insertOrder[i] = x ; fetchOrder[x] = i ; } }